Skip to content

Commit 642bf7b

Browse files
committed
CMake: Don't split GUI code into several libraries
1 parent 4a2d25b commit 642bf7b

13 files changed

Lines changed: 438 additions & 507 deletions

File tree

CMakeLists.txt

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ cmake_minimum_required(VERSION 3.16 FATAL_ERROR)
22

33
message(AUTHOR_WARNING "If the build fails, please try the autotools/qmake method.")
44

5-
if(POLICY CMP0074)
5+
if (POLICY CMP0074)
66
cmake_policy(SET CMP0074 NEW)
77
endif()
88

@@ -45,9 +45,9 @@ set(requiredQtVersion 5.9.0)
4545
set(requiredOpensslVersion 1.0)
4646
set(requiredLibtorrentVersion 1.1.10)
4747

48-
if(WIN32)
48+
if (WIN32)
4949
include(winconf)
50-
endif(WIN32)
50+
endif()
5151

5252

5353
# we need options here, at the top level, because they are used not only in "src" subdir, but in the "dist" dir too

dist/CMakeLists.txt

Lines changed: 5 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -2,11 +2,8 @@ find_package(Qt5Widgets ${requiredQtVersion}) # to conditionally install desktop
22

33
if (APPLE)
44
add_subdirectory(mac)
5-
else (APPLE)
6-
if (UNIX)
7-
add_subdirectory(unix)
8-
endif (UNIX)
9-
if (WIN32)
10-
add_subdirectory(windows)
11-
endif (WIN32)
12-
endif (APPLE)
5+
elseif (UNIX)
6+
add_subdirectory(unix)
7+
elseif (WIN32)
8+
add_subdirectory(windows)
9+
endif()

src/CMakeLists.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ if (APPLE)
3737
# Workaround CMake bug (autogen does not pass required parameters to moc)
3838
# Relevant issue: https://gitlab.kitware.com/cmake/cmake/issues/18041
3939
list(APPEND CMAKE_AUTOMOC_MOC_OPTIONS -DQ_OS_MACOS -DQ_OS_DARWIN)
40-
endif ()
40+
endif()
4141

4242
include_directories(${CMAKE_CURRENT_SOURCE_DIR})
4343

src/app/CMakeLists.txt

Lines changed: 44 additions & 43 deletions
Original file line numberDiff line numberDiff line change
@@ -1,27 +1,24 @@
11
add_executable(qBittorrent
2-
# headers
3-
application.h
4-
applicationinstancemanager.h
5-
cmdoptions.h
6-
filelogger.h
7-
qtlocalpeer/qtlocalpeer.h
8-
upgrade.h
9-
10-
# sources
11-
application.cpp
12-
applicationinstancemanager.cpp
13-
cmdoptions.cpp
14-
filelogger.cpp
15-
main.cpp
16-
qtlocalpeer/qtlocalpeer.cpp
17-
upgrade.cpp
2+
# headers
3+
application.h
4+
applicationinstancemanager.h
5+
cmdoptions.h
6+
filelogger.h
7+
qtlocalpeer/qtlocalpeer.h
8+
upgrade.h
9+
10+
# sources
11+
application.cpp
12+
applicationinstancemanager.cpp
13+
cmdoptions.cpp
14+
filelogger.cpp
15+
main.cpp
16+
qtlocalpeer/qtlocalpeer.cpp
17+
upgrade.cpp
1818
)
1919

2020
target_include_directories(qBittorrent PRIVATE ${CMAKE_CURRENT_BINARY_DIR})
21-
target_link_libraries(qBittorrent
22-
PRIVATE
23-
qbt_base
24-
)
21+
target_link_libraries(qBittorrent PRIVATE qbt_base)
2522

2623
set_target_properties(qBittorrent
2724
PROPERTIES
@@ -42,8 +39,8 @@ if (NOT DISABLE_WEBUI)
4239
endif()
4340

4441
set(QBT_APP_RESOURCES
45-
../icons/icons.qrc
46-
../searchengine/searchengine.qrc
42+
../icons/icons.qrc
43+
../searchengine/searchengine.qrc
4744
)
4845

4946
# With AUTORCC rcc is ran by cmake before language files are generated,
@@ -53,49 +50,53 @@ qt5_add_resources(QBT_APP_RESOURCE_SOURCE ${QBT_APP_RESOURCES})
5350
if (WIN32)
5451
if (MINGW)
5552
target_sources(qBittorrent PRIVATE ../qbittorrent_mingw.rc)
56-
else (MINGW)
53+
else()
5754
target_sources(qBittorrent PRIVATE ../qbittorrent.rc)
58-
endif (MINGW)
55+
endif()
56+
5957
target_sources(qBittorrent PRIVATE ../qbittorrent.exe.manifest)
60-
endif (WIN32)
58+
endif()
6159

6260
if (STACKTRACE)
6361
if (UNIX)
6462
target_sources(qBittorrent PRIVATE stacktrace.h)
65-
else (UNIX)
63+
else()
6664
target_sources(qBittorrent PRIVATE stacktrace_win.h)
6765
if (Qt5Widgets_FOUND)
6866
target_sources(qBittorrent PRIVATE stacktracedialog.cpp stacktracedialog.h)
69-
endif (Qt5Widgets_FOUND)
67+
endif()
68+
7069
if (MSVC)
7170
if (NOT "${WINXXBITS}" STREQUAL "Win64")
7271
# i686 arch requires frame pointer preservation
7372
add_compile_options(-Oy-)
74-
endif (NOT "${WINXXBITS}" STREQUAL "Win64")
73+
endif()
74+
7575
add_compile_options(-Zi)
7676
target_link_libraries(qBittorrent PUBLIC dbghelp -DEBUG)
77-
else (MSVC)
77+
else()
7878
if (NOT "${WINXXBITS}" STREQUAL "Win64")
7979
add_compile_options(-fno-omit-frame-pointer)
80-
endif (NOT "${WINXXBITS}" STREQUAL "Win64")
80+
endif()
81+
8182
target_link_libraries(qBittorrent PUBLIC dbghelp -Wl,--export-all-symbols)
82-
endif (MSVC)
83-
endif (UNIX)
84-
endif (STACKTRACE)
83+
endif()
84+
endif()
85+
endif()
8586

8687
if (Qt5Widgets_FOUND)
87-
target_link_libraries(qBittorrent PRIVATE qbt_searchengine qbt_gui)
88+
target_link_libraries(qBittorrent PRIVATE qbt_gui)
8889
set_target_properties(qBittorrent
8990
PROPERTIES
9091
OUTPUT_NAME qbittorrent
9192
WIN32_EXECUTABLE True
9293
)
93-
else(Qt5Widgets_FOUND)
94+
else()
9495
set_target_properties(qBittorrent
9596
PROPERTIES
9697
OUTPUT_NAME qbittorrent-nox
9798
)
98-
endif (Qt5Widgets_FOUND)
99+
endif()
99100

100101
if (NOT DISABLE_WEBUI)
101102
target_link_libraries(qBittorrent PRIVATE qbt_webui)
@@ -127,9 +128,8 @@ if (APPLE)
127128
${QT_TR_DIR}/qt_zh_CN.qm
128129
)
129130
list(APPEND QBT_APP_RESOURCE_SOURCE ${QT_TRANSLATIONS})
130-
set_source_files_properties(${QT_TRANSLATIONS}
131-
PROPERTIES MACOSX_PACKAGE_LOCATION translations)
132-
endif (APPLE)
131+
set_source_files_properties(${QT_TRANSLATIONS} PROPERTIES MACOSX_PACKAGE_LOCATION translations)
132+
endif()
133133

134134
target_sources(qBittorrent PRIVATE ${QBT_QM_FILES} ${QBT_APP_RESOURCE_SOURCE})
135135

@@ -138,23 +138,24 @@ get_target_property(QBT_EXECUTABLE_NAME qBittorrent OUTPUT_NAME)
138138
if (APPLE)
139139
set(qbt_BUNDLE_NAME ${QBT_EXECUTABLE_NAME})
140140

141-
# substitute @EXECUTABLE@ in dist/mac/Info.plist
141+
# substitute @EXECUTABLE@ in dist/mac/Info.plist
142142
set(EXECUTABLE ${qbt_BUNDLE_NAME})
143143
configure_file(${qBittorrent_SOURCE_DIR}/dist/mac/Info.plist ${qBittorrent_BINARY_DIR}/dist/mac/Info.plist @ONLY)
144144

145145
set_target_properties(qBittorrent PROPERTIES
146146
MACOSX_BUNDLE_BUNDLE_NAME "${qbt_BUNDLE_NAME}"
147147
MACOSX_BUNDLE_INFO_PLIST ${qBittorrent_BINARY_DIR}/dist/mac/Info.plist
148148
)
149-
endif (APPLE)
149+
endif()
150150

151151
# installation
152152
install(TARGETS qBittorrent
153153
RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR}
154154
BUNDLE DESTINATION .
155-
COMPONENT runtime)
155+
COMPONENT runtime
156+
)
156157

157158
if (Qt5Widgets_FOUND AND APPLE)
158159
find_package(Qt5Svg REQUIRED)
159160
include(bundle)
160-
endif (Qt5Widgets_FOUND AND APPLE)
161+
endif()

0 commit comments

Comments
 (0)