1 cmake_minimum_required(VERSION 3.13)
4 set(NOTHING_CI OFF CACHE BOOL "Indicates whether the build is running on CI or not")
7 # do the flags thing first.
9 add_compile_definitions(SDL_MAIN_HANDLED) # https://stackoverflow.com/a/25089610
10 add_compile_definitions(__USE_MINGW_ANSI_STDIO) # https://github.com/trink/symtseries/issues/49#issuecomment-160843756
13 # then try to find SDL2 using normal means (eg. the user may have installed SDL2 using pacman on msys2)
14 # note we don't use REQUIRED here, because it can fail -- in which case we fall back to looking for the
15 # library "directly" using local files.
16 find_package(SDL2 QUIET)
19 # Support both 32 and 64 bit builds
20 if (${CMAKE_SIZEOF_VOID_P} MATCHES 8)
21 set(SDL2_INCLUDE_DIRS "${CMAKE_SOURCE_DIR}/SDL2/x86_64-w64-mingw32/include/SDL2")
22 set(SDL2_LIBRARIES "${CMAKE_SOURCE_DIR}/SDL2/x86_64-w64-mingw32/lib/libSDL2.a;${CMAKE_SOURCE_DIR}/SDL2/x86_64-w64-mingw32/lib/libSDL2main.a")
24 set(SDL2_INCLUDE_DIRS "${CMAKE_SOURCE_DIR}/SDL2/i686-w64-mingw32/include/SDL2")
25 set(SDL2_LIBRARIES "${CMAKE_SOURCE_DIR}/SDL2/i686-w64-mingw32/lib/libSDL2.a;${CMAKE_SOURCE_DIR}/SDL2/i686-w64-mingw32/lib/libSDL2main.a")
28 set(SDL2_INCLUDE_DIRS "${CMAKE_SOURCE_DIR}/SDL2/include")
30 # Support both 32 and 64 bit builds
31 if (${CMAKE_SIZEOF_VOID_P} MATCHES 8)
32 set(SDL2_LIBRARIES "${CMAKE_SOURCE_DIR}/SDL2/lib/x64/SDL2.lib;${CMAKE_SOURCE_DIR}/SDL2/lib/x64/SDL2main.lib")
34 set(SDL2_LIBRARIES "${CMAKE_SOURCE_DIR}/SDL2/lib/x86/SDL2.lib;${CMAKE_SOURCE_DIR}/SDL2/lib/x86/SDL2main.lib")
37 string(STRIP "${SDL2_LIBRARIES}" SDL2_LIBRARIES)
40 find_package(SDL2 REQUIRED)
43 if("${SDL2_LIBRARIES}" STREQUAL "")
44 message(WARNING "SDL2_LIBRARIES wasn't set, manually setting to SDL2::SDL2")
45 set(SDL2_LIBRARIES "SDL2::SDL2")
48 include_directories(${CMAKE_BINARY_DIR})
49 include_directories(src/)
51 include_directories(${SDL2_INCLUDE_DIRS})
53 add_library(system STATIC
54 src/system/line_stream.h
55 src/system/line_stream.c
59 src/system/lt_adapters.h
60 src/system/lt_adapters.c
61 src/system/nth_alloc.h
62 src/system/nth_alloc.c
63 src/system/stacktrace.h
64 src/system/stacktrace.c
75 add_executable(nothing
84 src/game/level/background.h
85 src/game/level/background.c
86 src/game/level/boxes.h
87 src/game/level/boxes.c
88 src/game/level/goals.h
89 src/game/level/goals.c
90 src/game/level/labels.h
91 src/game/level/labels.c
94 src/game/level/lava/wavy_rect.h
95 src/game/level/lava/wavy_rect.c
96 src/game/level/platforms.h
97 src/game/level/platforms.c
98 src/game/level/player.h
99 src/game/level/player.c
100 src/game/level/explosion.h
101 src/game/level/explosion.c
102 src/game/level/regions.h
103 src/game/level/regions.c
104 src/game/level/rigid_bodies.h
105 src/game/level/rigid_bodies.c
106 src/game/level/action.h
107 src/game/level_picker.h
108 src/game/level_picker.c
111 src/game/level_folder.c
112 src/game/level_folder.h
113 src/game/sound_samples.h
114 src/game/sound_samples.c
115 src/game/sprite_font.h
116 src/game/sprite_font.c
142 src/ui/list_selector.h
143 src/ui/list_selector.c
150 src/game/level_metadata.h
151 src/game/level_metadata.c
152 src/game/level/level_editor.h
153 src/game/level/level_editor.c
154 src/game/level/level_editor/color_picker.h
155 src/game/level/level_editor/color_picker.c
156 src/game/level/level_editor/rect_layer.h
157 src/game/level/level_editor/rect_layer.c
158 src/game/level/level_editor/layer_picker.h
159 src/game/level/level_editor/layer_picker.c
160 src/game/level/level_editor/point_layer.h
161 src/game/level/level_editor/point_layer.c
162 src/game/level/level_editor/player_layer.h
163 src/game/level/level_editor/player_layer.c
164 src/game/level/level_editor/layer.h
165 src/game/level/level_editor/layer.c
166 src/game/level/level_editor/label_layer.h
167 src/game/level/level_editor/label_layer.c
168 src/game/level/level_editor/background_layer.h
169 src/game/level/level_editor/background_layer.c
170 src/game/level/level_editor/undo_history.h
171 src/game/level/level_editor/undo_history.c
172 src/game/level/level_editor/action_picker.h
173 src/game/level/level_editor/action_picker.c
175 target_link_libraries(nothing ${SDL2_LIBRARIES} system)
177 ADD_CUSTOM_TARGET(link_assets ALL
178 COMMAND ${CMAKE_COMMAND} -E create_symlink ${CMAKE_CURRENT_SOURCE_DIR}/assets ${CMAKE_BINARY_DIR}/assets)
180 if(("${CMAKE_C_COMPILER_ID}" STREQUAL "GNU") OR ("${CMAKE_C_COMPILER_ID}" STREQUAL "Clang") OR ("${CMAKE_C_COMPILER_ID}" STREQUAL "AppleClang"))
195 -Wmissing-declarations \
197 -Wmissing-prototypes \
201 -Wstrict-prototypes \
204 -Wmissing-field-initializers \
206 -fno-strict-aliasing \
212 set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -Werror")
214 target_link_libraries(nothing m)
215 elseif("${CMAKE_CXX_COMPILER_ID}" STREQUAL "MSVC")
232 /D \"_CRT_SECURE_NO_WARNINGS\"")
234 set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} /WX")
238 target_link_libraries(nothing hid setupapi Imm32 Version winmm)
240 target_link_libraries(nothing Imm32 Version winmm)