CMake: Enable/disable GUI application via option

This commit is contained in:
Vladimir Golovnev (Glassez) 2020-04-30 16:37:07 +03:00
parent fb42434946
commit ad0ee0cd36
No known key found for this signature in database
GPG key ID: 52A2C7DEE2DFA6F7
4 changed files with 9 additions and 13 deletions

View file

@ -94,7 +94,7 @@ before_install:
- | - |
if [ "$gui" = "false" ]; then if [ "$gui" = "false" ]; then
qmake_conf="$qmake_conf --disable-gui" qmake_conf="$qmake_conf --disable-gui"
cmake_conf="$cmake_conf -DCMAKE_DISABLE_FIND_PACKAGE_Qt5Widgets=ON" cmake_conf="$cmake_conf -DGUI=OFF"
fi fi
# print settings # print settings

View file

@ -57,6 +57,8 @@ optional_compile_definitions(COUNTRIES_RESOLUTION FEATURE DESCRIPTION "Enable re
DEFAULT ON DISABLED DISABLE_COUNTRIES_RESOLUTION) DEFAULT ON DISABLED DISABLE_COUNTRIES_RESOLUTION)
optional_compile_definitions(STACKTRACE FEATURE DESCRIPTION "Enable stacktraces" optional_compile_definitions(STACKTRACE FEATURE DESCRIPTION "Enable stacktraces"
DEFAULT ON ENABLED STACKTRACE) DEFAULT ON ENABLED STACKTRACE)
optional_compile_definitions(GUI FEATURE DESCRIPTION "Build GUI application"
DEFAULT ON DISABLED DISABLE_GUI)
optional_compile_definitions(WEBUI FEATURE DESCRIPTION "Enables built-in HTTP server for headless use" optional_compile_definitions(WEBUI FEATURE DESCRIPTION "Enables built-in HTTP server for headless use"
DEFAULT ON DISABLED DISABLE_WEBUI) DEFAULT ON DISABLED DISABLE_WEBUI)

View file

@ -12,19 +12,13 @@ if (Boost_VERSION VERSION_LESS 106000)
endif() endif()
find_package(Qt5 ${requiredQtVersion} REQUIRED COMPONENTS Core Network Xml LinguistTools) find_package(Qt5 ${requiredQtVersion} REQUIRED COMPONENTS Core Network Xml LinguistTools)
find_package(Qt5Widgets ${requiredQtVersion}) if (NOT DISABLE_GUI)
if (Qt5Widgets_FOUND) find_package(Qt5Widgets ${requiredQtVersion} REQUIRED)
find_package(Qt5DBus ${requiredQtVersion}) find_package(Qt5DBus ${requiredQtVersion})
else() else()
add_definitions(-DDISABLE_GUI) add_definitions(-DDISABLE_GUI)
endif() endif()
set_package_properties(Qt5Widgets PROPERTIES
DESCRIPTION "Set of components for creating classic desktop-style UIs for the Qt5 framework"
PURPOSE "Enables qBittorrent GUI. Unneeded for headless configuration."
TYPE OPTIONAL
)
set_package_properties(Qt5DBus PROPERTIES set_package_properties(Qt5DBus PROPERTIES
DESCRIPTION "Qt5 module for inter-process communication over the D-Bus protocol" DESCRIPTION "Qt5 module for inter-process communication over the D-Bus protocol"
PURPOSE "Enables communication with other system components (e.g. notification service) via D-Bus. " PURPOSE "Enables communication with other system components (e.g. notification service) via D-Bus. "
@ -60,7 +54,7 @@ configure_file(config.h.cmakein ${CMAKE_CURRENT_BINARY_DIR}/config.h)
add_subdirectory(app) add_subdirectory(app)
add_subdirectory(base) add_subdirectory(base)
if (Qt5Widgets_FOUND) if (NOT DISABLE_GUI)
add_subdirectory(gui) add_subdirectory(gui)
endif () endif ()

View file

@ -63,7 +63,7 @@ if (STACKTRACE)
target_sources(qBittorrent PRIVATE stacktrace.h) target_sources(qBittorrent PRIVATE stacktrace.h)
else() else()
target_sources(qBittorrent PRIVATE stacktrace_win.h) target_sources(qBittorrent PRIVATE stacktrace_win.h)
if (Qt5Widgets_FOUND) if (NOT DISABLE_GUI)
target_sources(qBittorrent PRIVATE stacktracedialog.cpp stacktracedialog.h) target_sources(qBittorrent PRIVATE stacktracedialog.cpp stacktracedialog.h)
endif() endif()
@ -85,7 +85,7 @@ if (STACKTRACE)
endif() endif()
endif() endif()
if (Qt5Widgets_FOUND) if (NOT DISABLE_GUI)
target_link_libraries(qBittorrent PRIVATE qbt_gui) target_link_libraries(qBittorrent PRIVATE qbt_gui)
set_target_properties(qBittorrent set_target_properties(qBittorrent
PROPERTIES PROPERTIES
@ -156,7 +156,7 @@ install(TARGETS qBittorrent
COMPONENT runtime COMPONENT runtime
) )
if (Qt5Widgets_FOUND AND APPLE) if (NOT DISABLE_GUI AND APPLE)
find_package(Qt5Svg REQUIRED) find_package(Qt5Svg REQUIRED)
include(bundle) include(bundle)
endif() endif()