Add ENABLE_NEWS and disable curl if it's not needed

This commit is contained in:
David Capello 2018-08-24 18:24:05 -03:00
parent 44a713a693
commit 1b5fd7ccef
5 changed files with 56 additions and 22 deletions

View File

@ -68,18 +68,25 @@ option(USE_SHARED_TINYXML "Use your installed copy of tinyxml" off)
option(USE_SHARED_PIXMAN "Use your installed copy of pixman" off)
option(USE_SHARED_FREETYPE "Use shared FreeType library" off)
option(USE_SHARED_HARFBUZZ "Use shared HarfBuzz library" off)
option(ENABLE_MEMLEAK "Enable memory-leaks detector (only for developers)" off)
option(ENABLE_UPDATER "Enable automatic check for updates" on)
option(ENABLE_SCRIPTING "Compile with scripting support" on)
option(ENABLE_TESTS "Compile unit tests" off)
option(ENABLE_BENCHMARKS "Compile benchmarks" off)
option(ENABLE_TRIAL_MODE "Compile the trial version" off)
option(ENABLE_STEAM "Compile with Steam library" off)
option(ENABLE_DEVMODE "Compile vesion for developers" off)
option(ENABLE_UI "Compile UI (turn off to compile CLI-only version)" on)
option(ENABLE_MEMLEAK "Enable memory-leaks detector (only for developers)" off)
option(ENABLE_NEWS "Enable the news in Home tab" on)
option(ENABLE_UPDATER "Enable automatic check for updates" on)
option(ENABLE_SCRIPTING "Compile with scripting support" on)
option(ENABLE_TESTS "Compile unit tests" off)
option(ENABLE_BENCHMARKS "Compile benchmarks" off)
option(ENABLE_TRIAL_MODE "Compile the trial version" off)
option(ENABLE_STEAM "Compile with Steam library" off)
option(ENABLE_DEVMODE "Compile vesion for developers" off)
option(ENABLE_UI "Compile UI (turn off to compile CLI-only version)" on)
option(FULLSCREEN_PLATFORM "Enable fullscreen by default" off)
set(CUSTOM_WEBSITE_URL "" CACHE STRING "Enable custom local webserver to check updates")
if(ENABLE_NEWS OR ENABLE_UPDATER)
set(REQUIRE_CURL ON)
else()
set(REQUIRE_CURL OFF)
endif()
if(NOT ENABLE_UI)
set(LAF_OS_BACKEND "none") # Without UI, we use the none backend
else()
@ -288,13 +295,15 @@ else()
include_directories(${CMAKE_BINARY_DIR}/third_party/cmark)
endif()
if(USE_SHARED_CURL)
find_package(CURL REQUIRED)
else()
set(CURL_LIBRARIES libcurl)
set(CURL_INCLUDE_DIRS ${CURL_DIR}/include)
if(REQUIRE_CURL)
if(USE_SHARED_CURL)
find_package(CURL REQUIRED)
else()
set(CURL_LIBRARIES libcurl)
set(CURL_INCLUDE_DIRS ${CURL_DIR}/include)
endif()
include_directories(${CURL_INCLUDE_DIRS})
endif()
include_directories(${CURL_INCLUDE_DIRS})
# simpleini
include_directories(${SIMPLEINI_DIR})

View File

@ -24,6 +24,10 @@ if(MSVC)
add_definitions(-D_SCL_SECURE_NO_WARNINGS)
endif(MSVC)
if(ENABLE_NEWS)
add_definitions(-DENABLE_NEWS)
endif()
if(ENABLE_UPDATER)
add_definitions(-DENABLE_UPDATER)
endif()
@ -43,7 +47,7 @@ endif()
######################################################################
# With static libcurl
if(NOT USE_SHARED_CURL AND CURL_STATICLIB)
if(REQUIRE_CURL AND NOT USE_SHARED_CURL AND CURL_STATICLIB)
add_definitions(-DCURL_STATICLIB)
endif()
@ -94,11 +98,14 @@ add_subdirectory(doc)
add_subdirectory(filters)
add_subdirectory(fixmath)
add_subdirectory(flic)
add_subdirectory(net)
add_subdirectory(render)
add_subdirectory(dio)
add_subdirectory(ui)
if(REQUIRE_CURL)
add_subdirectory(net)
endif()
if(GEN_EXE)
add_executable(gen IMPORTED)
set_target_properties(gen PROPERTIES IMPORTED_LOCATION ${GEN_EXE})

View File

@ -361,7 +361,6 @@ if(ENABLE_UI)
ui/keyboard_shortcuts.cpp
ui/main_menu_bar.cpp
ui/main_window.cpp
ui/news_listbox.cpp
ui/notifications.cpp
ui/optional_alert.cpp
ui/palette_popup.cpp
@ -395,6 +394,12 @@ if(ENABLE_UI)
util/clipboard.cpp
util/clipboard_native.cpp
widget_loader.cpp)
if(ENABLE_NEWS)
set(ui_app_files
res/http_loader.cpp
ui/news_listbox.cpp
${ui_app_files})
endif()
endif()
add_library(app-lib
@ -530,7 +535,6 @@ add_library(app-lib
pref/preferences.cpp
project.cpp
recent_files.cpp
res/http_loader.cpp
res/palettes_loader_delegate.cpp
res/resources_loader.cpp
resource_finder.cpp
@ -575,7 +579,6 @@ target_link_libraries(app-lib
fixmath-lib
flic-lib
laf-gfx
net-lib
render-lib
laf-ft
laf-os
@ -595,6 +598,10 @@ target_link_libraries(app-lib
fmt
tinyexpr)
if(REQUIRE_CURL)
target_link_libraries(app-lib net-lib)
endif()
if(ENABLE_SCRIPTING)
target_link_libraries(app-lib lua lauxlib lualib)
endif()

View File

@ -17,7 +17,6 @@
#include "app/i18n/strings.h"
#include "app/ui/data_recovery_view.h"
#include "app/ui/main_window.h"
#include "app/ui/news_listbox.h"
#include "app/ui/recent_listbox.h"
#include "app/ui/skin/skin_theme.h"
#include "app/ui/workspace.h"
@ -32,6 +31,10 @@
#include "ui/textbox.h"
#include "ui/view.h"
#ifdef ENABLE_NEWS
#include "app/ui/news_listbox.h"
#endif
namespace app {
using namespace ui;
@ -40,7 +43,9 @@ using namespace app::skin;
HomeView::HomeView()
: m_files(new RecentFilesListBox)
, m_folders(new RecentFoldersListBox)
#ifdef ENABLE_NEWS
, m_news(new NewsListBox)
#endif
, m_dataRecovery(nullptr)
, m_dataRecoveryView(nullptr)
{
@ -50,7 +55,9 @@ HomeView::HomeView()
filesView()->attachToView(m_files);
foldersView()->attachToView(m_folders);
#ifdef ENABLE_NEWS
newsView()->attachToView(m_news);
#endif
checkUpdate()->setVisible(false);
recoverSpritesPlaceholder()->setVisible(false);
@ -128,7 +135,11 @@ void HomeView::onResize(ui::ResizeEvent& ev)
{
headerPlaceholder()->setVisible(ev.bounds().h > 200*ui::guiscale());
foldersPlaceholder()->setVisible(ev.bounds().h > 150*ui::guiscale());
#ifdef ENABLE_NEWS
newsPlaceholder()->setVisible(ev.bounds().w > 200*ui::guiscale());
#else
newsPlaceholder()->setVisible(false);
#endif
ui::VBox::onResize(ev);
}

View File

@ -42,7 +42,7 @@ if(NOT USE_SHARED_TINYXML)
add_subdirectory(tinyxml)
endif()
if(NOT USE_SHARED_CURL)
if(REQUIRE_CURL AND NOT USE_SHARED_CURL)
set(BUILD_RELEASE_DEBUG_DIRS ON BOOL)
set(CMAKE_USE_OPENSSL OFF CACHE BOOL "Use OpenSSL code. Experimental")
add_subdirectory(curl)