-
Notifications
You must be signed in to change notification settings - Fork 0
/
CMakeLists.txt
425 lines (372 loc) · 20.1 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
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
cmake_minimum_required (VERSION 3.6)
cmake_policy(SET CMP0015 NEW)
project (LOOT)
include(ExternalProject)
option(MSVC_STATIC_RUNTIME "Build with static runtime libs (/MT)" OFF)
IF (${MSVC_STATIC_RUNTIME})
set (MSVC_SHARED_RUNTIME OFF)
ELSE()
set (MSVC_SHARED_RUNTIME ON)
ENDIF()
set(CMAKE_POSITION_INDEPENDENT_CODE ON)
set(CMAKE_CXX_STANDARD 17)
set(CMAKE_CXX_STANDARD_REQUIRED ON)
##############################
# Get Build Revision
##############################
find_package(Git)
IF (GIT_FOUND)
execute_process(COMMAND ${GIT_EXECUTABLE} rev-parse --short HEAD
WORKING_DIRECTORY ${CMAKE_SOURCE_DIR}
OUTPUT_VARIABLE GIT_COMMIT_STRING
OUTPUT_STRIP_TRAILING_WHITESPACE)
ELSE()
SET (GIT_COMMIT_STRING "unknown")
ENDIF ()
message(STATUS "Git revision: ${GIT_COMMIT_STRING}")
# Write to file.
configure_file("${CMAKE_SOURCE_DIR}/src/gui/version.cpp.in" "${CMAKE_BINARY_DIR}/generated/version.cpp" @ONLY)
include_directories("${CMAKE_BINARY_DIR}/generated")
##############################
# External Projects
##############################
set (Boost_USE_STATIC_LIBS ON)
set (Boost_USE_MULTITHREADED ON)
IF (MSVC)
set (Boost_USE_STATIC_RUNTIME ${MSVC_STATIC_RUNTIME})
ELSE()
set (Boost_USE_STATIC_RUNTIME OFF)
ENDIF()
find_package(Boost REQUIRED COMPONENTS locale system)
if (NOT CMAKE_SYSTEM_NAME MATCHES "Windows")
find_package(ICU REQUIRED COMPONENTS uc)
include_directories($ICU_INCLUDE_DIRS)
link_directories($ICU_LIBRARY_DIRS)
endif()
ExternalProject_Add(GTest
PREFIX "external"
URL "https://github.com/google/googletest/archive/release-1.8.1.tar.gz"
CMAKE_ARGS -Dgtest_force_shared_crt=${MSVC_SHARED_RUNTIME}
INSTALL_COMMAND "")
ExternalProject_Get_Property(GTest SOURCE_DIR BINARY_DIR)
set (GTEST_INCLUDE_DIRS "${SOURCE_DIR}/googletest/include")
set (GTEST_LIBRARIES "${BINARY_DIR}/googlemock/gtest/${CMAKE_CFG_INTDIR}/${CMAKE_STATIC_LIBRARY_PREFIX}gtest${CMAKE_STATIC_LIBRARY_SUFFIX}")
if (NOT DEFINED LIBLOOT_URL)
if (CMAKE_SYSTEM_NAME MATCHES "Windows")
if ("${CMAKE_GENERATOR_PLATFORM}" MATCHES "Win32")
set(LIBLOOT_URL "https://github.com/loot/libloot/releases/download/0.16.3/libloot-0.16.3-0-g2ffdac5_0.16.3-win32.7z")
else()
set(LIBLOOT_URL "https://github.com/loot/libloot/releases/download/0.16.3/libloot-0.16.3-0-g2ffdac5_0.16.3-win64.7z")
endif()
else()
set(LIBLOOT_URL "https://github.com/loot/libloot/releases/download/0.16.3/libloot-0.16.3-0-g2ffdac5_0.16.3-Linux.tar.xz")
endif()
endif()
ExternalProject_Add(json
PREFIX "external"
URL "https://github.com/nlohmann/json/releases/download/v3.9.1/json.hpp"
URL_HASH SHA256=7804b38146921d03374549c9e2a5e3acda097814c43caf2b96a0278e58df26e0
DOWNLOAD_NO_EXTRACT 1
CONFIGURE_COMMAND ""
BUILD_COMMAND ""
INSTALL_COMMAND "")
set(JSON_INCLUDE_DIRS "${CMAKE_BINARY_DIR}/external/src")
ExternalProject_Add(libloot
PREFIX "external"
URL ${LIBLOOT_URL}
CONFIGURE_COMMAND ""
BUILD_COMMAND ""
INSTALL_COMMAND "")
ExternalProject_Get_Property(libloot SOURCE_DIR)
set(LIBLOOT_EXTRACTED_PATH ${SOURCE_DIR})
include_directories("${CMAKE_SOURCE_DIR}/src"
"${LIBLOOT_EXTRACTED_PATH}/include")
link_directories(${LIBLOOT_EXTRACTED_PATH})
set(LIBLOOT_STATIC_LIBRARY "${CMAKE_STATIC_LIBRARY_PREFIX}loot${CMAKE_STATIC_LIBRARY_SUFFIX}")
set(LIBLOOT_SHARED_LIBRARY "${CMAKE_SHARED_LIBRARY_PREFIX}loot${CMAKE_SHARED_LIBRARY_SUFFIX}")
ExternalProject_Add(testing-plugins
PREFIX "external"
URL "https://github.com/Ortham/testing-plugins/archive/1.4.1.tar.gz"
CONFIGURE_COMMAND ""
BUILD_COMMAND ""
INSTALL_COMMAND "")
IF (CMAKE_SYSTEM_NAME MATCHES "Windows")
if ("${CMAKE_GENERATOR_PLATFORM}" MATCHES "Win32")
set(CEF_URL "https://cef-builds.spotifycdn.com/cef_binary_90.6.5%2Bg7a604aa%2Bchromium-90.0.4430.93_windows32_minimal.tar.bz2")
set(CEF_URL_HASH "71a8a4a643d28a9711574ffdf0e96c6b6fee9be3")
set(CEF_PRECOMPILED_BINARIES "libcef.dll" "snapshot_blob.bin" "v8_context_snapshot.bin" "d3dcompiler_47.dll" "libEGL.dll" "libGLESv2.dll" "chrome_elf.dll")
set(CEF_LIB libcef${CMAKE_STATIC_LIBRARY_SUFFIX})
else()
set(CEF_URL "https://cef-builds.spotifycdn.com/cef_binary_90.6.5%2Bg7a604aa%2Bchromium-90.0.4430.93_windows64_minimal.tar.bz2")
set(CEF_URL_HASH "ff215765fb431bc70eb4058a728c5bfa914f60b3")
set(CEF_PRECOMPILED_BINARIES "libcef.dll" "snapshot_blob.bin" "v8_context_snapshot.bin" "d3dcompiler_47.dll" "libEGL.dll" "libGLESv2.dll" "chrome_elf.dll")
set(CEF_LIB libcef${CMAKE_STATIC_LIBRARY_SUFFIX})
endif()
ELSE ()
set(CEF_URL "https://cef-builds.spotifycdn.com/cef_binary_90.6.5%2Bg7a604aa%2Bchromium-90.0.4430.93_linux64_minimal.tar.bz2")
set(CEF_URL_HASH "c81f998e45d2abbdfb4fb138f0f0593baac1ecf7")
set(CEF_PRECOMPILED_BINARIES "libcef.so" "snapshot_blob.bin" "v8_context_snapshot.bin" "chrome-sandbox")
set(CEF_LIB libcef${CMAKE_SHARED_LIBRARY_SUFFIX})
ENDIF()
IF (CMAKE_SYSTEM_NAME MATCHES "Windows")
set(CEF_BUILD_COMMAND, "${CMAKE_COMMAND} --build . --target libcef_dll_wrapper --config $(CONFIGURATION)")
ELSE ()
set(CEF_BUILD_COMMAND, "${CMAKE_COMMAND} --build . --target libcef_dll_wrapper")
ENDIF()
ExternalProject_Add(cef
PREFIX "external"
URL ${CEF_URL}
URL_HASH SHA1=${CEF_URL_HASH}
CMAKE_ARGS -DUSE_SANDBOX=OFF
BUILD_COMMAND ${CEF_BUILD_COMMAND}
INSTALL_COMMAND "")
ExternalProject_Get_Property(cef SOURCE_DIR BINARY_DIR)
set(CEF_INCLUDE_DIRS "${SOURCE_DIR}")
set(CEF_LIBRARIES "${SOURCE_DIR}/Release/${CEF_LIB}"
"${BINARY_DIR}/libcef_dll_wrapper/${CMAKE_CFG_INTDIR}/libcef_dll_wrapper${CMAKE_STATIC_LIBRARY_SUFFIX}")
set(CEF_RESOURCES_DIR "${SOURCE_DIR}/Resources")
set(CEF_RESOURCES "chrome_100_percent.pak"
"chrome_200_percent.pak"
"icudtl.dat"
"resources.pak")
set(CEF_LOCALES_DIR "${CEF_RESOURCES_DIR}/locales")
set(CEF_LOCALE_FILE "en-US.pak")
set(CEF_PRECOMPILED_BINARIES_DIR "${SOURCE_DIR}/Release")
ExternalProject_Add(cpptoml
PREFIX "external"
URL "https://github.com/skystrife/cpptoml/archive/v0.1.1.tar.gz"
CONFIGURE_COMMAND ""
BUILD_COMMAND ""
INSTALL_COMMAND "")
ExternalProject_Get_Property(cpptoml SOURCE_DIR)
set(CPPTOML_INCLUDE_DIRS "${SOURCE_DIR}/include")
ExternalProject_Add(spdlog
PREFIX "external"
URL "https://github.com/gabime/spdlog/archive/v1.8.5.tar.gz"
CONFIGURE_COMMAND ""
BUILD_COMMAND ""
INSTALL_COMMAND "")
ExternalProject_Get_Property(spdlog SOURCE_DIR)
set(SPDLOG_INCLUDE_DIRS "${SOURCE_DIR}/include")
##############################
# General Settings
##############################
set (LOOT_GUI_SRC "${CMAKE_BINARY_DIR}/generated/version.cpp"
"${CMAKE_SOURCE_DIR}/src/gui/main.cpp"
"${CMAKE_SOURCE_DIR}/src/gui/helpers.cpp"
"${CMAKE_SOURCE_DIR}/src/gui/cef/loot_handler.cpp"
"${CMAKE_SOURCE_DIR}/src/gui/cef/loot_app.cpp"
"${CMAKE_SOURCE_DIR}/src/gui/cef/loot_scheme_handler_factory.cpp"
"${CMAKE_SOURCE_DIR}/src/gui/cef/window_delegate.cpp"
"${CMAKE_SOURCE_DIR}/src/gui/cef/query/query_handler.cpp"
"${CMAKE_SOURCE_DIR}/src/gui/state/game/game.cpp"
"${CMAKE_SOURCE_DIR}/src/gui/state/game/game_settings.cpp"
"${CMAKE_SOURCE_DIR}/src/gui/state/game/helpers.cpp"
"${CMAKE_SOURCE_DIR}/src/gui/state/logging.cpp"
"${CMAKE_SOURCE_DIR}/src/gui/state/loot_paths.cpp"
"${CMAKE_SOURCE_DIR}/src/gui/state/loot_settings.cpp"
"${CMAKE_SOURCE_DIR}/src/gui/state/loot_state.cpp"
"${CMAKE_SOURCE_DIR}/src/gui/resource.rc")
set (LOOT_GUI_HEADERS "${CMAKE_SOURCE_DIR}/src/gui/helpers.h"
"${CMAKE_SOURCE_DIR}/src/gui/cef/loot_handler.h"
"${CMAKE_SOURCE_DIR}/src/gui/cef/loot_app.h"
"${CMAKE_SOURCE_DIR}/src/gui/cef/loot_scheme_handler_factory.h"
"${CMAKE_SOURCE_DIR}/src/gui/cef/window_delegate.h"
"${CMAKE_SOURCE_DIR}/src/gui/cef/query/derived_plugin_metadata.h"
"${CMAKE_SOURCE_DIR}/src/gui/cef/query/json.h"
"${CMAKE_SOURCE_DIR}/src/gui/cef/query/query.h"
"${CMAKE_SOURCE_DIR}/src/gui/cef/query/query_executor.h"
"${CMAKE_SOURCE_DIR}/src/gui/cef/query/types/apply_sort_query.h"
"${CMAKE_SOURCE_DIR}/src/gui/cef/query/types/cancel_sort_query.h"
"${CMAKE_SOURCE_DIR}/src/gui/cef/query/types/change_game_query.h"
"${CMAKE_SOURCE_DIR}/src/gui/cef/query/types/clear_all_metadata_query.h"
"${CMAKE_SOURCE_DIR}/src/gui/cef/query/types/clear_plugin_metadata_query.h"
"${CMAKE_SOURCE_DIR}/src/gui/cef/query/types/clipboard_query.h"
"${CMAKE_SOURCE_DIR}/src/gui/cef/query/types/close_settings_query.h"
"${CMAKE_SOURCE_DIR}/src/gui/cef/query/types/copy_content_query.h"
"${CMAKE_SOURCE_DIR}/src/gui/cef/query/types/copy_load_order_query.h"
"${CMAKE_SOURCE_DIR}/src/gui/cef/query/types/copy_metadata_query.h"
"${CMAKE_SOURCE_DIR}/src/gui/cef/query/types/discard_unapplied_changes_query.h"
"${CMAKE_SOURCE_DIR}/src/gui/cef/query/types/editor_opened_query.h"
"${CMAKE_SOURCE_DIR}/src/gui/cef/query/types/editor_closed_query.h"
"${CMAKE_SOURCE_DIR}/src/gui/cef/query/types/get_auto_sort_query.h"
"${CMAKE_SOURCE_DIR}/src/gui/cef/query/types/get_conflicting_plugins_query.h"
"${CMAKE_SOURCE_DIR}/src/gui/cef/query/types/get_game_data_query.h"
"${CMAKE_SOURCE_DIR}/src/gui/cef/query/types/get_game_types_query.h"
"${CMAKE_SOURCE_DIR}/src/gui/cef/query/types/get_init_errors_query.h"
"${CMAKE_SOURCE_DIR}/src/gui/cef/query/types/get_installed_games_query.h"
"${CMAKE_SOURCE_DIR}/src/gui/cef/query/types/get_settings_query.h"
"${CMAKE_SOURCE_DIR}/src/gui/cef/query/types/get_themes_query.h"
"${CMAKE_SOURCE_DIR}/src/gui/cef/query/types/get_version_query.h"
"${CMAKE_SOURCE_DIR}/src/gui/cef/query/types/metadata_query.h"
"${CMAKE_SOURCE_DIR}/src/gui/cef/query/types/open_log_location_query.h"
"${CMAKE_SOURCE_DIR}/src/gui/cef/query/types/open_readme_query.h"
"${CMAKE_SOURCE_DIR}/src/gui/cef/query/types/redate_plugins_query.h"
"${CMAKE_SOURCE_DIR}/src/gui/cef/query/types/save_filter_state_query.h"
"${CMAKE_SOURCE_DIR}/src/gui/cef/query/types/save_user_groups_query.h"
"${CMAKE_SOURCE_DIR}/src/gui/cef/query/types/sort_plugins_query.h"
"${CMAKE_SOURCE_DIR}/src/gui/cef/query/types/update_masterlist_query.h"
"${CMAKE_SOURCE_DIR}/src/gui/cef/query/query_handler.h"
"${CMAKE_SOURCE_DIR}/src/gui/state/game/game.h"
"${CMAKE_SOURCE_DIR}/src/gui/state/game/game_detection_error.h"
"${CMAKE_SOURCE_DIR}/src/gui/state/game/game_settings.h"
"${CMAKE_SOURCE_DIR}/src/gui/state/game/games_manager.h"
"${CMAKE_SOURCE_DIR}/src/gui/state/game/helpers.h"
"${CMAKE_SOURCE_DIR}/src/gui/state/logging.h"
"${CMAKE_SOURCE_DIR}/src/gui/state/loot_paths.h"
"${CMAKE_SOURCE_DIR}/src/gui/state/loot_settings.h"
"${CMAKE_SOURCE_DIR}/src/gui/state/loot_state.h"
"${CMAKE_SOURCE_DIR}/src/gui/state/unapplied_change_counter.h"
"${CMAKE_SOURCE_DIR}/src/gui/resource.h"
"${CMAKE_SOURCE_DIR}/src/gui/version.h")
set(LOOT_GUI_TESTS_SRC "${CMAKE_BINARY_DIR}/generated/version.cpp"
"${CMAKE_SOURCE_DIR}/src/gui/helpers.cpp"
"${CMAKE_SOURCE_DIR}/src/gui/state/game/game.cpp"
"${CMAKE_SOURCE_DIR}/src/gui/state/game/game_settings.cpp"
"${CMAKE_SOURCE_DIR}/src/gui/state/game/helpers.cpp"
"${CMAKE_SOURCE_DIR}/src/gui/state/logging.cpp"
"${CMAKE_SOURCE_DIR}/src/gui/state/loot_paths.cpp"
"${CMAKE_SOURCE_DIR}/src/gui/state/loot_settings.cpp"
"${CMAKE_SOURCE_DIR}/src/gui/state/loot_state.cpp"
"${CMAKE_SOURCE_DIR}/src/tests/gui/main.cpp")
set (LOOT_GUI_TESTS_HEADERS "${CMAKE_SOURCE_DIR}/src/gui/helpers.h"
"${CMAKE_SOURCE_DIR}/src/gui/state/game/game.h"
"${CMAKE_SOURCE_DIR}/src/gui/state/game/game_settings.h"
"${CMAKE_SOURCE_DIR}/src/gui/state/loot_paths.h"
"${CMAKE_SOURCE_DIR}/src/gui/state/loot_settings.h"
"${CMAKE_SOURCE_DIR}/src/gui/state/loot_state.h"
"${CMAKE_SOURCE_DIR}/src/tests/gui/cef/query/json_test.h"
"${CMAKE_SOURCE_DIR}/src/tests/gui/cef/query/types/close_settings_query_test.h"
"${CMAKE_SOURCE_DIR}/src/tests/gui/cef/query/types/editor_closed_query_test.h"
"${CMAKE_SOURCE_DIR}/src/tests/gui/cef/query/types/get_settings_query_test.h"
"${CMAKE_SOURCE_DIR}/src/tests/gui/cef/query/types/get_themes_query_test.h"
"${CMAKE_SOURCE_DIR}/src/tests/gui/state/game/game_test.h"
"${CMAKE_SOURCE_DIR}/src/tests/gui/state/game/game_settings_test.h"
"${CMAKE_SOURCE_DIR}/src/tests/gui/state/game/games_manager_test.h"
"${CMAKE_SOURCE_DIR}/src/tests/gui/state/game/helpers_test.h"
"${CMAKE_SOURCE_DIR}/src/tests/gui/state/loot_paths_test.h"
"${CMAKE_SOURCE_DIR}/src/tests/gui/state/loot_settings_test.h"
"${CMAKE_SOURCE_DIR}/src/tests/gui/state/unapplied_change_counter_test.h"
"${CMAKE_SOURCE_DIR}/src/tests/gui/helpers_test.h"
"${CMAKE_SOURCE_DIR}/src/tests/gui/test_helpers.h")
source_group("Header Files\\gui" FILES ${LOOT_GUI_HEADERS})
source_group("Header Files\\tests" FILES ${LOOT_TESTS_HEADERS})
source_group("Header Files\\tests" FILES ${LOOT_GUI_TESTS_HEADERS})
source_group("Source Files\\gui" FILES ${LOOT_GUI_SRC})
source_group("Source Files\\tests" FILES ${LOOT_TESTS_SRC})
source_group("Header Files\\tests" FILES ${LOOT_GUI_TESTS_SRC})
# Include source and library directories.
include_directories ("${CMAKE_SOURCE_DIR}/src"
${CPPTOML_INCLUDE_DIRS}
${CEF_INCLUDE_DIRS}
${JSON_INCLUDE_DIRS}
${Boost_INCLUDE_DIRS}
${GTEST_INCLUDE_DIRS}
${SPDLOG_INCLUDE_DIRS})
##############################
# System-Specific Settings
##############################
# Settings when compiling for Windows.
IF (CMAKE_SYSTEM_NAME MATCHES "Windows")
add_definitions (-DUNICODE -D_UNICODE -DNOMINMAX -DBOOST_UUID_FORCE_AUTO_LINK)
set(LIBLOOT_LINK_LIBRARY ${LIBLOOT_STATIC_LIBRARY})
else()
set(LIBLOOT_LINK_LIBRARY ${LIBLOOT_SHARED_LIBRARY})
endif()
IF (CMAKE_COMPILER_IS_GNUCXX)
set (CMAKE_INSTALL_RPATH "${CMAKE_INSTALL_RPATH};.")
set (CMAKE_BUILD_WITH_INSTALL_RPATH ON)
set (LOOT_LIBS pthread http_parser ssh2 stdc++fs icui18n)
set (LOOT_GUI_LIBS X11 ${LOOT_LIBS})
set (LOOT_TEST_LIBS ${LOOT_LIBS})
ENDIF ()
IF (MSVC)
# Turn off permissive mode to be more standards-compliant and avoid compiler errors.
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} /permissive-")
# Set /bigobj to allow building Debug tests
set(CMAKE_CXX_FLAGS_DEBUG "${CMAKE_CXX_FLAGS_DEBUG} /bigobj")
# Update compiler flags.
IF (MSVC_STATIC_RUNTIME)
FOREACH(flag
CMAKE_C_FLAGS_RELEASE CMAKE_C_FLAGS_RELWITHDEBINFO
CMAKE_C_FLAGS_DEBUG CMAKE_C_FLAGS_DEBUG_INIT
CMAKE_CXX_FLAGS_RELEASE CMAKE_CXX_FLAGS_RELWITHDEBINFO
CMAKE_CXX_FLAGS_DEBUG CMAKE_CXX_FLAGS_DEBUG_INIT)
STRING(REPLACE "/MD" "/MT" "${flag}" "${${flag}}")
SET("${flag}" "${${flag}} /EHsc")
ENDFOREACH()
ENDIF ()
set (LOOT_GUI_LIBS comctl32
Psapi)
ENDIF ()
##############################
# Define Targets
##############################
# Build application.
add_executable (LOOT ${LOOT_GUI_SRC} ${LOOT_GUI_HEADERS})
add_dependencies (LOOT cef cpptoml json libloot spdlog)
target_link_libraries(LOOT ${Boost_LIBRARIES} ${CEF_LIBRARIES} ${LIBLOOT_LINK_LIBRARY} ${LOOT_GUI_LIBS} ${ICU_LIBRARIES})
# Build application tests.
add_executable (loot_gui_tests ${LOOT_GUI_TESTS_SRC} ${LOOT_GUI_TESTS_HEADERS})
add_dependencies (loot_gui_tests cpptoml libloot spdlog GTest testing-plugins)
target_link_libraries(loot_gui_tests ${Boost_LIBRARIES} ${LIBLOOT_LINK_LIBRARY} ${GTEST_LIBRARIES} ${LOOT_TEST_LIBS} ${ICU_LIBRARIES})
##############################
# Set Target-Specific Flags
##############################
IF (MSVC)
set (LOOT_LINK_FLAGS "/SUBSYSTEM:WINDOWS /LARGEADDRESSAWARE")
get_target_property (EXISTING_LINK_FLAGS LOOT LINK_FLAGS)
IF (EXISTING_LINK_FLAGS)
set (LOOT_LINK_FLAGS "${EXISTING_LINK_FLAGS} ${LOOT_LINK_FLAGS}")
ENDIF ()
set_target_properties (LOOT PROPERTIES LINK_FLAGS ${LOOT_LINK_FLAGS})
ENDIF ()
##############################
# Post-Build Steps
##############################
IF (CMAKE_SYSTEM_NAME MATCHES "Windows")
add_custom_command(
TARGET LOOT
POST_BUILD
COMMAND "mt.exe" -manifest \"${CMAKE_SOURCE_DIR}/src/gui/LOOT.exe.manifest\" -inputresource:"$(TargetDir)$(TargetFileName)"\;\#1 -outputresource:"$(TargetDir)$(TargetFileName)"\;\#1
COMMENT "Adding manifest..."
)
ENDIF ()
# Copy CEF binaries.
FOREACH(cef_dll ${CEF_PRECOMPILED_BINARIES})
add_custom_command(TARGET LOOT POST_BUILD
COMMAND ${CMAKE_COMMAND} -E copy_if_different
"${CEF_PRECOMPILED_BINARIES_DIR}/${cef_dll}"
$<TARGET_FILE_DIR:LOOT>/${cef_dll})
ENDFOREACH()
# Copy CEF resources.
FOREACH(cef_resource ${CEF_RESOURCES})
add_custom_command(TARGET LOOT POST_BUILD
COMMAND ${CMAKE_COMMAND} -E copy_if_different
"${CEF_RESOURCES_DIR}/${cef_resource}"
$<TARGET_FILE_DIR:LOOT>/${cef_resource})
ENDFOREACH()
# Copy CEF en-US locale resource.
add_custom_command(TARGET LOOT POST_BUILD
COMMAND ${CMAKE_COMMAND} -E copy_if_different
"${CEF_LOCALES_DIR}/${CEF_LOCALE_FILE}"
$<TARGET_FILE_DIR:LOOT>/resources/l10n/${CEF_LOCALE_FILE})
# Copy the API binary to the build directory.
add_custom_command(TARGET LOOT POST_BUILD
COMMAND ${CMAKE_COMMAND} -E copy_if_different
"${LIBLOOT_EXTRACTED_PATH}/${LIBLOOT_SHARED_LIBRARY}"
"$<TARGET_FILE_DIR:LOOT>/${LIBLOOT_SHARED_LIBRARY}")
add_custom_command(TARGET loot_gui_tests POST_BUILD
COMMAND ${CMAKE_COMMAND} -E copy_if_different
"${LIBLOOT_EXTRACTED_PATH}/${LIBLOOT_SHARED_LIBRARY}"
"$<TARGET_FILE_DIR:loot_gui_tests>/${LIBLOOT_SHARED_LIBRARY}")
# Build the UI HTML.
add_custom_command(TARGET LOOT POST_BUILD
COMMAND yarn build
WORKING_DIRECTORY ${CMAKE_SOURCE_DIR})
# Copy testing plugins
ExternalProject_Get_Property(testing-plugins SOURCE_DIR)
add_custom_command(TARGET loot_gui_tests POST_BUILD
COMMAND ${CMAKE_COMMAND} -E copy_directory
${SOURCE_DIR}
$<TARGET_FILE_DIR:loot_gui_tests>)