Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
rubberduckycooly
GitHub Repository: rubberduckycooly/Sonic-Mania-Decompilation
Path: blob/master/CMakeLists.txt
338 views
1
cmake_minimum_required(VERSION 3.13)
2
project(SonicMania)
3
4
option(WITH_RSDK "Whether or not to build with RSDKv5. Defaults to true" ON)
5
6
if(NOT DEFINED GAME_STATIC)
7
if(WIN32)
8
set(GAME_STATIC OFF)
9
elseif(UNIX)
10
set(GAME_STATIC OFF)
11
else()
12
set(GAME_STATIC ON)
13
endif()
14
endif()
15
16
option(GAME_STATIC "Whether or not to build the game as a static library." $<BOOL:$<IF:WITH_RSDK,ON,OFF>>)
17
18
option(MANIA_FIRST_RELEASE "Whether or not to build Mania's first release. Defaults to false" OFF)
19
if(MANIA_FIRST_RELEASE)
20
set(MANIA_PREPLUS ON)
21
else()
22
option(MANIA_PREPLUS "Whether or not to build Mania pre-plus. Defaults to false" OFF)
23
endif()
24
25
26
if(NOT MANIA_PREPLUS)
27
set(GAME_VERSION 6 CACHE STRING "The game version to use. Defaults to 6 == Last Steam release")
28
else()
29
set(GAME_VERSION 3 CACHE STRING "The game version to use. Defaults to 3 == Last pre-plus release")
30
endif()
31
32
set(GAME_NAME "SonicMania" CACHE STRING "The game directory to look into")
33
set(GAME_OUTPUT_NAME "Game" CACHE STRING "The name of the built library")
34
35
option(GAME_INCLUDE_EDITOR "Whether or not to include editor functions. Defaults to true" ON)
36
37
option(GAME_INCREMENTAL_BUILD "Whether or not to build all objects separately (for quicker dev-->build iterations). Defaults to false." OFF)
38
39
if(GAME_INCREMENTAL_BUILD)
40
include(${GAME_NAME}/Objects.cmake)
41
set(GAME_SOURCES
42
${GAME_NAME}/Game.c
43
${GENERATED_SOURCES}
44
)
45
else()
46
set(GAME_SOURCES
47
${GAME_NAME}/Game.c
48
${GAME_NAME}/Objects/All.c
49
)
50
endif()
51
52
if(GAME_STATIC)
53
add_library(${GAME_NAME} STATIC ${GAME_SOURCES})
54
else()
55
add_library(${GAME_NAME} SHARED ${GAME_SOURCES})
56
endif()
57
58
target_include_directories(${GAME_NAME} PRIVATE
59
${GAME_NAME}/
60
${GAME_NAME}/Objects/
61
)
62
63
if(WIN32)
64
target_compile_definitions(${GAME_NAME} PRIVATE _CRT_SECURE_NO_WARNINGS)
65
endif()
66
67
set_target_properties(${GAME_NAME} PROPERTIES OUTPUT_NAME ${GAME_OUTPUT_NAME})
68
69
if(WITH_RSDK)
70
set(RSDK_PATH dependencies/RSDKv5 CACHE STRING "The path to look for RSDKv5 if using WITH_RSDK.")
71
72
add_subdirectory(${RSDK_PATH})
73
74
if(GAME_STATIC)
75
target_include_directories(RetroEngine PRIVATE ${GAME_NAME}/)
76
target_link_libraries(RetroEngine ${GAME_NAME})
77
endif()
78
else()
79
set(RETRO_REVISION 3 CACHE STRING "What revision to compile for. Defaults to v5U = 3")
80
81
option(RETRO_MOD_LOADER "Enables or disables the mod loader." ON)
82
set(RETRO_MOD_LOADER_VER 2 CACHE STRING "Sets the mod loader version. Defaults to latest")
83
84
target_compile_definitions(${GAME_NAME} PRIVATE
85
RETRO_REVISION=${RETRO_REVISION}
86
87
RETRO_USE_MOD_LOADER=$<BOOL:${RETRO_MOD_LOADER}>
88
RETRO_MOD_LOADER_VER=${RETRO_MOD_LOADER_VER}
89
90
GAME_INCLUDE_EDITOR=$<BOOL:${GAME_INCLUDE_EDITOR}>
91
92
MANIA_PREPLUS=$<BOOL:${MANIA_PREPLUS}>
93
MANIA_FIRST_RELEASE=$<BOOL:${MANIA_FIRST_RELEASE}>
94
GAME_VERSION=${GAME_VERSION}
95
)
96
endif()
97
98
# MSVC likes to merge similar functions together even though their addresses are being referenced.
99
# Disable COMDAT folding to fix some bugs like not drowning when suspended to a pull chain in HCZ.
100
if(MSVC)
101
target_link_options(${GAME_NAME} PRIVATE /OPT:NOICF)
102
endif()
103
104