|
1 | | -cmake_minimum_required(VERSION 3.17.2) |
2 | | -project(tf2_bot_detector VERSION 1.1.0.10) |
| 1 | +cmake_minimum_required(VERSION 3.17) |
3 | 2 |
|
4 | | -include(GenerateExportHeader) |
5 | | - |
6 | | -message("TF2BD CMAKE_BUILD_TYPE = ${CMAKE_BUILD_TYPE}") |
7 | | - |
8 | | -option(TF2BD_IS_CI_COMPILE "Set to true if this is a compile on a CI service. Used to help determine if user has made modifications to the source code." off) |
9 | | -if (TF2BD_IS_CI_COMPILE) |
10 | | - add_compile_definitions(TF2BD_IS_CI_COMPILE=1) |
11 | | -else() |
12 | | - add_compile_definitions(TF2BD_IS_CI_COMPILE=0) |
13 | | -endif() |
| 3 | +option(TF2BD_ENABLE_DISCORD_INTEGRATION "Enable discord integration" on) |
| 4 | +option(TF2BD_ENABLE_TESTS "Enable test compilation" off) |
14 | 5 |
|
15 | | -# Generate PDBs for release builds - RelWithDebInfo is NOT a Release build! |
16 | | -if (MSVC) |
17 | | - set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} /MP") |
18 | | - set(CMAKE_CXX_FLAGS_RELEASE "${CMAKE_CXX_FLAGS_RELEASE} /Zi") |
19 | | - set(CMAKE_SHARED_LINKER_FLAGS_RELEASE "${CMAKE_SHARED_LINKER_FLAGS_RELEASE} /DEBUG") |
20 | | - set(CMAKE_EXE_LINKER_FLAGS_RELEASE "${CMAKE_EXE_LINKER_FLAGS_RELEASE} /DEBUG") |
21 | | -endif() |
| 6 | +include(cmake/init-preproject.cmake) |
| 7 | + project(tf2_bot_detector) |
| 8 | +include(cmake/init-postproject.cmake) |
22 | 9 |
|
23 | | -set_property(GLOBAL PROPERTY INTERPROCEDURAL_OPTIMIZATION_RELEASE true) |
24 | | -if (MSVC AND (CMAKE_BUILD_TYPE MATCHES "Release")) |
25 | | - add_link_options(/OPT:REF /OPT:ICF) |
26 | | -endif() |
| 10 | +set_warning_level(1) |
| 11 | +set(ENABLE_EXAMPLES off CACHE BOOL "Build examples" FORCE) |
| 12 | +add_subdirectory("submodules/cppcoro") |
27 | 13 |
|
| 14 | +set_warning_level(3) |
28 | 15 | add_subdirectory(submodules/ValveFileVDF) |
29 | 16 | add_subdirectory(submodules/SourceRCON) |
30 | 17 | add_subdirectory(submodules/imgui_desktop) |
31 | 18 | add_subdirectory(submodules/mh_stuff) |
32 | 19 |
|
33 | | -set(ENABLE_EXAMPLES off CACHE BOOL "Build examples" FORCE) |
34 | | -add_subdirectory("submodules/cppcoro") |
35 | | - |
36 | | -if (WIN32) |
37 | | - add_library(tf2_bot_detector SHARED) |
38 | | - set_target_properties(tf2_bot_detector PROPERTIES PDB_NAME "tf2_bot_detector_dll") |
39 | | - |
40 | | - generate_export_header(tf2_bot_detector |
41 | | - EXPORT_FILE_NAME "tf2_bot_detector/tf2_bot_detector_export.h" |
42 | | - ) |
43 | | - |
44 | | - add_executable(tf2_bot_detector_launcher WIN32 |
45 | | - "tf2_bot_detector/Platform/Windows/CrashHandler.cpp" |
46 | | - "tf2_bot_detector/Launcher/main.cpp" |
47 | | - "tf2_bot_detector/Launcher/Resources.rc" |
48 | | - ) |
49 | | - target_compile_definitions(tf2_bot_detector_launcher PRIVATE TF2BD_LAUNCHER_USE_WINMAIN) |
50 | | - |
51 | | - target_include_directories(tf2_bot_detector_launcher PRIVATE ${CMAKE_CURRENT_BINARY_DIR}/tf2_bot_detector) |
52 | | - target_link_libraries(tf2_bot_detector_launcher PRIVATE tf2_bot_detector) |
53 | | - set_target_properties(tf2_bot_detector_launcher PROPERTIES OUTPUT_NAME "tf2_bot_detector") |
54 | | - set_property(TARGET tf2_bot_detector_launcher PROPERTY CXX_STANDARD 17) |
55 | | -else() |
56 | | - add_executable(tf2_bot_detector |
57 | | - "tf2_bot_detector/Launcher/main.cpp" |
58 | | - ) |
59 | | -endif() |
60 | | - |
61 | | -target_sources(tf2_bot_detector PRIVATE |
62 | | - "tf2_bot_detector/Actions/RCONActionManager.cpp" |
63 | | - "tf2_bot_detector/Actions/RCONActionManager.h" |
64 | | - "tf2_bot_detector/Actions/ActionGenerators.cpp" |
65 | | - "tf2_bot_detector/Actions/ActionGenerators.h" |
66 | | - "tf2_bot_detector/Actions/Actions.cpp" |
67 | | - "tf2_bot_detector/Actions/Actions.h" |
68 | | - "tf2_bot_detector/Actions/HijackActionManager.h" |
69 | | - "tf2_bot_detector/Actions/HijackActionManager.cpp" |
70 | | - "tf2_bot_detector/Actions/IActionManager.h" |
71 | | - "tf2_bot_detector/Actions/ICommandSource.h" |
72 | | - "tf2_bot_detector/Config/ConfigHelpers.cpp" |
73 | | - "tf2_bot_detector/Config/ConfigHelpers.h" |
74 | | - "tf2_bot_detector/Config/DRPInfo.cpp" |
75 | | - "tf2_bot_detector/Config/DRPInfo.h" |
76 | | - "tf2_bot_detector/Config/PlayerListJSON.cpp" |
77 | | - "tf2_bot_detector/Config/PlayerListJSON.h" |
78 | | - "tf2_bot_detector/Config/Rules.cpp" |
79 | | - "tf2_bot_detector/Config/Rules.h" |
80 | | - "tf2_bot_detector/Config/Settings.cpp" |
81 | | - "tf2_bot_detector/Config/Settings.h" |
82 | | - "tf2_bot_detector/Config/SponsorsList.h" |
83 | | - "tf2_bot_detector/Config/SponsorsList.cpp" |
84 | | - "tf2_bot_detector/ConsoleLog/ConsoleLogParser.h" |
85 | | - "tf2_bot_detector/ConsoleLog/ConsoleLogParser.cpp" |
86 | | - "tf2_bot_detector/ConsoleLog/ConsoleLines.cpp" |
87 | | - "tf2_bot_detector/ConsoleLog/ConsoleLines.h" |
88 | | - "tf2_bot_detector/ConsoleLog/IConsoleLine.h" |
89 | | - "tf2_bot_detector/ConsoleLog/ConsoleLineListener.cpp" |
90 | | - "tf2_bot_detector/ConsoleLog/ConsoleLineListener.h" |
91 | | - "tf2_bot_detector/ConsoleLog/NetworkStatus.cpp" |
92 | | - "tf2_bot_detector/ConsoleLog/NetworkStatus.h" |
93 | | - "tf2_bot_detector/GameData/MatchmakingQueue.h" |
94 | | - "tf2_bot_detector/GameData/TFClassType.h" |
95 | | - "tf2_bot_detector/GameData/TFParty.h" |
96 | | - "tf2_bot_detector/GameData/UserMessageType.h" |
97 | | - "tf2_bot_detector/Networking/GithubAPI.h" |
98 | | - "tf2_bot_detector/Networking/GithubAPI.cpp" |
99 | | - "tf2_bot_detector/Networking/HTTPClient.h" |
100 | | - "tf2_bot_detector/Networking/HTTPClient.cpp" |
101 | | - "tf2_bot_detector/Networking/HTTPHelpers.h" |
102 | | - "tf2_bot_detector/Networking/HTTPHelpers.cpp" |
103 | | - "tf2_bot_detector/Networking/NetworkHelpers.h" |
104 | | - "tf2_bot_detector/Networking/NetworkHelpers.cpp" |
105 | | - "tf2_bot_detector/Networking/SteamAPI.h" |
106 | | - "tf2_bot_detector/Networking/SteamAPI.cpp" |
107 | | - "tf2_bot_detector/Platform/Platform.h" |
108 | | - "tf2_bot_detector/SetupFlow/BasicSettingsPage.h" |
109 | | - "tf2_bot_detector/SetupFlow/BasicSettingsPage.cpp" |
110 | | - "tf2_bot_detector/SetupFlow/ChatWrappersGeneratorPage.h" |
111 | | - "tf2_bot_detector/SetupFlow/ChatWrappersGeneratorPage.cpp" |
112 | | - "tf2_bot_detector/SetupFlow/ChatWrappersVerifyPage.h" |
113 | | - "tf2_bot_detector/SetupFlow/ChatWrappersVerifyPage.cpp" |
114 | | - "tf2_bot_detector/SetupFlow/ISetupFlowPage.h" |
115 | | - "tf2_bot_detector/SetupFlow/NetworkSettingsPage.h" |
116 | | - "tf2_bot_detector/SetupFlow/NetworkSettingsPage.cpp" |
117 | | - "tf2_bot_detector/SetupFlow/SetupFlow.cpp" |
118 | | - "tf2_bot_detector/SetupFlow/SetupFlow.h" |
119 | | - "tf2_bot_detector/SetupFlow/TF2CommandLinePage.h" |
120 | | - "tf2_bot_detector/SetupFlow/TF2CommandLinePage.cpp" |
121 | | - "tf2_bot_detector/UI/ImGui_TF2BotDetector.cpp" |
122 | | - "tf2_bot_detector/UI/ImGui_TF2BotDetector.h" |
123 | | - "tf2_bot_detector/UI/MainWindow.cpp" |
124 | | - "tf2_bot_detector/UI/MainWindow.Scoreboard.cpp" |
125 | | - "tf2_bot_detector/UI/MainWindow.h" |
126 | | - "tf2_bot_detector/Util/JSONUtils.h" |
127 | | - "tf2_bot_detector/Util/PathUtils.cpp" |
128 | | - "tf2_bot_detector/Util/PathUtils.h" |
129 | | - "tf2_bot_detector/Util/TextUtils.cpp" |
130 | | - "tf2_bot_detector/Util/TextUtils.h" |
131 | | - "tf2_bot_detector/BaseTextures.h" |
132 | | - "tf2_bot_detector/BaseTextures.cpp" |
133 | | - "tf2_bot_detector/BatchedAction.h" |
134 | | - "tf2_bot_detector/Bitmap.h" |
135 | | - "tf2_bot_detector/Bitmap.cpp" |
136 | | - "tf2_bot_detector/Clock.cpp" |
137 | | - "tf2_bot_detector/Clock.h" |
138 | | - "tf2_bot_detector/CompensatedTS.cpp" |
139 | | - "tf2_bot_detector/CompensatedTS.h" |
140 | | - "tf2_bot_detector/Config/ChatWrappers.cpp" |
141 | | - "tf2_bot_detector/Config/ChatWrappers.h" |
142 | | - "tf2_bot_detector/DLLMain.cpp" |
143 | | - "tf2_bot_detector/DLLMain.h" |
144 | | - "tf2_bot_detector/IPlayer.cpp" |
145 | | - "tf2_bot_detector/IPlayer.h" |
146 | | - "tf2_bot_detector/Log.cpp" |
147 | | - "tf2_bot_detector/Log.h" |
148 | | - "tf2_bot_detector/ModeratorLogic.cpp" |
149 | | - "tf2_bot_detector/ModeratorLogic.h" |
150 | | - "tf2_bot_detector/PlayerStatus.h" |
151 | | - "tf2_bot_detector/SteamID.cpp" |
152 | | - "tf2_bot_detector/SteamID.h" |
153 | | - "tf2_bot_detector/TextureManager.h" |
154 | | - "tf2_bot_detector/TextureManager.cpp" |
155 | | - "tf2_bot_detector/TFConstants.h" |
156 | | - "tf2_bot_detector/Version.h" |
157 | | - "tf2_bot_detector/WorldEventListener.cpp" |
158 | | - "tf2_bot_detector/WorldEventListener.h" |
159 | | - "tf2_bot_detector/WorldState.cpp" |
160 | | - "tf2_bot_detector/WorldState.h" |
161 | | -) |
162 | | - |
163 | | -configure_file(tf2_bot_detector/Version.base.h tf2_bot_detector/Version.h) |
164 | | -target_include_directories(tf2_bot_detector PRIVATE ${CMAKE_CURRENT_BINARY_DIR}/tf2_bot_detector) |
165 | | - |
166 | | -if(WIN32) |
167 | | - if ((CMAKE_BUILD_TYPE MATCHES "Release")) |
168 | | - set(TF2BD_RESOURCE_FILEFLAGS "0") |
169 | | - else() |
170 | | - set(TF2BD_RESOURCE_FILEFLAGS "VS_FF_DEBUG") |
171 | | - endif() |
172 | | - configure_file(tf2_bot_detector/Resources.base.rc tf2_bot_detector/Resources.rc) |
173 | | - |
174 | | - target_sources(tf2_bot_detector PRIVATE |
175 | | - "tf2_bot_detector/Platform/Windows/Processes.cpp" |
176 | | - "tf2_bot_detector/Platform/Windows/Shell.cpp" |
177 | | - "tf2_bot_detector/Platform/Windows/Steam.cpp" |
178 | | - "tf2_bot_detector/Platform/Windows/WindowsHelpers.h" |
179 | | - "tf2_bot_detector/Resources.rc" |
180 | | - ) |
181 | | -endif() |
182 | | - |
183 | | -target_include_directories(tf2_bot_detector |
184 | | - PRIVATE tf2_bot_detector |
185 | | -) |
186 | | -target_compile_definitions(tf2_bot_detector PRIVATE WIN32_LEAN_AND_MEAN) |
187 | | - |
188 | | -option(TF2BD_ENABLE_DISCORD_INTEGRATION "Enable discord integration" on) |
189 | | -if (TF2BD_ENABLE_DISCORD_INTEGRATION) |
190 | | - target_compile_definitions(tf2_bot_detector PRIVATE TF2BD_ENABLE_DISCORD_INTEGRATION) |
191 | | - find_library(DISCORD_GAME_SDK discord_game_sdk) |
192 | | - message("DISCORD_GAME_SDK = ${DISCORD_GAME_SDK}") |
193 | | - target_link_libraries(tf2_bot_detector PRIVATE ${DISCORD_GAME_SDK}) |
194 | | - |
195 | | - find_path(GAME_SDK_INCLUDE discord-game-sdk/discord.h) |
196 | | - target_include_directories(tf2_bot_detector PRIVATE ${DISCORD_GAME_SDK_INCLUDE}) |
197 | | - |
198 | | - find_library(DISCORD_CPP_GAME_SDK discord_game_sdk_cpp) |
199 | | - message("DISCORD_CPP_GAME_SDK = ${DISCORD_CPP_GAME_SDK}") |
200 | | - target_link_libraries(tf2_bot_detector PRIVATE ${DISCORD_CPP_GAME_SDK}) |
201 | | - |
202 | | - target_sources(tf2_bot_detector PRIVATE |
203 | | - "tf2_bot_detector/DiscordRichPresence.cpp" |
204 | | - "tf2_bot_detector/DiscordRichPresence.h" |
205 | | - ) |
206 | | -endif() |
207 | | - |
208 | | -find_package(OpenSSL REQUIRED) |
209 | | -target_link_libraries(tf2_bot_detector) |
210 | | - |
211 | | -find_path(HTTPLIB_PATH NAMES httplib.h) |
212 | | -target_include_directories(tf2_bot_detector PRIVATE ${HTTPLIB_PATH}) |
213 | | - |
214 | | -find_package(nlohmann_json CONFIG REQUIRED) |
215 | | -find_package(libzippp CONFIG REQUIRED) |
216 | | -find_package(fmt CONFIG REQUIRED) |
217 | | - |
218 | | -target_link_libraries(tf2_bot_detector PRIVATE |
219 | | - imgui_desktop |
220 | | - mh_stuff |
221 | | - ValveFileVDF |
222 | | - libzip::libzip |
223 | | - libzippp::libzippp |
224 | | - cppcoro |
225 | | - SourceRCON |
226 | | - OpenSSL::SSL # cpp-httplib requires openssl |
227 | | - nlohmann_json::nlohmann_json |
228 | | - fmt::fmt |
229 | | -) |
230 | | - |
231 | | -option(TF2BD_ENABLE_TESTS "Enable test compilation" off) |
232 | | -if (TF2BD_ENABLE_TESTS) |
233 | | - enable_testing() |
234 | | - |
235 | | - find_package(Catch2 CONFIG REQUIRED) |
236 | | - target_link_libraries(tf2_bot_detector PRIVATE Catch2::Catch2) |
237 | | - target_compile_definitions(tf2_bot_detector PRIVATE TF2BD_ENABLE_TESTS) |
238 | | - target_sources(tf2_bot_detector PRIVATE |
239 | | - "tf2_bot_detector/Tests/Catch2.cpp" |
240 | | - "tf2_bot_detector/Tests/ConsoleLineTests.cpp" |
241 | | - "tf2_bot_detector/Tests/Tests.h" |
242 | | - ) |
243 | | - |
244 | | - SET(TF2BD_ENABLE_CLI_EXE true) |
245 | | - |
246 | | - add_test(NAME TF2BD_Tests COMMAND tf2_bot_detector_cli --run-tests |
247 | | - WORKING_DIRECTORY staging |
248 | | - ) |
249 | | -endif() |
250 | | - |
251 | | -if(TF2BD_ENABLE_CLI_EXE) |
252 | | - add_executable(tf2_bot_detector_cli "tf2_bot_detector/Launcher/main.cpp") |
253 | | - target_include_directories(tf2_bot_detector_cli PRIVATE ${CMAKE_CURRENT_BINARY_DIR}/tf2_bot_detector) |
254 | | - target_link_libraries(tf2_bot_detector_cli PRIVATE tf2_bot_detector) |
255 | | - set_property(TARGET tf2_bot_detector_cli PROPERTY CXX_STANDARD 17) |
256 | | -endif() |
257 | | - |
258 | | -# TODO: Find a way to do this locally |
259 | | -if(MSVC) |
260 | | - target_compile_options(tf2_bot_detector PRIVATE /WX) |
261 | | -endif() |
262 | | - |
263 | | -set_property(TARGET tf2_bot_detector PROPERTY CXX_STANDARD 20) |
264 | | -if (MSVC) |
265 | | - add_definitions(/await) |
266 | | -endif() |
267 | | - |
268 | | -set_target_properties(tf2_bot_detector PROPERTIES |
269 | | - VS_DEBUGGER_WORKING_DIRECTORY "${CMAKE_SOURCE_DIR}/staging" |
270 | | -) |
| 20 | +add_subdirectory(tf2_bot_detector_common) |
| 21 | +# add_subdirectory(tf2_bot_detector_updater) |
| 22 | +add_subdirectory(tf2_bot_detector) |
271 | 23 |
|
272 | | -# "installation" aka create a build we can upload to github as a release |
273 | | -if (WIN32) |
274 | | - file(GLOB TF2BD_INSTALL_DEPS_DLL LIST_DIRECTORIES false "${CMAKE_BINARY_DIR}/*.dll") |
275 | | - install(FILES ${TF2BD_INSTALL_DEPS_DLL} DESTINATION /) |
276 | | -endif() |
277 | | -install(DIRECTORY staging/ staging/ DESTINATION "/" FILES_MATCHING |
278 | | - PATTERN "*" |
279 | | - PATTERN "staging/cfg/settings.json" EXCLUDE |
280 | | - PATTERN "staging/logs" EXCLUDE |
281 | | -) |
282 | | -install(TARGETS tf2_bot_detector DESTINATION /) |
0 commit comments