Skip to content

Commit ad0ee0c

Browse files
committed
CMake: Enable/disable GUI application via option
1 parent fb42434 commit ad0ee0c

4 files changed

Lines changed: 9 additions & 13 deletions

File tree

.travis.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -94,7 +94,7 @@ before_install:
9494
- |
9595
if [ "$gui" = "false" ]; then
9696
qmake_conf="$qmake_conf --disable-gui"
97-
cmake_conf="$cmake_conf -DCMAKE_DISABLE_FIND_PACKAGE_Qt5Widgets=ON"
97+
cmake_conf="$cmake_conf -DGUI=OFF"
9898
fi
9999
100100
# print settings

CMakeLists.txt

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -57,6 +57,8 @@ optional_compile_definitions(COUNTRIES_RESOLUTION FEATURE DESCRIPTION "Enable re
5757
DEFAULT ON DISABLED DISABLE_COUNTRIES_RESOLUTION)
5858
optional_compile_definitions(STACKTRACE FEATURE DESCRIPTION "Enable stacktraces"
5959
DEFAULT ON ENABLED STACKTRACE)
60+
optional_compile_definitions(GUI FEATURE DESCRIPTION "Build GUI application"
61+
DEFAULT ON DISABLED DISABLE_GUI)
6062
optional_compile_definitions(WEBUI FEATURE DESCRIPTION "Enables built-in HTTP server for headless use"
6163
DEFAULT ON DISABLED DISABLE_WEBUI)
6264

src/CMakeLists.txt

Lines changed: 3 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -12,19 +12,13 @@ if (Boost_VERSION VERSION_LESS 106000)
1212
endif()
1313

1414
find_package(Qt5 ${requiredQtVersion} REQUIRED COMPONENTS Core Network Xml LinguistTools)
15-
find_package(Qt5Widgets ${requiredQtVersion})
16-
if (Qt5Widgets_FOUND)
15+
if (NOT DISABLE_GUI)
16+
find_package(Qt5Widgets ${requiredQtVersion} REQUIRED)
1717
find_package(Qt5DBus ${requiredQtVersion})
1818
else()
1919
add_definitions(-DDISABLE_GUI)
2020
endif()
2121

22-
set_package_properties(Qt5Widgets PROPERTIES
23-
DESCRIPTION "Set of components for creating classic desktop-style UIs for the Qt5 framework"
24-
PURPOSE "Enables qBittorrent GUI. Unneeded for headless configuration."
25-
TYPE OPTIONAL
26-
)
27-
2822
set_package_properties(Qt5DBus PROPERTIES
2923
DESCRIPTION "Qt5 module for inter-process communication over the D-Bus protocol"
3024
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)
6054
add_subdirectory(app)
6155
add_subdirectory(base)
6256

63-
if (Qt5Widgets_FOUND)
57+
if (NOT DISABLE_GUI)
6458
add_subdirectory(gui)
6559
endif ()
6660

src/app/CMakeLists.txt

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,7 @@ if (STACKTRACE)
6363
target_sources(qBittorrent PRIVATE stacktrace.h)
6464
else()
6565
target_sources(qBittorrent PRIVATE stacktrace_win.h)
66-
if (Qt5Widgets_FOUND)
66+
if (NOT DISABLE_GUI)
6767
target_sources(qBittorrent PRIVATE stacktracedialog.cpp stacktracedialog.h)
6868
endif()
6969

@@ -85,7 +85,7 @@ if (STACKTRACE)
8585
endif()
8686
endif()
8787

88-
if (Qt5Widgets_FOUND)
88+
if (NOT DISABLE_GUI)
8989
target_link_libraries(qBittorrent PRIVATE qbt_gui)
9090
set_target_properties(qBittorrent
9191
PROPERTIES
@@ -156,7 +156,7 @@ install(TARGETS qBittorrent
156156
COMPONENT runtime
157157
)
158158

159-
if (Qt5Widgets_FOUND AND APPLE)
159+
if (NOT DISABLE_GUI AND APPLE)
160160
find_package(Qt5Svg REQUIRED)
161161
include(bundle)
162162
endif()

0 commit comments

Comments
 (0)