forked from bugix/OpenGGS
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathCMakeLists.txt
More file actions
212 lines (190 loc) · 7.97 KB
/
CMakeLists.txt
File metadata and controls
212 lines (190 loc) · 7.97 KB
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
cmake_minimum_required(VERSION 3.15)
project(OpenGGS LANGUAGES CXX)
# Optionally set C++ standard
set(CMAKE_CXX_STANDARD 17)
set(CMAKE_CXX_STANDARD_REQUIRED ON)
set(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} "${OpenGGS_SOURCE_DIR}/cmake")
# Define a CMake option that defaults to OFF
option(ENABLE_CLANG_TIDY "Enable clang-tidy checks" OFF)
include(FetchContent)
#------------------------------------------------------------------------------
#------------------------------------------------------------------------------
#------------------------------------------------------------------------------
#------------------------------------------------------------------------------
if (CMAKE_SYSTEM_NAME STREQUAL "Linux")
find_package(SDL2 REQUIRED)
find_package(SDL2_image REQUIRED)
find_package(SDL2_mixer REQUIRED)
include_directories(${SDL2_INCLUDE_DIR}
${SDL2_IMAGE_INCLUDE_DIR}
${SDL2_MIXER_INCLUDE_DIR})
endif()
#------------------------------------------------------------------------------
#------------------------------------------------------------------------------
#------------------------------------------------------------------------------
#------------------------------------------------------------------------------
# Declare SDL2
FetchContent_Declare(
SDL2
GIT_REPOSITORY https://github.com/libsdl-org/SDL.git
GIT_TAG release-2.32.2
)
# Disable building SDL2 tests, if desired
set(SDL_TEST OFF CACHE BOOL "Do not build SDL2_test" FORCE)
# Optionally disable tests or set build options
set(SUPPORT_AVIF OFF CACHE BOOL "Disable AVIF support" FORCE)
set(SDL2IMAGE_AVIF OFF CACHE BOOL "Disable TIFF support in SDL2_image" FORCE)
set(SUPPORT_WEBP OFF CACHE BOOL "Disable WEBP support" FORCE)
set(SUPPORT_TIFF OFF CACHE BOOL "Disable TIFF support in SDL2_image" FORCE)
set(SDL2IMAGE_TIF OFF CACHE BOOL "Disable TIFF support in SDL2_image" FORCE)
set(IMAGE_TEST OFF CACHE BOOL "Disable building SDL2_image test" FORCE)
# --- Fetch & build SDL2_image ---
FetchContent_Declare(
SDL2_image
GIT_REPOSITORY https://github.com/libsdl-org/SDL_image.git
GIT_TAG release-2.8.8
)
# Before FetchContent_MakeAvailable(SDL2_mixer):
set(MUSIC_OPUS OFF CACHE BOOL "Disable Opus in SDL2_mixer" FORCE)
set(MUSIC_MP3_SMPEG OFF CACHE BOOL "Disable SMPEG-based MP3" FORCE)
set(MUSIC_MPG123 OFF CACHE BOOL "Disable mpg123-based MP3" FORCE)
set(MIXER_TEST OFF CACHE BOOL "Disable building SDL2_mixer test" FORCE)
set(SDL2MIXER_OPUS OFF CACHE BOOL "Disable building SDL2MIXER_OPUS" FORCE)
set(SDL2MIXER_MOD OFF CACHE BOOL "Disable building SDL2MIXER_MOD" FORCE)
set(SDL2MIXER_MOD_XMP OFF CACHE BOOL "Disable building SDL2MIXER_MOD_XMP" FORCE)
set(MIXER_TEST OFF CACHE BOOL "Disable building SDL2_mixer test" FORCE)
set(SDL2MIXER_MIDI_FLUIDSYNTH OFF CACHE BOOL "Disable SDL2MIXER_MIDI_FLUIDSYNTH in SDL2_mixer" FORCE)
set(SDL2MIXER_WAVPACK OFF CACHE BOOL "Disable building SDL2MIXER_WAVPACK" FORCE)
# --- Fetch & build SDL2_mixer ---
FetchContent_Declare(
SDL2_mixer
GIT_REPOSITORY https://github.com/libsdl-org/SDL_mixer.git
GIT_TAG release-2.8.1
)
# 3) Fetch (clone) and build SDL2, SDL2_image, and SDL2_mixer
FetchContent_MakeAvailable(SDL2 SDL2_image SDL2_mixer)
#------------------------------------------------------------------------------
#------------------------------------------------------------------------------
#------------------------------------------------------------------------------
#------------------------------------------------------------------------------
if(ENABLE_CLANG_TIDY)
message(STATUS "clang-tidy checks enabled")
if(CMAKE_CXX_COMPILER_ID STREQUAL "Clang")
# Adjust the checks, warning settings, etc. as you prefer:
set(CMAKE_CXX_CLANG_TIDY
"clang-tidy"
)
message(STATUS "clang-tidy set: ${CMAKE_CXX_CLANG_TIDY}")
endif()
endif()
#------------------------------------------------------------------------------
#------------------------------------------------------------------------------
#------------------------------------------------------------------------------
#------------------------------------------------------------------------------
# Add Corrosion as a dependency
FetchContent_Declare(
Corrosion
GIT_REPOSITORY https://github.com/corrosion-rs/corrosion.git
GIT_TAG v0.5 # Optionally specify a commit hash, version tag or branch here
)
FetchContent_MakeAvailable(Corrosion)
# Import targets defined in a package or workspace manifest `Cargo.toml` file
corrosion_import_crate(MANIFEST_PATH rust-lib/Cargo.toml)
#------------------------------------------------------------------------------
#------------------------------------------------------------------------------
#------------------------------------------------------------------------------
#------------------------------------------------------------------------------
set(SOURCE_FILES
src/ANIMATION.cpp
src/GRAPHICS_Sprites_Draw.cpp
src/LOOP_Editor_Stages_Creator_Functions.cpp
src/LOOP_Stagefile_Load.cpp
src/STAGE_Draw.cpp
src/AUDIO.cpp
src/GRAPHICS_Sprites_Move.cpp
src/LOOP_Editor_Stages_Enemies.cpp
src/LOOP_Story.cpp
src/STAGE_Interface_Draw.cpp
src/CONTENT_Gametype_Load.cpp
src/GRAPHICS_Tiles_Animations.cpp
src/LOOP_Editor_Stages_Interface.cpp
src/PLAYER.cpp
src/SYSTEM_Debug_Infos.cpp
src/CONTENT_Stages_Load_Write.cpp
src/GRAPHICS_Tiles_Define.cpp
src/LOOP_Editor_Stages_Set_Elements.cpp
src/PLAYER_Collision_NonSolids.cpp
src/SYSTEM_Draw_Text.cpp
src/ENEMIES.cpp
src/GRAPHICS_Tiles_Draw.cpp
src/LOOP_Editor_Stages_Sprites.cpp
src/PLAYER_Collision_Solids.cpp
src/SYSTEM_Input_General.cpp
src/ENEMIES_Collision.cpp
src/GRAPHICS_Tiles_Elements.cpp
src/LOOP_Editor_Stages_Stage_Settings.cpp
src/PLAYER_Collision_Solids_Specials.cpp
src/SYSTEM_SDL_Textures.cpp
src/ENEMIES_Draw.cpp
src/GRAPHICS_Tiles_Switch_Tile.cpp
src/LOOP_Editor_Tiles.cpp
src/PLAYER_Collision_Sprites.cpp
src/SYSTEM_SDL_init.cpp
src/ENEMIES_Move.cpp
src/INTERFACE_Draw.cpp
src/LOOP_Gameloop.cpp
src/PLAYER_Draw.cpp
src/SYSTEM_SDL_input.cpp
src/GAME_ENVIRONMENT.cpp
src/LOOP_Credits.cpp
src/LOOP_Gameloop_Splashscreens.cpp
src/PLAYER_Jump.cpp
src/SYSTEM_Update_Screen.cpp
src/GRAPHICS_Sprites.cpp
src/LOOP_Editor_Stages.cpp
src/LOOP_Menu.cpp
src/PLAYER_Killed.cpp
src/SYSTEM_Vector_Operations.cpp
src/GRAPHICS_Sprites_Bullets.cpp
src/LOOP_Editor_Stages_Creator.cpp
src/LOOP_Options.cpp
src/PLAYER_Run.cpp
src/main.cpp
)
#------------------------------------------------------------------------------
#------------------------------------------------------------------------------
#------------------------------------------------------------------------------
#------------------------------------------------------------------------------
find_program(CLANG_FORMAT_BIN clang-format-18)
if (CLANG_FORMAT_BIN)
message(STATUS "Found clang-format at ${CLANG_FORMAT_BIN}")
# Gather all your source files. For example:
file(GLOB_RECURSE ALL_SOURCE_FILES
"${CMAKE_SOURCE_DIR}/src/*.cpp"
"${CMAKE_SOURCE_DIR}/src/*.h"
)
# Custom target: "format"
add_custom_target(format
COMMAND ${CLANG_FORMAT_BIN} -i ${ALL_SOURCE_FILES}
COMMENT "Running clang-format on source files"
)
endif()
#------------------------------------------------------------------------------
#------------------------------------------------------------------------------
#------------------------------------------------------------------------------
#------------------------------------------------------------------------------
add_executable(openggs ${SOURCE_FILES})
if (CMAKE_SYSTEM_NAME STREQUAL "Linux")
target_link_libraries(openggs ${SDL2_LIBRARY}
${SDL2_IMAGE_LIBRARIES}
${SDL2_MIXER_LIBRARIES})
endif()
target_link_libraries(openggs
PRIVATE
SDL2::SDL2
SDL2::SDL2main # needed on Windows
SDL2_image
SDL2_mixer
)
#------------------------------------------------------------------------------
#------------------------------------------------------------------------------