-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathCMakeLists.txt
202 lines (179 loc) · 5.6 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
cmake_minimum_required(VERSION 3.28)
project(BlockSmashies VERSION 0.1)
set(CMAKE_C_STANDARD 17)
set(CMAKE_C_STANDARD_REQUIRED ON)
# Ensure static linking with MSVC
if (MSVC)
set(CMAKE_MSVC_RUNTIME_LIBRARY "MultiThreaded$<$<CONFIG:Debug>:Debug>") # Static runtime for Debug and Release
endif()
if (WIN32)
set(CMAKE_EXE_LINKER_FLAGS_RELEASE "${CMAKE_EXE_LINKER_FLAGS_RELEASE} /SUBSYSTEM:WINDOWS /ENTRY:mainCRTStartup")
endif()
# Third-party subdirectories
add_subdirectory(external/raylib)
add_subdirectory(external/parson)
add_subdirectory(external/box2d)
# Include directories
include_directories(
${PROJECT_SOURCE_DIR}/include/entities/ship
${PROJECT_SOURCE_DIR}/include/core
${PROJECT_SOURCE_DIR}/include/collisions
${PROJECT_SOURCE_DIR}/include/entities
${PROJECT_SOURCE_DIR}/include/mappings
${PROJECT_SOURCE_DIR}/include/scenes
${PROJECT_SOURCE_DIR}/include/game_states
${PROJECT_SOURCE_DIR}/include/game
${PROJECT_SOURCE_DIR}/include/input
${PROJECT_SOURCE_DIR}/external/parson
${PROJECT_SOURCE_DIR}/external/uthash/src
${PROJECT_SOURCE_DIR}/external/klib
${PROJECT_SOURCE_DIR}/external/box2d/include
${PROJECT_SOURCE_DIR}/external/uuid4/src
)
# Source files for the core module
set(CORE_SRC
src/core/main.c
src/core/settings.c
src/core/resource_manager.c
src/core/animation_handler.c
src/core/game.c
src/core/b_utils.c
)
set(EXTERNAL_SRC
external/uuid4/src/uuid4.c
)
set(COLLISIONS_SRC
src/collisions/collision_manager.c
src/collisions/ball_brick_collision.c
src/collisions/ball_kill_boundary_collision.c
src/collisions/nanite_ship_collision.c
src/collisions/nanite_kill_boundary_collision.c
)
# Source files for entities
set(ENTITIES_SRC
src/entities/ball.c
src/entities/brick.c
src/entities/wall_edges.c
src/entities/kill_boundary.c
src/entities/entities.c
src/entities/nanite.c
)
set(SHIP_SRC
src/entities/ship/ship_shield.c
src/entities/ship/ship_body.c
src/entities/ship/ship_thrusters.c
src/entities/ship/ship.c
)
# Source files for mappings
set(MAPPINGS_SRC
src/mappings/brick_type_mapper.c
src/mappings/bar_level_mapper.c
src/mappings/nanite_type_mapper.c
src/mappings/ship_color_mapper.c
src/mappings/thruster_level_mapper.c
src/mappings/shield_type_mapper.c
src/mappings/node_perk_mapper.c
src/mappings/node_attribute_mapper.c
src/mappings/upgrade_icon_mapper.c
)
# Source files for scenes
set(SCENES_SRC
src/scenes/scene_manager.c
src/scenes/main_menu_scene.c
src/scenes/gameplay_scene.c
src/scenes/title_scene.c
src/scenes/logo_scene.c
src/scenes/embark_scene.c
)
# Source files for game states
set(GAME_STATES_SRC
src/game_states/game_state_manager.c
src/game_states/pause_menu_state.c
src/game_states/playing_state.c
src/game_states/game_over_state.c
src/game_states/game_intro_start_state.c
src/game_states/high_score_state.c
src/game_states/upgrade_menu_state.c
src/game_states/settings_menu_state.c
)
# Source files for game
set(GAME_SRC
src/game/game_status.c
src/game/game_data.c
src/game/high_score.c
src/game/game_context.c
src/game/game_ui.c
src/game/shake_effect.c
src/game/playing_ui_bars.c
src/game/player_stat.c
src/game/game_data_summary.c
src/game/level_manager.c
src/game/game_slide.c
src/game/slide_manager.c
src/game/upgrade_manager.c
src/game/game_dialog.c
src/game/text_manager.c
)
set(INPUT_SRC
src/input/gamepad_test.c
src/input/input_manager.c
src/input/virtual_keyboard.c
src/input/playing_input_handler.c
)
# Create the BlockSmashies executable
add_executable(BlockSmashies
${SCENES_SRC}
${GAME_STATES_SRC}
${CORE_SRC}
${GAME_SRC}
${INPUT_SRC}
${ENTITIES_SRC}
${SHIP_SRC}
${COLLISIONS_SRC}
${MAPPINGS_SRC}
${EXTERNAL_SRC})
# Ensure static linking for raylib, parson, and box2d
target_link_libraries(BlockSmashies PUBLIC raylib parson box2d)
# Make sure raylib, parson, and box2d are compiled statically
set_target_properties(raylib PROPERTIES
MSVC_RUNTIME_LIBRARY "MultiThreaded$<$<CONFIG:Debug>:Debug>"
POSITION_INDEPENDENT_CODE ON
)
set_target_properties(parson PROPERTIES
MSVC_RUNTIME_LIBRARY "MultiThreaded$<$<CONFIG:Debug>:Debug>"
POSITION_INDEPENDENT_CODE ON
)
set_target_properties(box2d PROPERTIES
MSVC_RUNTIME_LIBRARY "MultiThreaded$<$<CONFIG:Debug>:Debug>"
POSITION_INDEPENDENT_CODE ON
)
# Custom command to copy assets directory to the build directory
add_custom_command(TARGET BlockSmashies POST_BUILD
COMMAND ${CMAKE_COMMAND} -E copy_directory
${CMAKE_SOURCE_DIR}/assets $<TARGET_FILE_DIR:BlockSmashies>/assets
)
# Set build types
set(CMAKE_CONFIGURATION_TYPES "Debug;Release;MinSizeRel;RelWithDebInfo" CACHE STRING "" FORCE)
# Compiler specific settings
if (MSVC)
add_compile_options(/MP)
target_compile_options(BlockSmashies PRIVATE
$<$<CONFIG:Debug>:/Od /Zi>
$<$<CONFIG:Release>:/O2 /DNDEBUG>
$<$<CONFIG:MinSizeRel>:/O1>
$<$<CONFIG:RelWithDebInfo>:/O2 /Zi>
)
target_compile_options(BlockSmashies PRIVATE /W3 /WX /wd4996)
else()
target_compile_options(BlockSmashies PRIVATE
$<$<CONFIG:Debug>:-g -O0>
$<$<CONFIG:Release>:-O3 -DNDEBUG>
$<$<CONFIG:MinSizeRel>:-Os>
$<$<CONFIG:RelWithDebInfo>:-O2 -g>
)
endif()
# Set the default build type to Debug if not specified
if(NOT CMAKE_BUILD_TYPE AND NOT CMAKE_CONFIGURATION_TYPES)
set(CMAKE_BUILD_TYPE Debug CACHE STRING "Choose the type of build." FORCE)
message(STATUS "Setting build type to 'Debug' as default.")
endif()