-
Notifications
You must be signed in to change notification settings - Fork 46
/
Copy pathCMakeLists.txt
594 lines (546 loc) · 19.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
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
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
cmake_minimum_required(VERSION 3.16.0 FATAL_ERROR)
# Set the project version and language
project(Starship VERSION 0.1.0 LANGUAGES C CXX ASM)
if(APPLE)
enable_language(OBJCXX)
endif()
# Set the minimum version of CMake and the deployment target for macOS
set(CMAKE_OSX_DEPLOYMENT_TARGET "10.15" CACHE STRING "Minimum OS X deployment version")
# Set the C++ standard and enable the MSVC parallel build option
set(CMAKE_CXX_STANDARD 20 CACHE STRING "The C++ standard to use")
set(CMAKE_C_STANDARD 11 CACHE STRING "The C standard to use")
#add_compile_options(-fsanitize=address)
#add_link_options(-fsanitize=address)
# Add a custom module path to locate additional CMake modules
set(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} "${CMAKE_SOURCE_DIR}/cmake/modules/")
if (WIN32)
include(cmake/automate-vcpkg.cmake)
set(VCPKG_TRIPLET x64-windows-static)
set(VCPKG_TARGET_TRIPLET x64-windows-static)
vcpkg_bootstrap()
vcpkg_install_packages(zlib bzip2 libzip libpng sdl2 glew glfw3 nlohmann-json tinyxml2 spdlog)
endif()
if (MSVC)
set(CPP "${CMAKE_C_COMPILER}" "/EP")
else()
set(CPP "${CMAKE_C_COMPILER}" "-E" "-P" "-Wno-trigraphs" "-x" "c")
endif()
if(IOS)
set(PLATFORM "OS64")
include(cmake/ios.toolchain.cmake)
add_compile_definitions(
PLATFORM_IOS=1
)
set(CMAKE_XCODE_ATTRIBUTE_DEVELOPMENT_TEAM "YOUR_TEAM_ID")
set(PROJECT_ID "dev.net64.game")
endif()
################################################################################
# Set target arch type if empty. Visual studio solution generator provides it.
################################################################################
if (CMAKE_SYSTEM_NAME STREQUAL "Windows")
if(NOT CMAKE_VS_PLATFORM_NAME)
set(CMAKE_VS_PLATFORM_NAME "x64")
endif()
message("${CMAKE_VS_PLATFORM_NAME} architecture in use")
if(NOT ("${CMAKE_VS_PLATFORM_NAME}" STREQUAL "x64"
OR "${CMAKE_VS_PLATFORM_NAME}" STREQUAL "Win32"))
message(FATAL_ERROR "${CMAKE_VS_PLATFORM_NAME} arch is not supported!")
endif()
endif()
# Set game compilation version
set(VERSION us)
set(USE_NETWORKING OFF)
set(SKIP_XCODE_VERSION_CHECK ON)
# Add compile definitions for the target
add_compile_definitions(
VERSION_US=1
ENABLE_RUMBLE=1
F3DEX_GBI=1
_LANGUAGE_C
_USE_MATH_DEFINES
CIMGUI_DEFINE_ENUMS_AND_STRUCTS
NON_MATCHING=1
NON_EQUIVALENT=1
AVOID_UB=1
)
# Find necessary libraries
if (UNIX AND NOT APPLE)
find_package(OpenGL REQUIRED)
endif()
# Include directories
include_directories(
${CMAKE_CURRENT_SOURCE_DIR}
${CMAKE_CURRENT_SOURCE_DIR}/include
${CMAKE_CURRENT_SOURCE_DIR}/src
)
# Collect source files to build the executable
file(GLOB_RECURSE ALL_FILES RELATIVE ${CMAKE_CURRENT_SOURCE_DIR}
# "src/assets/*.c"
"src/audio/*.c"
"src/audio/*.h"
"src/engine/*.c"
"src/engine/*.h"
"src/libultra/io/aisetfreq.c"
"src/libultra/gu/sqrtf.c"
"src/libultra/gu/mtxutil.c"
"src/libultra/gu/ortho.c"
"src/overlays/*.c"
"src/overlays/*.h"
"src/port/*.h"
"src/port/*.c"
"src/port/*.cpp"
"src/sys/*.c"
"src/sys/*.h"
"src/1FA60.c"
"src/buffers.c"
"src/dmatable.c"
"src/libc_math64.c"
"src/libc_sprintf.c"
)
# Exclude specific files from the ALL_FILES list
list(FILTER ALL_FILES EXCLUDE REGEX ".*.inc.c")
list(FILTER ALL_FILES EXCLUDE REGEX "src/engine/fox_colheaders.c")
list(FILTER ALL_FILES EXCLUDE REGEX "src/engine/fox_edata_info.c")
list(FILTER ALL_FILES EXCLUDE REGEX "src/engine/fox_rcp_setup.c")
list(FILTER ALL_FILES EXCLUDE REGEX "src/engine/fox_load_inits.c")
list(FILTER ALL_FILES EXCLUDE REGEX "src/overlays/ovl_ending/fox_end2_data.c")
list(FILTER ALL_FILES EXCLUDE REGEX "src/sys/sys_timer.c")
list(FILTER ALL_FILES EXCLUDE REGEX "src/sys/sys_fault.c")
list(FILTER ALL_FILES EXCLUDE REGEX "src/mods/object_ram.c")
if (CMAKE_SYSTEM_NAME STREQUAL "iOS")
set(IOS_DIR ${CMAKE_CURRENT_SOURCE_DIR}/libultraship/ios)
set(STORYBOARD_FILE ${IOS_DIR}/Launch.storyboard)
set(IMAGE_FILES ${IOS_DIR}/PoweredBy.png)
set(ICON_FILES ${IOS_DIR}/Icon.png)
list(APPEND ALL_FILES ${STORYBOARD_FILE} ${IMAGE_FILES} ${ICON_FILES})
add_executable(${PROJECT_NAME} ${ALL_FILES})
set_xcode_property(${PROJECT_NAME} PRODUCT_BUNDLE_IDENTIFIER ${PROJECT_ID} All)
set_target_properties(
${PROJECT_NAME}
PROPERTIES
MACOSX_BUNDLE TRUE
MACOSX_BUNDLE_INFO_PLIST ${IOS_DIR}/plist.in
RESOURCE "${IMAGE_FILES};${STORYBOARD_FILE};${ICON_FILES}"
)
else()
add_executable(${PROJECT_NAME} ${ALL_FILES})
endif()
################################################################################
# MSVC runtime library
################################################################################
if (MSVC)
if (CMAKE_SYSTEM_NAME STREQUAL "Windows")
get_property(MSVC_RUNTIME_LIBRARY_DEFAULT TARGET ${PROJECT_NAME} PROPERTY MSVC_RUNTIME_LIBRARY)
if("${CMAKE_VS_PLATFORM_NAME}" STREQUAL "x64")
string(CONCAT "MSVC_RUNTIME_LIBRARY_STR"
$<$<CONFIG:Debug>:
MultiThreadedDebug
>
$<$<CONFIG:Release>:
MultiThreaded
>
$<$<NOT:$<OR:$<CONFIG:Debug>,$<CONFIG:Release>>>:${MSVC_RUNTIME_LIBRARY_DEFAULT}>
)
elseif("${CMAKE_VS_PLATFORM_NAME}" STREQUAL "Win32")
string(CONCAT "MSVC_RUNTIME_LIBRARY_STR"
$<$<CONFIG:Debug>:
MultiThreadedDebug
>
$<$<CONFIG:Release>:
MultiThreaded
>
$<$<NOT:$<OR:$<CONFIG:Debug>,$<CONFIG:Release>>>:${MSVC_RUNTIME_LIBRARY_DEFAULT}>
)
endif()
set_target_properties(${PROJECT_NAME} PROPERTIES MSVC_RUNTIME_LIBRARY ${MSVC_RUNTIME_LIBRARY_STR})
endif()
endif()
#==============================================================================#
# Libultraship Integration #
#==============================================================================#
include_directories(
${CMAKE_CURRENT_SOURCE_DIR}
${CMAKE_CURRENT_SOURCE_DIR}/src
${CMAKE_CURRENT_BINARY_DIR}
${CMAKE_CURRENT_SOURCE_DIR}/libultraship/include
${CMAKE_CURRENT_SOURCE_DIR}/libultraship/include/libultraship
${CMAKE_CURRENT_SOURCE_DIR}/libultraship/src
${CMAKE_CURRENT_SOURCE_DIR}/libultraship/src/log
${CMAKE_CURRENT_SOURCE_DIR}/libultraship/src/debug
${CMAKE_CURRENT_SOURCE_DIR}/libultraship/src/menu
${CMAKE_CURRENT_SOURCE_DIR}/libultraship/src/utils
${CMAKE_CURRENT_SOURCE_DIR}/libultraship/src/utils/binarytools
${CMAKE_CURRENT_SOURCE_DIR}/libultraship/src/config
${CMAKE_CURRENT_SOURCE_DIR}/libultraship/src/resource
${CMAKE_CURRENT_SOURCE_DIR}/libultraship/src/resource/type
${CMAKE_CURRENT_SOURCE_DIR}/libultraship/src/resource/factory
${CMAKE_CURRENT_SOURCE_DIR}/libultraship/src/audio
${CMAKE_CURRENT_SOURCE_DIR}/libultraship/src/window
${CMAKE_CURRENT_SOURCE_DIR}/libultraship/src/window/gui
${CMAKE_CURRENT_SOURCE_DIR}/libultraship/src/config
${CMAKE_CURRENT_SOURCE_DIR}/libultraship/src/public
${CMAKE_CURRENT_SOURCE_DIR}/libultraship/src/public/libultra
${CMAKE_CURRENT_SOURCE_DIR}/libultraship/src/public/bridge
${CMAKE_CURRENT_SOURCE_DIR}/libultraship/extern
${CMAKE_CURRENT_SOURCE_DIR}/libultraship/extern/tinyxml2
${CMAKE_CURRENT_SOURCE_DIR}/libultraship/libultraship/Lib/
${CMAKE_CURRENT_SOURCE_DIR}/libultraship/libultraship/Lib/libjpeg/include/
${CMAKE_CURRENT_SOURCE_DIR}/libultraship/libultraship/Lib/spdlog/include/
${CMAKE_CURRENT_SOURCE_DIR}/libultraship/src/graphic/Fast3D/U64/PR
${CMAKE_CURRENT_SOURCE_DIR}/libultraship/src/graphic
${SDL2_INCLUDE_DIRS}
${GLEW_INCLUDE_DIRS}
)
add_subdirectory(libultraship ${CMAKE_CURRENT_SOURCE_DIR}/libultraship)
add_dependencies(${PROJECT_NAME} libultraship)
target_link_libraries(${PROJECT_NAME} PRIVATE libultraship)
if (CMAKE_SYSTEM_NAME STREQUAL "Windows")
if("${CMAKE_VS_PLATFORM_NAME}" STREQUAL "x64")
target_compile_definitions(${PROJECT_NAME} PRIVATE
"$<$<CONFIG:Debug>:"
"_DEBUG;"
"_CRT_SECURE_NO_WARNINGS;"
"ENABLE_DX11;"
">"
"$<$<CONFIG:Release>:"
"NDEBUG"
">"
"INCLUDE_GAME_PRINTF;"
"UNICODE;"
"_UNICODE"
STORMLIB_NO_AUTO_LINK
"_CRT_SECURE_NO_WARNINGS;"
"_SILENCE_ALL_MS_EXT_DEPRECATION_WARNINGS;"
)
elseif("${CMAKE_VS_PLATFORM_NAME}" STREQUAL "Win32")
target_compile_definitions(${PROJECT_NAME} PRIVATE
"$<$<CONFIG:Debug>:"
"NOINCLUDE_GAME_PRINTF;"
"_DEBUG;"
"_CRT_SECURE_NO_WARNINGS;"
"ENABLE_OPENGL"
">"
"$<$<CONFIG:Release>:"
"NDEBUG;"
">"
"INCLUDE_GAME_PRINTF;"
"WIN32;"
"UNICODE;"
"_UNICODE"
STORMLIB_NO_AUTO_LINK
"_SILENCE_ALL_MS_EXT_DEPRECATION_WARNINGS;"
)
endif()
elseif (CMAKE_SYSTEM_NAME STREQUAL "CafeOS")
target_compile_definitions(${PROJECT_NAME} PRIVATE
"$<$<CONFIG:Debug>:"
"_DEBUG"
">"
"$<$<CONFIG:Release>:"
"NDEBUG"
">"
"SPDLOG_ACTIVE_LEVEL=3;"
"SPDLOG_NO_THREAD_ID;"
"SPDLOG_NO_TLS;"
"STBI_NO_THREAD_LOCALS;"
)
elseif ("${CMAKE_CXX_COMPILER_ID}" MATCHES "GNU|Clang|AppleClang")
target_compile_definitions(${PROJECT_NAME} PRIVATE
"$<$<CONFIG:Debug>:"
"_DEBUG"
">"
"$<$<CONFIG:Release>:"
"NDEBUG"
">"
"$<$<BOOL:${BUILD_CROWD_CONTROL}>:ENABLE_CROWD_CONTROL>"
"SPDLOG_ACTIVE_LEVEL=0;"
"_CONSOLE;"
"_CRT_SECURE_NO_WARNINGS;"
"UNICODE;"
"_UNICODE"
)
endif()
if (CMAKE_SYSTEM_NAME STREQUAL "Windows")
set(ADDITIONAL_LIBRARY_DEPENDENCIES
"$<$<BOOL:${USE_NETWORKING}>:SDL2_net::SDL2_net-static>"
)
elseif(CMAKE_SYSTEM_NAME STREQUAL "NintendoSwitch")
set(ADDITIONAL_LIBRARY_DEPENDENCIES
-lglad
)
elseif(CMAKE_SYSTEM_NAME STREQUAL "CafeOS")
set(ADDITIONAL_LIBRARY_DEPENDENCIES
"$<$<CONFIG:Debug>:-Wl,--wrap=abort>"
)
target_include_directories(${PROJECT_NAME} PRIVATE
${DEVKITPRO}/portlibs/wiiu/include/
)
else()
set(ADDITIONAL_LIBRARY_DEPENDENCIES
"$<$<BOOL:${USE_NETWORKING}>:SDL2_net::SDL2_net>"
)
endif()
if(USE_NETWORKING)
if(MSVC)
vcpkg_install_packages(sdl2-net)
endif()
find_package(SDL2_net REQUIRED)
include_directories(${SDL2_NET_INCLUDE_DIRS})
target_link_libraries(${PROJECT_NAME} PRIVATE SDL2_net::SDL2_net)
target_compile_definitions(${PROJECT_NAME} PRIVATE USE_NETWORKING)
endif()
target_link_libraries(${PROJECT_NAME} PRIVATE "${ADDITIONAL_LIBRARY_DEPENDENCIES}")
if(CMAKE_SYSTEM_NAME MATCHES "NintendoSwitch")
nx_generate_nacp(Lylat.nacp
NAME "${PROJECT_NAME}"
AUTHOR "${PROJECT_TEAM}"
VERSION "${PROJECT_VERSION_MAJOR}.${PROJECT_VERSION_MINOR}.${PROJECT_VERSION_PATCH}"
)
nx_create_nro(${PROJECT_NAME}
NACP Lylat.nacp
)
INSTALL(FILES ${CMAKE_CURRENT_BINARY_DIR}/${PROJECT_NAME}.nro DESTINATION . COMPONENT ${PROJECT_NAME})
endif()
################################################################################
# Compile and link options
################################################################################
if(MSVC)
if("${CMAKE_VS_PLATFORM_NAME}" STREQUAL "x64")
target_compile_options(${PROJECT_NAME} PRIVATE
$<$<CONFIG:Debug>:
/w;
/Od;
/MTd
>
$<$<CONFIG:Release>:
/Oi;
/Gy;
/W3;
/MT
>
/permissive-;
/MP;
${DEFAULT_CXX_DEBUG_INFORMATION_FORMAT};
${DEFAULT_CXX_EXCEPTION_HANDLING}
)
target_compile_options(${PROJECT_NAME} PRIVATE $<$<CONFIG:Debug>:/ZI;>)
target_compile_options(${PROJECT_NAME} PRIVATE $<$<CONFIG:Release>:/Zi;>)
elseif("${CMAKE_VS_PLATFORM_NAME}" STREQUAL "Win32")
target_compile_options(${PROJECT_NAME} PRIVATE
$<$<CONFIG:Debug>:
/MTd
>
$<$<CONFIG:Release>:
/O2;
/Oi;
/Gy;
/MT
>
/permissive-;
/MP;
/w;
${DEFAULT_CXX_DEBUG_INFORMATION_FORMAT};
${DEFAULT_CXX_EXCEPTION_HANDLING}
)
endif()
if("${CMAKE_VS_PLATFORM_NAME}" STREQUAL "x64")
target_link_options(${PROJECT_NAME} PRIVATE
$<$<CONFIG:Debug>:
/INCREMENTAL
>
$<$<CONFIG:Release>:
/OPT:REF;
/OPT:ICF;
/INCREMENTAL:NO;
/FORCE:MULTIPLE
>
/MANIFEST:NO;
/DEBUG;
/SUBSYSTEM:WINDOWS
)
elseif("${CMAKE_VS_PLATFORM_NAME}" STREQUAL "Win32")
target_link_options(${PROJECT_NAME} PRIVATE
$<$<CONFIG:Debug>:
/STACK:8777216
>
$<$<CONFIG:Release>:
/OPT:REF;
/OPT:ICF;
/INCREMENTAL:NO;
/FORCE:MULTIPLE
>
/MANIFEST:NO;
/DEBUG;
/SUBSYSTEM:WINDOWS
)
endif()
# Remove /RTC from msvc flags
foreach (fentry
CMAKE_C_FLAGS
CMAKE_CXX_FLAGS
)
string (REGEX REPLACE "/RTC(su|[1su])" "" ${fentry} "${${fentry}}")
endforeach(fentry)
endif()
if (CMAKE_CXX_COMPILER_ID MATCHES "GNU|Clang|AppleClang")
if (CMAKE_SYSTEM_NAME STREQUAL "Darwin" OR CMAKE_SYSTEM_NAME STREQUAL "iOS")
target_compile_options(${PROJECT_NAME} PRIVATE
-Wall -Wextra -Wno-error
-Wno-return-type
-Wno-unused-parameter
-Wno-unused-function
-Wno-unused-variable
-Wno-missing-field-initializers
-Wno-parentheses
-Wno-narrowing
-Wno-missing-braces
-Wno-int-conversion
$<$<COMPILE_LANGUAGE:C>:
-Werror-implicit-function-declaration
-Wno-incompatible-pointer-types
-fpermissive
>
$<$<COMPILE_LANGUAGE:CXX>:-fpermissive>
$<$<COMPILE_LANGUAGE:CXX>:
-Wno-c++11-narrowing
-Wno-deprecated-enum-enum-conversion
>
-pthread
)
target_link_options(${PROJECT_NAME} PRIVATE
-pthread
)
elseif (CMAKE_SYSTEM_NAME STREQUAL "NintendoSwitch")
target_compile_options(${PROJECT_NAME} PRIVATE
-Wall -Wextra -Wno-error
-Wno-return-type
-Wno-unused-parameter
-Wno-unused-function
-Wno-unused-variable
-Wno-missing-field-initializers
-Wno-parentheses
-Wno-narrowing
-Wno-missing-braces
-Wno-int-conversion
$<$<COMPILE_LANGUAGE:C>:
-Werror-implicit-function-declaration
-Wno-incompatible-pointer-types
-fpermissive
>
$<$<COMPILE_LANGUAGE:CXX>:-fpermissive>
$<$<COMPILE_LANGUAGE:CXX>:
-Wno-c++11-narrowing
-Wno-deprecated-enum-enum-conversion
>
-pthread
)
target_link_options(${PROJECT_NAME} PRIVATE
-pthread
)
elseif (CMAKE_SYSTEM_NAME STREQUAL "CafeOS")
target_compile_options(${PROJECT_NAME} PRIVATE
-O2
# disable some warnings to not clutter output
-Wno-multichar
-Wno-return-type
-Wno-narrowing
-Wno-switch-outside-range
$<$<COMPILE_LANGUAGE:C>:
-Werror-implicit-function-declaration
-Wno-incompatible-pointer-types
-Wno-discarded-array-qualifiers
-Wno-discarded-qualifiers
-Wno-int-conversion
-Wno-builtin-declaration-mismatch
-Wno-switch-unreachable
-Wno-stringop-overflow
>
)
else()
if(CMAKE_SYSTEM_PROCESSOR MATCHES "x86_64")
set(CPU_OPTION -msse2 -mfpmath=sse)
endif()
target_compile_options(${PROJECT_NAME} PRIVATE
-Wall -Wextra -Wno-error
-Wno-unused-parameter
-Wno-unused-function
-Wno-unused-variable
-Wno-missing-field-initializers
-Wno-parentheses
-Wno-narrowing
-Wno-missing-braces
-Wno-int-conversion
$<$<COMPILE_LANGUAGE:C>:
-Werror-implicit-function-declaration
-Wno-incompatible-pointer-types
-fpermissive
>
$<$<COMPILE_LANGUAGE:CXX>:-fpermissive>
$<$<COMPILE_LANGUAGE:CXX>:-Wno-deprecated-enum-enum-conversion>
-pthread
${CPU_OPTION}
)
target_link_options(${PROJECT_NAME} PRIVATE
-pthread
-Wl,-export-dynamic
)
endif()
endif()
include(ExternalProject)
ExternalProject_Add(torch
PREFIX torch
SOURCE_DIR ${CMAKE_SOURCE_DIR}/tools/Torch
CMAKE_ARGS -DCMAKE_INSTALL_PREFIX=${CMAKE_BINARY_DIR}/Torch
)
ExternalProject_Get_Property(torch install_dir)
if (MSVC)
set(TORCH_EXECUTABLE ${install_dir}/src/torch-build/$<CONFIGURATION>/torch)
else()
set(TORCH_EXECUTABLE ${install_dir}/src/torch-build/torch)
endif()
add_custom_target(
ExtractAssets
DEPENDS torch
WORKING_DIRECTORY ${CMAKE_SOURCE_DIR}
COMMAND ${TORCH_EXECUTABLE} otr baserom.z64
COMMAND ${CMAKE_COMMAND} -E copy_if_different "${CMAKE_SOURCE_DIR}/sf64.otr" "${CMAKE_BINARY_DIR}/sf64.otr"
)
add_custom_target(
GeneratePortOTR
DEPENDS torch
WORKING_DIRECTORY ${CMAKE_SOURCE_DIR}
COMMAND ${TORCH_EXECUTABLE} pack port starship.otr
COMMAND ${CMAKE_COMMAND} -E copy_if_different "${CMAKE_SOURCE_DIR}/starship.otr" "${CMAKE_BINARY_DIR}/starship.otr"
)
if(CMAKE_SYSTEM_NAME MATCHES "Darwin")
add_custom_target(CreateOSXIcons
COMMAND mkdir -p ${CMAKE_BINARY_DIR}/macosx/starship.iconset
COMMAND sips -z 16 16 logo.png --out ${CMAKE_BINARY_DIR}/macosx/starship.iconset/icon_16x16.png
COMMAND sips -z 32 32 logo.png --out ${CMAKE_BINARY_DIR}/macosx/starship.iconset/[email protected]
COMMAND sips -z 32 32 logo.png --out ${CMAKE_BINARY_DIR}/macosx/starship.iconset/icon_32x32.png
COMMAND sips -z 64 64 logo.png --out ${CMAKE_BINARY_DIR}/macosx/starship.iconset/[email protected]
COMMAND sips -z 128 128 logo.png --out ${CMAKE_BINARY_DIR}/macosx/starship.iconset/icon_128x128.png
COMMAND sips -z 256 256 logo.png --out ${CMAKE_BINARY_DIR}/macosx/starship.iconset/[email protected]
COMMAND sips -z 256 256 logo.png --out ${CMAKE_BINARY_DIR}/macosx/starship.iconset/icon_256x256.png
COMMAND sips -z 512 512 logo.png --out ${CMAKE_BINARY_DIR}/macosx/starship.iconset/[email protected]
COMMAND sips -z 512 512 logo.png --out ${CMAKE_BINARY_DIR}/macosx/starship.iconset/icon_512x512.png
COMMAND cp logo.png ${CMAKE_BINARY_DIR}/macosx/starship.iconset/[email protected]
COMMAND iconutil -c icns -o ${CMAKE_BINARY_DIR}/macosx/starship.icns ${CMAKE_BINARY_DIR}/macosx/starship.iconset
WORKING_DIRECTORY ${CMAKE_SOURCE_DIR}
COMMENT "Creating OSX icons ..."
)
add_dependencies(${PROJECT_NAME} CreateOSXIcons)
configure_file("${CMAKE_SOURCE_DIR}/Info.plist" "${CMAKE_BINARY_DIR}/Info.plist" COPYONLY)
endif()
set_property(TARGET ${PROJECT_NAME} PROPERTY APPIMAGE_DESKTOP_FILE_TERMINAL YES)
set_property(TARGET ${PROJECT_NAME} PROPERTY APPIMAGE_DESKTOP_FILE "${CMAKE_SOURCE_DIR}/Starship.desktop")
set_property(TARGET ${PROJECT_NAME} PROPERTY APPIMAGE_ICON_FILE "${CMAKE_SOURCE_DIR}/logo.png")
if(CMAKE_SYSTEM_NAME MATCHES "Linux")
set(CPACK_GENERATOR "External")
elseif(CMAKE_SYSTEM_NAME MATCHES "Windows|NintendoSwitch|CafeOS")
set(CPACK_GENERATOR "ZIP")
elseif(CMAKE_SYSTEM_NAME MATCHES "Darwin")
set(CPACK_GENERATOR "Bundle")
endif()
set(CPACK_PROJECT_CONFIG_FILE ${CMAKE_SOURCE_DIR}/cmake/configure-packaging.cmake)
include(cmake/packaging.cmake)