forked from Banderi/Ozymandias
-
-
Notifications
You must be signed in to change notification settings - Fork 13
/
CMakeLists.txt
578 lines (516 loc) · 24.8 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
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
cmake_minimum_required(VERSION 3.13...3.26)
include(CMakeDependentOption)
set(CMAKE_BUILD_PLATFORM "default" CACHE STRING "Platform to cross-compile for. Options: android default")
if (CMAKE_BUILD_PLATFORM STREQUAL "win_emscripten")
message("Platform: win + emscripten")
set(WIN_EMSCRIPTEN TRUE)
else()
set(WIN_EMSCRIPTEN FALSE)
endif()
if (CMAKE_BUILD_PLATFORM STREQUAL "android")
message("Platform: android")
set(PLATFORM_ANDROID TRUE)
else()
set(PLATFORM_ANDROID FALSE)
endif()
#
# CppTrace
#
if(PLATFORM_ANDROID)
# no cpptrace for android, baa...
else()
if(CMAKE_BUILD_TYPE STREQUAL "RelWithDebInfo" OR CMAKE_BUILD_TYPE STREQUAL "Debug")
set(CPPTRACE_EXT_PATH "${CMAKE_CURRENT_SOURCE_DIR}/ext/cpptrace")
set(CPPTRACE_CHECK_PATH "${CPPTRACE_EXT_PATH}/include/cpptrace/cpptrace.hpp")
if (EXISTS "${CPPTRACE_CHECK_PATH}")
add_definitions(-DCPPTRACE_ENABLED=ON)
include_directories(${PROJECT_SOURCE_DIR}/ext/cpptrace/include)
set(CPPTRACE_LIBRARY cpptrace)
add_subdirectory(ext/cpptrace)
endif()
endif()
endif()
#
# Akhenaten
#
set(GAME akhenaten)
project(${GAME} CXX)
message("C++ compiler is ${CMAKE_CXX_COMPILER_ID}" )
if(CMAKE_SIZEOF_VOID_P EQUAL 8)
set(GAME_ARCH_64 TRUE)
set(GAME_PROCESSOR_ARCH "x64")
else()
set(GAME_ARCH_64 FALSE)
set(GAME_PROCESSOR_ARCH "x86")
endif(CMAKE_SIZEOF_VOID_P EQUAL 8)
set(CMAKE_MODULE_PATH "${CMAKE_SOURCE_DIR}/cmake")
include("${CMAKE_MODULE_PATH}/CMakeRC.cmake")
if (MSVC)
add_compile_options(/wd4244)
add_compile_options(/MP)
add_compile_options(/EHsc)
elseif (APPLE)
set(CMAKE_CXX_FLAGS "-Wno-c++11-narrowing -Wno-deprecated-declarations -Wno-switch --std=c++17 -fno-exceptions -stdlib=libc++ ${CMAKE_CXX_FLAGS}")
elseif(PLATFORM_ANDROID)
set(CMAKE_CXX_FLAGS "-Wno-c++11-narrowing -fno-exceptions -Wno-switch -Wno-non-pod-varargs --std=c++17 -Wno-constant-conversion ${CMAKE_CXX_FLAGS}")
elseif(WIN_EMSCRIPTEN)
if(DEFINED ENV{EMSDK})
set(EMSDK $ENV{EMSDK})
set(CMAKE_TOOLCHAIN_FILE "$ENV{EMSDK}/upstream/emscripten/cmake/Modules/Platform/Emscripten.cmake" CACHE PATH "toolchain file")
else()
message(FATAL_ERROR "Please define EMSDK to Emscripten SDK in system path!")
endif()
message("Emscripten SDK: ${EMSDK}")
set(USE_FLAGS "-s USE_SDL=2 -s USE_SDL_MIXER=2 -s SDL2_MIXER_FORMATS=[\"mp3\"] -s USE_MPG123=1")
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} ${USE_FLAGS}")
set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} ${USE_FLAGS}")
set(CMAKE_CXX_FLAGS "-Wno-c++11-narrowing -fno-exceptions -Wno-varargs -Wno-constant-conversion -Wno-non-pod-varargs --std=c++17 ${CMAKE_CXX_FLAGS} ${USE_FLAGS}")
else()
set(CMAKE_CXX_FLAGS "-Wno-c++11-narrowing -fno-exceptions -static-libgcc --std=c++17 -static-libstdc++ ${CMAKE_CXX_FLAGS}")
endif()
set(CMAKE_CXX_STANDARD 17)
set(CMAKE_CXX_STANDARD_REQUIRED ON)
set(GAME_WORKING_DIRECTORY "${CMAKE_SOURCE_DIR}/bin_x64")
if(CMAKE_BUILD_TYPE STREQUAL "RelWithDebInfo")
SET(GAME_BUILD_TYPE "RelWithDebInfo")
elseif(CMAKE_BUILD_TYPE STREQUAL "Release")
SET(GAME_BUILD_TYPE "Release")
else()
SET(GAME_BUILD_TYPE "Debug")
endif()
set(SDL2_VERSION "2.30.7")
set(SDL2_MIXER_VERSION "2.0.4")
set(SDL2_EXTRACT_PATH "${CMAKE_CURRENT_SOURCE_DIR}/ext/SDL2")
set(TRACY_EXT_PATH "${CMAKE_CURRENT_SOURCE_DIR}/ext/tracy")
#
# Dependencies and libs
#
if (MSVC OR WIN_EMSCRIPTEN)
set(SDL_EXT_DIR ${CMAKE_CURRENT_SOURCE_DIR}/ext/SDL2)
set(SDL2_CHECK_PATH "${SDL2_EXTRACT_PATH}/include/SDL.h")
if(NOT EXISTS "${SDL2_CHECK_PATH}")
set(SDL2_DEP_FILENAME "SDL2-devel-${SDL2_VERSION}-VC.zip")
set(SDL2_UNPACK_DIR "SDL2-${SDL2_VERSION}")
set(SDL2_DOWNLOAD_URL "http://libsdl.org/release/${SDL2_DEP_FILENAME}")
set(SDL2_TMP_ZIP_PATH "${CMAKE_BINARY_DIR}/tmp/${SDL2_DEP_FILENAME}")
message("Download SDL2 to ${SDL2_TMP_ZIP_PATH}")
file(DOWNLOAD "${SDL2_DOWNLOAD_URL}" "${SDL2_TMP_ZIP_PATH}")
message("Unpack SDL2 to ${SDL2_EXTRACT_PATH}")
execute_process(COMMAND ${CMAKE_COMMAND} -E tar xzf ${SDL2_TMP_ZIP_PATH} WORKING_DIRECTORY ${CMAKE_BINARY_DIR}/tmp)
file(COPY ${CMAKE_BINARY_DIR}/tmp/${SDL2_UNPACK_DIR}/include DESTINATION ${SDL2_EXTRACT_PATH})
file(COPY ${CMAKE_BINARY_DIR}/tmp/${SDL2_UNPACK_DIR}/lib DESTINATION ${SDL2_EXTRACT_PATH})
endif()
set(SDL2_MIXER_DEP_FILENAME "SDL2_mixer-devel-${SDL2_MIXER_VERSION}-VC.zip")
set(SDL2_MIXER_DOWNLOAD_URL "https://libsdl.org/projects/SDL_mixer/release/${SDL2_MIXER_DEP_FILENAME}")
set(SDL2_MIXER_UNPACK_DIR "SDL2_mixer-${SDL2_MIXER_VERSION}")
set(SDL2_MIXER_CHECK_PATH "${SDL2_EXTRACT_PATH}/include/SDL_mixer.h")
set(SDL2_MIXER_TMP_ZIP_PATH "${CMAKE_BINARY_DIR}/tmp/${SDL2_MIXER_DEP_FILENAME}")
if (NOT EXISTS "${SDL2_MIXER_CHECK_PATH}")
message("Download SDL2_mixer to ${SDL2_MIXER_TMP_ZIP_PATH}")
file(DOWNLOAD "${SDL2_MIXER_DOWNLOAD_URL}" "${SDL2_MIXER_TMP_ZIP_PATH}")
message("Unpack SDL2_mixer to ${SDL2_EXTRACT_PATH}")
execute_process(COMMAND ${CMAKE_COMMAND} -E tar xzf ${SDL2_MIXER_TMP_ZIP_PATH} WORKING_DIRECTORY ${CMAKE_BINARY_DIR}/tmp)
file(COPY ${CMAKE_BINARY_DIR}/tmp/${SDL2_MIXER_UNPACK_DIR}/include DESTINATION ${SDL2_EXTRACT_PATH})
file(COPY ${CMAKE_BINARY_DIR}/tmp/${SDL2_MIXER_UNPACK_DIR}/lib DESTINATION ${SDL2_EXTRACT_PATH})
endif()
file(GLOB SDL2_DLL_PUBLIC_DLL "${SDL2_EXTRACT_PATH}/lib/${GAME_PROCESSOR_ARCH}/*.dll")
file(COPY ${SDL2_DLL_PUBLIC_DLL} DESTINATION ${GAME_WORKING_DIRECTORY})
set(SDL_FFMPEG_DIR ${CMAKE_CURRENT_SOURCE_DIR}/ext/ffmpeg)
file(GLOB FFMPEG_PUBLIC_DLL "${SDL_FFMPEG_DIR}/bin/*.dll")
file(COPY ${FFMPEG_PUBLIC_DLL} DESTINATION ${GAME_WORKING_DIRECTORY})
endif()
set(TRACY_CHECK_PATH "${TRACY_EXT_PATH}/public/TracyClient.cpp")
if (EXISTS "${TRACY_CHECK_PATH}")
add_definitions(-DTRACY_ENABLE=ON)
set(TRACY_FILES ${PROJECT_SOURCE_DIR}/ext/tracy/public/TracyClient.cpp)
include_directories(${PROJECT_SOURCE_DIR}/ext/tracy/public/)
endif()
if (CMAKE_BUILD_DEPENDENCIES STREQUAL "android")
set(SDL2_SRC_CHECK_PATH "${SDL2_EXTRACT_PATH}/SDL2-${SDL2_VERSION}/include/SDL.h")
set(SDL2_SRC_DOWNLOAD_URL "https://github.com/libsdl-org/SDL/releases/download/release-${SDL2_VERSION}/SDL2-${SDL2_VERSION}.zip")
set(SDL2_SRC_DEP_FILENAME "SDL2-${SDL2_VERSION}.zip")
set(SDL2_SRC_UNPACK_DIR "SDL2-${SDL2_VERSION}")
set(SDL2_SRC_TMP_ZIP_PATH "${CMAKE_BINARY_DIR}/tmp/${SDL2_SRC_DEP_FILENAME}")
set(SDL2_SRC_EXTRACT_PATH "${CMAKE_CURRENT_SOURCE_DIR}/ext/SDL2")
if (NOT EXISTS "${SDL2_SRC_CHECK_PATH}")
message("Download SDL2 sources to ${SDL2_SRC_TMP_ZIP_PATH}")
file(DOWNLOAD "${SDL2_SRC_DOWNLOAD_URL}" "${SDL2_SRC_TMP_ZIP_PATH}")
message("Unpack SDL2 sources to ${SDL2_SRC_EXTRACT_PATH}")
execute_process(COMMAND ${CMAKE_COMMAND} -E tar xzf ${SDL2_SRC_TMP_ZIP_PATH} WORKING_DIRECTORY ${CMAKE_BINARY_DIR}/tmp)
file(COPY ${CMAKE_BINARY_DIR}/tmp/${SDL2_SRC_UNPACK_DIR} DESTINATION ${SDL2_SRC_EXTRACT_PATH})
endif()
set(SDL2_MIXER_SRC_CHECK_PATH "${SDL2_EXTRACT_PATH}/SDL2_mixer-${SDL2_MIXER_VERSION}/mixer.h")
set(SDL2_MIXER_SRC_DOWNLOAD_URL "https://github.com/libsdl-org/SDL_mixer/archive/refs/tags/release-${SDL2_MIXER_VERSION}.zip")
set(SDL2_MIXER_SRC_DEP_FILENAME "SDL2_mixer-${SDL2_MIXER_VERSION}.zip")
set(SDL2_MIXER_SRC_UNPACK_DIR "SDL2_mixer-${SDL2_MIXER_VERSION}")
set(SDL2_MIXER_SRC_TMP_ZIP_PATH "${CMAKE_BINARY_DIR}/tmp/${SDL2_MIXER_SRC_DEP_FILENAME}")
if (NOT EXISTS "${SDL2_MIXER_SRC_CHECK_PATH}")
message("Download SDL2_mixer sources to ${SDL2_MIXER_SRC_TMP_ZIP_PATH}")
file(DOWNLOAD "${SDL2_MIXER_SRC_DOWNLOAD_URL}" "${SDL2_MIXER_SRC_TMP_ZIP_PATH}")
message("Unpack SDL2_mixer sources to ${CMAKE_BINARY_DIR}/tmp")
execute_process(COMMAND ${CMAKE_COMMAND} -E tar xzf ${SDL2_MIXER_SRC_TMP_ZIP_PATH} WORKING_DIRECTORY ${CMAKE_BINARY_DIR}/tmp)
message("Copy SDL2_mixer sources to ${SDL2_SRC_EXTRACT_PATH}")
file(RENAME ${CMAKE_BINARY_DIR}/tmp/SDL_mixer-release-${SDL2_MIXER_VERSION} ${CMAKE_BINARY_DIR}/tmp/SDL2_mixer-${SDL2_MIXER_VERSION})
file(COPY ${CMAKE_BINARY_DIR}/tmp/SDL2_mixer-${SDL2_MIXER_VERSION} DESTINATION ${SDL2_SRC_EXTRACT_PATH})
set(SDL2_MIXER_SRC_EXTRACT_PATH "${CMAKE_BINARY_DIR}/tmp/SDL2_mixer-${SDL2_MIXER_VERSION}")
file(COPY ${SDL2_MIXER_SRC_EXTRACT_PATH}/SDL_mixer.h DESTINATION ${SDL2_EXTRACT_PATH}/SDL2_mixer-${SDL2_MIXER_VERSION}/include)
endif()
endif()
if (PLATFORM_ANDROID)
set(PROJECT_VERSION_MAJOR 0)
set(PROJECT_VERSION_MINOR 2)
set(PROJECT_VERSION_PATCH 2)
set(IS_RELEASE_VERSION FALSE)
set(VERSION_REVISION "")
endif()
add_subdirectory(ext/png)
add_subdirectory(ext/expat)
add_subdirectory(ext/mujs)
add_subdirectory(ext/lame)
if (PLATFORM_ANDROID OR WIN_EMSCRIPTEN OR APPLE)
# no filters on android
else()
add_subdirectory(ext/gpupixel)
endif()
file(GLOB PLATFORM_FILES ${PROJECT_SOURCE_DIR}/src/platform/*.cpp)
file(GLOB CONFIG_FILES ${PROJECT_SOURCE_DIR}/src/config/*.cpp)
file(GLOB CONTENT_FILES ${PROJECT_SOURCE_DIR}/src/content/*.cpp)
file(GLOB CORE_FILES ${PROJECT_SOURCE_DIR}/src/core/*.cpp)
file(GLOB CORE_ENCODING_FILES ${PROJECT_SOURCE_DIR}/src/core/encoding/*.cpp)
file(GLOB BUILDING_FILES ${PROJECT_SOURCE_DIR}/src/building/*.cpp)
file(GLOB BUILDING_CONSTRUCTION_FILES ${PROJECT_SOURCE_DIR}/src/building/construction/*.cpp)
file(GLOB CITY_FILES ${PROJECT_SOURCE_DIR}/src/city/*.cpp)
file(GLOB EMPIRE_FILES ${PROJECT_SOURCE_DIR}/src/empire/*.cpp)
file(GLOB FIGURE_FILES ${PROJECT_SOURCE_DIR}/src/figure/*.cpp)
file(GLOB FIGURETYPE_FILES ${PROJECT_SOURCE_DIR}/src/figuretype/*.cpp)
file(GLOB GAME_FILES ${PROJECT_SOURCE_DIR}/src/game/*.cpp)
file(GLOB INPUT_FILES ${PROJECT_SOURCE_DIR}/src/input/*.cpp)
file(GLOB GRID_FILES ${PROJECT_SOURCE_DIR}/src/grid/*.cpp)
file(GLOB GRID_ROUTING_FILES ${PROJECT_SOURCE_DIR}/src/grid/routing/*.cpp)
file(GLOB SCENARIO_FILES ${PROJECT_SOURCE_DIR}/src/scenario/*.cpp)
file(GLOB GRAPHICS_ELEMENTS_FILES ${PROJECT_SOURCE_DIR}/src/graphics/elements/*.cpp)
file(GLOB GRAPHICS_VIEW_FILES ${PROJECT_SOURCE_DIR}/src/graphics/view/*.cpp)
file(GLOB SOUND_FILES ${PROJECT_SOURCE_DIR}/src/sound/*.cpp)
file(GLOB WIDGET_FILES ${PROJECT_SOURCE_DIR}/src/widget/*.cpp)
file(GLOB WIDGET_CITY_FILES ${PROJECT_SOURCE_DIR}/src/widget/city/*.cpp)
file(GLOB OVERLAYS_FILES ${PROJECT_SOURCE_DIR}/src/overlays/*.cpp)
file(GLOB WIDGET_SIDEBAR_FILES ${PROJECT_SOURCE_DIR}/src/widget/sidebar/*.cpp)
file(GLOB WINDOW_ADVISOR_FILES ${PROJECT_SOURCE_DIR}/src/window/advisor/*.cpp)
file(GLOB WINDOW_FILES ${PROJECT_SOURCE_DIR}/src/window/*.cpp)
file(GLOB WINDOW_EDITOR_FILES ${PROJECT_SOURCE_DIR}/src/window/editor/*.cpp)
file(GLOB WINDOW_BUILDING_FILES ${PROJECT_SOURCE_DIR}/src/window/building/*.cpp)
file(GLOB DEV_FILES ${PROJECT_SOURCE_DIR}/src/dev/*.cpp)
file(GLOB EDITOR_FILES ${PROJECT_SOURCE_DIR}/src/editor/*.cpp)
file(GLOB TRANSLATION_FILES ${PROJECT_SOURCE_DIR}/src/translation/*.cpp)
file(GLOB IMGUI_FILES ${PROJECT_SOURCE_DIR}/ext/imgui/*.cpp)
file(GLOB IMGUI_CPP_FILES ${PROJECT_SOURCE_DIR}/ext/imgui/misc/cpp/*.cpp)
file(GLOB IMGUI_BACKEND_FILES ${PROJECT_SOURCE_DIR}/ext/imgui/backends/*.cpp)
file(GLOB GRAPHICS_FILES ${PROJECT_SOURCE_DIR}/src/graphics/*.cpp)
file(GLOB IO_FILES ${PROJECT_SOURCE_DIR}/src/io/*.cpp)
file(GLOB IO_CONFIG_FILES ${PROJECT_SOURCE_DIR}/src/io/config/*.cpp)
file(GLOB IO_GAMEFILES_FILES ${PROJECT_SOURCE_DIR}/src/io/gamefiles/*.cpp)
file(GLOB IO_GAMESTATE_FILES ${PROJECT_SOURCE_DIR}/src/io/gamestate/*.cpp)
file(GLOB IO_IMAGEPAKS_FILES ${PROJECT_SOURCE_DIR}/src/io/imagepaks/*.cpp)
file(GLOB IO_PLAYERDATA_FILES ${PROJECT_SOURCE_DIR}/src/io/playerdata/*.cpp)
file(GLOB RESOURCE_FILES ${PROJECT_SOURCE_DIR}/src/resource/*.cpp)
file(GLOB JS_FILES ${PROJECT_SOURCE_DIR}/src/js/*.cpp)
file(GLOB SCRIPTS_FILES ${PROJECT_SOURCE_DIR}/src/scripts/*.cpp)
if (PLATFORM_ANDROID)
add_definitions(-DANDROID_BUILD=ON)
file(GLOB ANDROID_BACKEND_FILES ${PROJECT_SOURCE_DIR}/src/platform/android/*.cpp)
set(PLATFORM_FILES ${PLATFORM_FILES} ${ANDROID_BACKEND_FILES})
set(CMAKE_CXX_FLAGS "-Wno-format-security ${CMAKE_CXX_FLAGS}")
# set(SDL2_ANDROID_HOOK ${SDL_EXT_DIR}/src/main/android/SDL_android_main.c)
endif()
# Find revision ID and hash of the sourcetree
execute_process(
COMMAND git rev-list --count --all
WORKING_DIRECTORY "${CMAKE_SOURCE_DIR}"
OUTPUT_VARIABLE GAME_BUILD_NUMBER
OUTPUT_STRIP_TRAILING_WHITESPACE
ERROR_QUIET
)
add_definitions(-DGAME_BUILD_NUMBER=${GAME_BUILD_NUMBER})
message("GAME_BUILD_NUMBER now is ${GAME_BUILD_NUMBER}")
set(IMGUI_FILES ${IMGUI_FILES} ${IMGUI_CPP_FILES} ${IMGUI_BACKEND_FILES})
if(MSVC)
file(GLOB CORE_HEADERS ${PROJECT_SOURCE_DIR}/src/core/*.h)
file(GLOB IO_HEADERS ${PROJECT_SOURCE_DIR}/src/io/*.h)
file(GLOB PLATFORM_HEADERS ${PROJECT_SOURCE_DIR}/src/platform/*.h)
file(GLOB BUILDING_HEADERS ${PROJECT_SOURCE_DIR}/src/building/*.h)
file(GLOB BUILDING_CONSTRUCTION_HEADERS ${PROJECT_SOURCE_DIR}/src/building/construction/*.h)
file(GLOB CITY_HEADERS ${PROJECT_SOURCE_DIR}/src/city/*.h)
file(GLOB EMPIRE_HEADERS ${PROJECT_SOURCE_DIR}/src/empire/*.h)
file(GLOB FIGURE_HEADERS ${PROJECT_SOURCE_DIR}/src/figure/*.h)
file(GLOB FIGURETYPE_HEADERS ${PROJECT_SOURCE_DIR}/src/figuretype/*.h)
file(GLOB GAME_HEADERS ${PROJECT_SOURCE_DIR}/src/game/*.h)
file(GLOB INPUT_HEADERS ${PROJECT_SOURCE_DIR}/src/input/*.h)
file(GLOB GRID_HEADERS ${PROJECT_SOURCE_DIR}/src/grid/*.h)
file(GLOB GRID_ROUTING_HEADERS ${PROJECT_SOURCE_DIR}/src/grid/routing/*.h)
file(GLOB SCENARIO_HEADERS ${PROJECT_SOURCE_DIR}/src/scenario/*.h)
file(GLOB GRAPHICS_ELEMENTS_HEADERS ${PROJECT_SOURCE_DIR}/src/graphics/elements/*.h)
file(GLOB GRAPHICS_VIEW_HEADERS ${PROJECT_SOURCE_DIR}/src/graphics/view/*.h)
file(GLOB SOUND_HEADERS ${PROJECT_SOURCE_DIR}/src/sound/*.h)
file(GLOB WIDGET_HEADERS ${PROJECT_SOURCE_DIR}/src/widget/*.h)
file(GLOB WIDGET_CITY_HEADERS ${PROJECT_SOURCE_DIR}/src/widget/city/*.h)
file(GLOB OVERLAYS_HEADERS ${PROJECT_SOURCE_DIR}/src/overlays/*.h)
file(GLOB WIDGET_SIDEBAR_HEADERS ${PROJECT_SOURCE_DIR}/src/widget/sidebar/*.h)
file(GLOB WINDOW_ADVISOR_HEADERS ${PROJECT_SOURCE_DIR}/src/window/advisor/*.h)
file(GLOB WINDOW_HEADERS ${PROJECT_SOURCE_DIR}/src/window/*.h)
file(GLOB WINDOW_BUILDING_HEADERS ${PROJECT_SOURCE_DIR}/src/window/building/*.h)
file(GLOB DEV_HEADERS ${PROJECT_SOURCE_DIR}/src/dev/*.h)
file(GLOB EDITOR_HEADERS ${PROJECT_SOURCE_DIR}/src/editor/*.h)
file(GLOB TRANSLATION_HEADERS ${PROJECT_SOURCE_DIR}/src/translation/*.h)
file(GLOB IMGUI_HEADERS ${PROJECT_SOURCE_DIR}/ext/imgui/*.h)
file(GLOB IMGUI_BACKEND_HEADERS ${PROJECT_SOURCE_DIR}/ext/imgui/backends/*.h)
source_group("core" FILES ${CORE_FILES})
source_group("core/encoding" FILES ${CORE_ENCODING_FILES})
source_group("platform" FILES ${PLATFORM_FILES} )
source_group("building" FILES ${BUILDING_FILES})
source_group("building/construction" FILES ${BUILDING_CONSTRUCTION_FILES})
source_group("city" FILES ${CITY_FILES})
source_group("empire" FILES ${EMPIRE_FILES})
source_group("figure" FILES ${FIGURE_FILES})
source_group("figuretype" FILES ${FIGURETYPE_FILES})
source_group("game" FILES ${GAME_FILES})
source_group("input" FILES ${INPUT_FILES})
source_group("grid" FILES ${GRID_FILES})
source_group("grid/routing" FILES ${GRID_ROUTING_FILES})
source_group("scenario" FILES ${SCENARIO_FILES})
source_group("graphics/view" FILES ${GRAPHICS_VIEW_FILES})
source_group("graphics/elements" FILES ${GRAPHICS_ELEMENTS_FILES})
source_group("sound" FILES ${SOUND_FILES})
source_group("widgets" FILES ${WIDGET_FILES})
source_group("widgets/city" FILES ${WIDGET_CITY_FILES})
source_group("overlays" FILES ${OVERLAYS_FILES})
source_group("widgets/sidebar" FILES ${WIDGET_SIDEBAR_FILES})
source_group("window" FILES ${WINDOW_FILES})
source_group("window/advisors" FILES ${WINDOW_ADVISOR_FILES})
source_group("window/editor" FILES ${WINDOW_EDITOR_FILES})
source_group("window/building" FILES ${WINDOW_BUILDING_FILES})
source_group("advisor" FILES ${ADVISOR_FILES})
source_group("dev" FILES ${DEV_FILES})
source_group("editor" FILES ${EDITOR_FILES})
source_group("translation" FILES ${TRANSLATION_FILES})
source_group("imgui" FILES ${IMGUI_FILES})
source_group("io" FILES ${IO_FILES} {IO_HEADERS})
source_group("io/gamefiles" FILES ${IO_GAMEFILES_FILES})
source_group("content" FILES ${CONTENT_FILES})
source_group("config" FILES ${CONFIG_FILES})
source_group("resource" FILES ${RESOURCE_FILES} ${SCRIPTS_FILES})
source_group("graphics" FILES ${GRAPHICS_FILES})
source_group("js" FILES ${JS_FILES})
endif()
set(MACOSX_FILES "")
if(APPLE)
#set(RC_FILES ${PROJECT_SOURCE_DIR}/res/akhenaten.icns)
elseif(MSVC)
#set(RC_FILES ${PROJECT_SOURCE_DIR}/res/akhenaten.rc)
endif()
set(SOURCE_FILES
${PLATFORM_FILES}
${CONTENT_FILES}
${CONFIG_FILES}
${CORE_FILES} ${CORE_HEADERS}
${IO_FILES} ${IO_HEADERS}
${IO_CONFIG_FILES}
${IO_GAMEFILES_FILES}
${IO_GAMESTATE_FILES}
${IO_IMAGEPAKS_FILES}
${IO_PLAYERDATA_FILES}
${BUILDING_FILES}
${CITY_FILES}
${EMPIRE_FILES}
${FIGURE_FILES}
${FIGURETYPE_FILES}
${GAME_FILES}
${INPUT_FILES}
${GRID_FILES}
${SCENARIO_FILES}
${GRAPHICS_FILES}
${SOUND_FILES}
${WIDGET_FILES}
${WINDOW_FILES}
${DEV_FILES}
${EDITOR_FILES}
${TRANSLATION_FILES}
${ADVISOR_FILES}
${WINDOW_BUILDING_FILES}
${WINDOW_EDITOR_FILES}
${WINDOW_ADVISOR_FILES}
${WIDGET_SIDEBAR_FILES}
${OVERLAYS_FILES}
${WIDGET_CITY_FILES}
${GRAPHICS_VIEW_FILES}
${GRAPHICS_ELEMENTS_FILES}
${BUILDING_CONSTRUCTION_FILES}
${CORE_ENCODING_FILES}
${GRID_FILES}
${GRID_ROUTING_FILES}
${IMGUI_FILES}
${MACOSX_FILES}
${RC_FILES}
${TRACY_FILES}
${RESOURCE_FILES}
${JS_FILES}
${SCRIPTS_FILES}
)
set(SCRIPTS_FOLDER ${PROJECT_SOURCE_DIR}/src/scripts)
cmrc_add_resource_library(
resources
ALIAS akhenaten::rc
NAMESPACE akhenaten
${SCRIPTS_FOLDER}/building_info.js
${SCRIPTS_FOLDER}/building_menu.js
${SCRIPTS_FOLDER}/building_sounds.js
${SCRIPTS_FOLDER}/city_sounds.js
${SCRIPTS_FOLDER}/desirability.js
${SCRIPTS_FOLDER}/figures.js
${SCRIPTS_FOLDER}/imagepaks.js
${SCRIPTS_FOLDER}/images.js
${SCRIPTS_FOLDER}/images_remap.js
${SCRIPTS_FOLDER}/common.js
${SCRIPTS_FOLDER}/localization.js
${SCRIPTS_FOLDER}/math.js
${SCRIPTS_FOLDER}/mission_sounds.js
${SCRIPTS_FOLDER}/missions.js
${SCRIPTS_FOLDER}/modules.js
${SCRIPTS_FOLDER}/overlays.js
${SCRIPTS_FOLDER}/ui.js
${SCRIPTS_FOLDER}/walker_sounds.js
${PROJECT_SOURCE_DIR}/res/akhenaten_72.png
${PROJECT_SOURCE_DIR}/res/patreon_48.png
)
set_source_files_properties(${SOURCE_FILES} PROPERTIES LANGUAGE CXX)
if (PLATFORM_ANDROID)
find_package(SDL2 REQUIRED CONFIG)
set(SDL2_LIBRARY SDL2::SDL2)
set(SDL2_MIXER_LIBRARY SDL2::SDL2_mixer)
elseif (WIN_EMSCRIPTEN)
set(SDL2_LIBRARY "SDL2")
set(SDL2_INCLUDE_DIR "${EMSDK}/emscripten/system/include/SDL")
# set(SDL2_MIXER_LIBRARIES "${SDL2_EXTRACT_PATH}/lib/x64/SDL2_mixer.lib")
set(SDL2_MIXER_LIBRARY "SDL2_mixer")
# set(SDL2_MIXER_INCLUDE_DIRS "${SDL2_EXTRACT_PATH}/include")
set(SDL2_MIXER_INCLUDE_DIR "${EMSDK}/emscripten/system/include/SDL")
else()
find_package(SDL2 REQUIRED)
find_package(SDL2_mixer REQUIRED)
endif()
if (PLATFORM_ANDROID)
add_library(${GAME} SHARED ${SDL2_ANDROID_HOOK} ${SOURCE_FILES})
else()
add_executable(${GAME} WIN32 ${SOURCE_FILES})
endif()
if (MSVC)
add_compile_definitions(_CRT_SECURE_NO_WARNINGS)
endif()
if(APPLE)
# generating a macOS icns file (see https://stackoverflow.cppom/a/20703594)
add_custom_command(OUTPUT ${PROJECT_SOURCE_DIR}/res/akhenaten.icns
COMMAND mkdir -p akhenaten.iconset
COMMAND sips -z 16 16 akhenaten_256.png --out akhenaten.iconset/icon_16x16.png
COMMAND sips -z 32 32 akhenaten_256.png --out akhenaten.iconset/[email protected]
COMMAND sips -z 32 32 akhenaten_256.png --out akhenaten.iconset/icon_32x32.png
COMMAND sips -z 64 64 akhenaten_256.png --out akhenaten.iconset/[email protected]
COMMAND sips -z 128 128 akhenaten_256.png --out akhenaten.iconset/icon_128x128.png
COMMAND sips -z 256 256 akhenaten_256.png --out akhenaten.iconset/[email protected]
COMMAND sips -z 256 256 akhenaten_256.png --out akhenaten.iconset/icon_256x256.png
COMMAND iconutil -c icns akhenaten.iconset
COMMAND rm -R akhenaten.iconset
WORKING_DIRECTORY ${PROJECT_SOURCE_DIR}/res)
set_source_files_properties(${PROJECT_SOURCE_DIR}/res/akhenaten.icns PROPERTIES
MACOSX_PACKAGE_LOCATION "Resources")
# setting variables that will populate Info.plist
set(MACOSX_BUNDLE_GUI_IDENTIFIER "mt.dalerank.akhenaten")
set(MACOSX_BUNDLE_BUNDLE_NAME ${PROJECT_NAME})
set(CMAKE_OSX_DEPLOYMENT_TARGET "10.15" CACHE STRING "Minimum OS X deployment version" FORCE)
set(MACOSX_BUNDLE_ICON_FILE "akhenaten.icns")
set(MACOSX_BUNDLE_BUNDLE_VERSION "0.2.1 ${GAME_BUILD_NUMBER}")
set(MACOSX_BUNDLE_LONG_VERSION_STRING ${MACOSX_BUNDLE_BUNDLE_VERSION})
set(MACOSX_BUNDLE_SHORT_VERSION_STRING ${MACOSX_BUNDLE_BUNDLE_VERSION})
set_target_properties(${GAME} PROPERTIES
MACOSX_BUNDLE TRUE
MACOSX_BUNDLE_INFO_PLIST "${PROJECT_SOURCE_DIR}/res/Info.plist.in")
set(DIRS "")
# if SDL2 library is a framework, we need to indicate to CMake
# the path to its dependencies. SDL2_LIBRARY contains two parts.
# Example: /Library/Frameworks/SDL2.framework;-framework Cocoa
# So strip out everything after the ';'
string(REGEX REPLACE ";.*$" "" SDL2_LIB_DIR "${SDL2_LIBRARY}")
if(EXISTS "${SDL2_LIB_DIR}/Versions/A/Frameworks")
set(DIRS "${DIRS};${SDL2_LIB_DIR}/Versions/A/Frameworks")
endif()
# if SDL2_mixer library is a framework, we need to indicate to CMake
# the path to its dependencies (Ogg.framework etc):
if(EXISTS "${SDL2_MIXER_LIBRARY}/Versions/A/Frameworks")
set(DIRS "${DIRS};${SDL2_MIXER_LIBRARY}/Versions/A/Frameworks")
endif()
# when installing, "fixup" automatically copies librairies inside the
# bundle and links the binary against them
install(CODE "
include(BundleUtilities)
fixup_bundle(${CMAKE_BINARY_DIR}/${PROJECT_NAME}.app \"\" \"${DIRS}\")
" BUNDLE DESTINATION ${CMAKE_BINARY_DIR})
endif()
include_directories(${SDL2_INCLUDE_DIR})
include_directories(${SDL2_MIXER_INCLUDE_DIR})
include_directories(${EXTEXPAT_INCLUDE_DIR})
include_directories(${EXTPNG_INCLUDE_DIR})
include_directories(${EXTMUJS_INCLUDE_DIR})
include_directories(${CMRC_INCLUDE_DIR})
include_directories(${EXTLAME_INCLUDE_DIR})
if (PLATFORM_ANDROID OR WIN_EMSCRIPTEN OR APPLE)
# no filters on android
set(GPUPIXEL_LIBRARY "")
else()
include_directories(${GPUPIXEL_INCLUDE_DIR})
endif()
include_directories(ext)
include_directories(src)
include_directories(ext/imgui)
include_directories(ext/imgui/backends)
if(MSVC)
include_directories(ext/dirent)
include_directories(ext/ffmpeg/include)
set_target_properties(${GAME} PROPERTIES VS_DEBUGGER_WORKING_DIRECTORY "${GAME_WORKING_DIRECTORY}")
endif()
if (UNIX AND NOT APPLE AND (CMAKE_COMPILER_IS_GNUCC OR CMAKE_C_COMPILER_ID STREQUAL "Clang"))
target_link_libraries(${GAME} m)
endif()
target_link_libraries (${GAME}
${SDL2_LIBRARY} ${SDL2_MIXER_LIBRARY} ${EXTMUJS_LIBRARY}
${EXTEXPAT_LIBRARY} ${EXTPNG_LIBRARY} ${CPPTRACE_LIBRARY}
${EXTLAME_LIBRARY} ${GPUPIXEL_LIBRARY} akhenaten::rc)
if(MSVC)
target_link_libraries(${GAME} "winmm" "imagehlp" "shlwapi")
set(FFMPEG_LIB ${CMAKE_SOURCE_DIR}/ext/ffmpeg/lib)
target_link_libraries(${GAME} ${FFMPEG_LIB}/avcodec.lib)
target_link_libraries(${GAME} ${FFMPEG_LIB}/swscale.lib)
target_link_libraries(${GAME} ${FFMPEG_LIB}/avutil.lib)
target_link_libraries(${GAME} ${FFMPEG_LIB}/avformat.lib)
endif()
if (PLATFORM_ANDROID)
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -DPNG_ARM_NEON_OPT=0 -D_BSD_SOURCE")
find_library(log-lib log)
find_library(android-lib android)
target_link_libraries(${GAME} ${log-lib} ${android-lib})
endif()
if(NOT APPLE)
install(TARGETS ${GAME} RUNTIME DESTINATION bin)
endif()
if(UNIX AND NOT APPLE)
install(FILES "res/akhenaten.desktop" DESTINATION "share/applications" RENAME "com.github.dalerank.akhenaten.desktop")
install(FILES "res/akhenaten_256.png" DESTINATION "share/icons/hicolor/256x256/apps" RENAME "com.github.dalerank.akhenaten.png")
endif()
if (MSVC)
set(BINARY_FILES "${CMAKE_BINARY_DIR}/${GAME_BUILD_TYPE}/${GAME}.exe")
foreach( file_i ${BINARY_FILES})
add_custom_command(
TARGET ${GAME}
POST_BUILD
COMMAND ${CMAKE_COMMAND}
ARGS -E copy ${file_i} "${GAME_WORKING_DIRECTORY}"
)
endforeach( file_i )
endif()