forked from testpushpleaseignore/acquisition
-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathCMakeLists.txt
408 lines (357 loc) · 13.2 KB
/
CMakeLists.txt
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
#[[
Copyright (C) 2014-2024 Acquisition Contributors
This file is part of Acquisition.
Acquisition is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
Acquisition is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with Acquisition. If not, see <http://www.gnu.org/licenses/>.
#]]
cmake_minimum_required(VERSION 3.29)
# NOTE: For automatic update detection to work, the 'app_version' variable
# defined below should match a tag in github. Historically, the github tags
# have been identical to the 'app_version' as defined below, except the
# tags on github are prefixed with a 'v'.
#
# The version code that used to be used for update detection is no longer
# needed, except that some users with version of acquisition prior to
# version 0.10.5 will still need it, so we can't outright get rid of it.
project(acquisition
VERSION 0.12.3
DESCRIPTION "Stash and forum shop management for Path of Exile (TM)"
HOMEPAGE_URL "https://github.com/gerwaric/acquisition"
LANGUAGES CXX
)
# Use this to define pre-releases
set(version_postfix "-beta.1")
# Variables used to generate version_defines.h and installer.iss
set(version_code 63) # This doesn't need to be changed with the new update checks.
set(app_name "${CMAKE_PROJECT_NAME}")
set(app_version "${CMAKE_PROJECT_VERSION}")
set(app_version_string "${CMAKE_PROJECT_VERSION}${version_postfix}")
set(app_url "${CMAKE_PROJECT_HOMEPAGE_URL}")
set(app_publisher "GERWARIC")
set(app_publisher_email "gerwaric@gmail.com")
set(app_copyright "Copyright (C) 2014-2024 Ilya Zhuravlev and other Acquisition Contributors")
set(app_trademark "Path of Exile is a trademark of Grinding Gear Games, Ltd.")
set(CMAKE_AUTOUIC ON)
set(CMAKE_AUTOMOC ON)
set(CMAKE_AUTORCC ON)
set(CMAKE_CXX_STANDARD 17)
set(CMAKE_CXX_STANDARD_REQUIRED ON)
# When building with Qt Creator in Windows, the compiler and linker options
# need to be set before qt_add_executable(), otherwise these options won't be used.
# (This is apparently not an issue with Visual Studio 2022).
if(WIN32)
# Enable more warnings by default
add_compile_options(/W4)
add_compile_options(/EHsc)
# There was a change to mutex constructors at some point
# that was causing random crashes, which can be avoided
# with this preprocessor flag.
add_compile_options(/D_DISABLE_CONSTEXPR_MUTEX_CONSTRUCTOR)
# Create .pdb files for debugging
add_compile_options("$<$<NOT:$<CONFIG:Debug>>:/Zi>")
add_link_options("$<$<NOT:$<CONFIG:Debug>>:/DEBUG>")
add_link_options("$<$<NOT:$<CONFIG:Debug>>:/OPT:REF>")
add_link_options("$<$<NOT:$<CONFIG:Debug>>:/OPT:ICF>")
endif()
find_package(Qt6 REQUIRED COMPONENTS Core Gui HttpServer Network Sql Test WebSockets Widgets)
qt_standard_project_setup(REQUIRES 6.8.0)
qt_add_executable(acquisition WIN32 MACOSX_BUNDLE
# Source
src/application.cpp
src/bucket.cpp
src/buyout.cpp
src/buyoutmanager.cpp
src/column.cpp
src/currency.cpp
src/currencymanager.cpp
src/datastore/datastore.cpp
src/datastore/memorydatastore.cpp
src/datastore/sqlitedatastore.cpp
src/filters.cpp
src/imagecache.cpp
src/influence.cpp
src/item.cpp
src/itemcategories.cpp
src/itemconstants.cpp
src/itemlocation.cpp
src/items_model.cpp
src/itemsmanager.cpp
src/itemsmanagerworker.cpp
src/legacy/legacybuyoutvalidator.cpp
src/legacy/legacydatastore.cpp
src/legacy/legacyitem.cpp
src/main.cpp
src/modlist.cpp
src/modsfilter.cpp
src/ratelimit/ratelimit.cpp
src/ratelimit/ratelimitdialog.cpp
src/ratelimit/ratelimitedrequest.cpp
src/ratelimit/ratelimiter.cpp
src/ratelimit/ratelimitmanager.cpp
src/ratelimit/ratelimitpolicy.cpp
src/search.cpp
src/shop.cpp
src/ui/flowlayout.cpp
src/ui/itemtooltip.cpp
src/ui/logindialog.cpp
src/ui/logpanel.cpp
src/ui/mainwindow.cpp
src/ui/searchcombobox.cpp
src/ui/verticalscrollarea.cpp
src/util/crashpad.cpp
src/util/fatalerror.cpp
src/util/networkmanager.cpp
src/util/oauthmanager.cpp
src/util/oauthtoken.cpp
src/util/repoe.cpp
src/util/updatechecker.cpp
src/util/util.cpp
test/testdata.cpp
test/testitem.cpp
test/testitemsmanager.cpp
test/testmain.cpp
test/testshop.cpp
test/testutil.cpp
# Headers
src/application.h
src/bucket.h
src/buyout.h
src/buyoutmanager.h
src/column.h
src/currency.h
src/currencymanager.h
src/datastore/datastore.h
src/datastore/memorydatastore.h
src/datastore/sqlitedatastore.h
src/filters.h
src/imagecache.h
src/influence.h
src/item.h
src/itemcategories.h
src/itemconstants.h
src/itemlocation.h
src/items_model.h
src/itemsmanager.h
src/itemsmanagerworker.h
src/legacy/legacybuyout.h
src/legacy/legacybuyoutvalidator.h
src/legacy/legacycharacter.h
src/legacy/legacycurrency.h
src/legacy/legacydatastore.h
src/legacy/legacyitem.h
src/legacy/legacystash.h
src/modlist.h
src/modsfilter.h
src/network_info.h
src/ratelimit/ratelimit.h
src/ratelimit/ratelimitdialog.h
src/ratelimit/ratelimitedreply.h
src/ratelimit/ratelimitedrequest.h
src/ratelimit/ratelimiter.h
src/ratelimit/ratelimitmanager.h
src/ratelimit/ratelimitpolicy.h
src/replytimeout.h
src/search.h
src/shop.h
src/ui/flowlayout.h
src/ui/itemtooltip.h
src/ui/logindialog.h
src/ui/logpanel.h
src/ui/mainwindow.h
src/ui/searchcombobox.h
src/ui/verticalscrollarea.h
src/util/crashpad.h
src/util/fatalerror.h
src/util/networkmanager.h
src/util/oauthmanager.h
src/util/oauthtoken.h
src/util/rapidjson_util.h
src/util/repoe.h
src/util/updatechecker.h
src/util/util.h
test/testdata.h
test/testitem.h
test/testitemsmanager.h
test/testmain.h
test/testshop.h
test/testutil.h
# Forms
src/ui/logindialog.ui
src/ui/mainwindow.ui
# Resources
resources.qrc
# Generated version header
"${CMAKE_BINARY_DIR}/version_defines.h"
)
# On Windows, we want to know which version of MSVC was used.
if(WIN32)
if(NOT MSVC)
message(FATAL_ERROR "Only the MSVC compiler is supported on Windows")
endif()
# On Windows there we do extra checks to catch incompatible older versions
# of the Microsoft Visual Studio C++ Runtime, because these can cause
# otherwise unexpected crashes (usually in mutex-related code).
#
# For this to work, we need to know the MSCV runtime version that acquisition
# was built with, which is what the cmake code below this include does.
target_sources(acquisition PRIVATE
src/util/checkmsvc.cpp
src/util/checkmsvc.h
)
# The Microsoft Visual C++ Compiler version 19 corresponds to runtime version 14.
set(msvc_compiler_ver "19")
set(msvc_runtime_ver "14")
# Run the compiler executable to grab the version printed on the first line.
execute_process(
COMMAND cl
OUTPUT_VARIABLE cl_output
ERROR_VARIABLE cl_error
OUTPUT_STRIP_TRAILING_WHITESPACE
)
# Extract the compiler version.
string(REGEX MATCH "Version ([0-9]+\\.[0-9]+\\.[0-9]+)" msvc_version ${cl_error})
string(REGEX REPLACE "^Version " "" msvc_version ${msvc_version})
if (NOT msvc_version)
message(FATAL_ERROR "Could not determine MSVC version from cl.exe output")
endif()
message(STATUS "MSVC Compiler: ${msvc_version}")
# Derive the runtime version.
string(REGEX REPLACE "^${msvc_compiler_ver}" "${msvc_runtime_ver}" msvc_runtime_version ${msvc_version})
if (NOT msvc_runtime_version)
message(FATAL_ERROR "Could not determine MSVC runtime version from cl.exe output")
endif()
message(STATUS "MSVC Runtime: ${msvc_runtime_version}")
endif()
# Automatically populate and include the versions header file.
configure_file("src/version_defines.h.in" "version_defines.h" @ONLY)
# Setup include directories.
target_include_directories(acquisition PRIVATE
src/
test/
"${CMAKE_BINARY_DIR}"
)
add_subdirectory(deps/boost-headers-only)
add_subdirectory(deps/Crashpad)
add_subdirectory(deps/json_struct)
add_subdirectory(deps/libpoe)
add_subdirectory(deps/qdarkstyle)
add_subdirectory(deps/QsLog)
add_subdirectory(deps/rapidjson)
add_subdirectory(deps/semver)
# Link required libraries.
target_link_libraries(acquisition PRIVATE
# Qt libraries
Qt::Core
Qt::Gui
Qt::HttpServer
Qt::Network
Qt::Widgets
Qt::Sql
Qt::Test
Qt::WebSockets
# Extenal libraries
boost-headers-only
Crashpad
json_struct
libpoe
qdarkstyle
QsLog
rapidjson
semver
)
#----------------------------------
# Platform-specific section
#----------------------------------
if(WIN32)
# Needed to check the MSVC runtime version
target_link_libraries(acquisition PRIVATE Version)
# Add the application icon.
target_sources(acquisition PRIVATE "${PROJECT_SOURCE_DIR}/assets/icon.ico")
# Use a function to set version variables so there can be a default value.
function(setver name value default)
if (NOT "${value}" STREQUAL "")
set("${name}" "${value}" PARENT_SCOPE)
else()
set("${name}" "${default}" PARENT_SCOPE)
endif()
endfunction()
# Define the version variables.
setver(app_VERSION_MAJOR "${PROJECT_VERSION_MAJOR}" 1)
setver(app_VERSION_MINOR "${PROJECT_VERSION_MINOR}" 0)
setver(app_VERSION_PATCH "${PROJECT_VERSION_PATCH}" 0)
setver(app_VERSION_TWEAK "${PROJECT_VERSION_TWEAK}" 0)
# Define the reset of the versioninfo data.
set(app_COMPANY_NAME "")
set(app_FILE_DESCRIPTION "")
set(app_FILE_VERSION "${app_version_string}")
set(app_INTERNAL_NAME "${CMAKE_PROJECT_NAME}")
set(app_LEGAL_COPYRIGHT "${app_copyright}")
set(app_LEGAL_TRADEMARK "${app_trademark}")
set(app_ORIGINAL_FILENAME "${CMAKE_PROJECT_NAME}.exe")
set(app_PRODUCT_NAME "${CMAKE_PROJECT_NAME}")
set(app_PRODUCT_VERSION "${app_version_string}")
set(app_ICON "${PROJECT_SOURCE_DIR}/assets/icon.ico")
# Create the windows VERSIONINFO resource file.
configure_file(version_info.rc.in version_info.rc @ONLY)
target_sources(acquisition PUBLIC "${CMAKE_BINARY_DIR}/version_info.rc")
elseif(APPLE)
set(macosx_app_version "${PROJECT_VERSION_MAJOR}.${PROJECT_VERSION_MINOR}.${PROJECT_VERSION_PATCH}")
# Setup the macOS bundle
set_target_properties(acquisition PROPERTIES
MACOSX_BUNDLE_BUNDLE_NAME "Acquisition"
MACOSX_BUNDLE_BUNDLE_VERSION "${macosx_app_version}"
MACOSX_BUNDLE_COPYRIGHT "${app_copyright}"
#MACOSX_BUNDLE_GUI_IDENTIFIER ""
MACOSX_BUNDLE_ICON_FILE "icon.icns"
MACOSX_BUNDLE_INFO_STRING "${PROJECT_DESCRIPTION}"
MACOSX_BUNDLE_SHORT_VERSION_STRING "${macosx_app_version}"
)
# Add the macOS application icon
set(macos_app_icon "${PROJECT_SOURCE_DIR}/assets/icon.icns")
set_source_files_properties("${macos_app_icon}" PROPERTIES MACOSX_PACKAGE_LOCATION "Resources")
target_sources(acquisition PRIVATE "${macos_app_icon}")
# Generate debugging symbols file.
target_compile_options(acquisition PRIVATE "-g")
set_target_properties(acquisition PROPERTIES
XCODE_ATTRIBUTE_GCC_GENERATE_DEBUGGING_SYMBOLS "YES"
XCODE_ATTRIBUTE_DEBUG_INFORMATION_FORMAT "dwarf-with-dsym"
XCODE_ATTRIBUTE_DEPLOYMENT_POSTPROCESING "YES"
XCODE_ATTRIBUTE_STRIP_INSTALLED_PRODUCT "YES"
)
set(macos_exe "${CMAKE_BINARY_DIR}/acquisition.app/Contents/MacOS/acquisition")
set(macos_dsym "${CMAKE_BINARY_DIR}/acquisition_${app_version_string}.dSYM")
add_custom_command(TARGET acquisition
POST_BUILD
COMMAND xcrun dsymutil "${macos_exe}" -o "${macos_dsym}"
)
elseif(UNIX)
find_package(OpenSSL REQUIRED)
# Make sure OpenSSL was found
if (OpenSSL_FOUND)
message(STATUS "Found OpenSSL: ${OPENSSL_VERSION}")
message(STATUS "OpenSSL Include Dir: ${OPENSSL_INCLUDE_DIR}")
message(STATUS "OpenSSL Libraries: ${OPENSSL_LIBRARIES}")
else()
message(FATAL_ERROR "OpenSSL not found on this system!")
endif()
# Link OpenSSL libraries to acquisition
target_include_directories(acquisition PUBLIC ${OPENSSL_INCLUDE_DIR})
target_link_libraries(acquisition PUBLIC OpenSSL::SSL OpenSSL::Crypto)
# Generate debug symbols.
target_compile_options(acquisition PRIVATE -g)
add_custom_command(TARGET acquisition
POST_BUILD
COMMAND ${CMAKE_OBJCOPY} --only-keep-debug acquisition acquisition.debug
COMMAND ${CMAKE_STRIP} --strip-debug --strip-unneeded acquisition
COMMAND ${CMAKE_OBJCOPY} --add-gnu-debuglink=acquisition.debug acquisition
COMMAND chmod -x acquisition.debug
)
endif()