-
Notifications
You must be signed in to change notification settings - Fork 5
/
CMakeLists.txt
executable file
·110 lines (95 loc) · 2.99 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
cmake_minimum_required(VERSION 3.24)
project(gravity_defied_cpp C CXX)
unset(ENV{PKG_CONFIG_PATH})
if(WIN32)
include(cmake/mingw-sdl2.cmake)
download_mingw_sdl2(
"2.26.1" # SDL2
"2.20.1" # SDL2_ttf
"2.6.2" # SDL2_image
)
endif()
find_package(PkgConfig REQUIRED)
pkg_search_module(SDL2 REQUIRED IMPORTED_TARGET sdl2)
pkg_search_module(SDL2_TTF REQUIRED IMPORTED_TARGET SDL2_ttf)
pkg_search_module(SDL2_IMAGE REQUIRED IMPORTED_TARGET SDL2_image)
# Create a sources variable with a link to all cpp files to compile
set(SOURCES
src/utils/Time.cpp
src/utils/EmbedFileStream.cpp
src/main.cpp
src/MathF16.cpp
src/GameCanvas.cpp
src/GamePhysics.cpp
src/TimerOrMotoPartOrMenuElem.cpp
src/class_10.cpp
src/GameLevel.cpp
src/LevelLoader.cpp
src/Micro.cpp
src/TextRender.cpp
src/GameMenu.cpp
src/SettingsStringRender.cpp
src/MenuManager.cpp
src/RecordManager.cpp
src/Timer.cpp
src/lcdui/CanvasImpl.cpp
src/lcdui/Canvas.cpp
src/lcdui/Graphics.cpp
src/lcdui/Image.cpp
src/lcdui/Font.cpp
src/lcdui/Command.cpp
src/lcdui/FontStorage.cpp
src/rms/RecordEnumerationImpl.cpp
src/rms/RecordStore.cpp
)
include(cmake/CMakeRC.cmake)
cmrc_add_resource_library(Assets
NAMESPACE assets
ALIAS Assets::Assets
WHENCE assets
assets/bluearm.png
assets/helmet.png
assets/sprites.png
assets/blueleg.png
assets/bluebody.png
assets/logo.png
assets/fender.png
assets/levels.mrg
assets/engine.png
assets/splash.png
assets/raster.png
assets/FontSansSerif.ttf
)
# Compile resources when building for Windows.
if(WIN32)
enable_language(RC)
list(APPEND SOURCES winres/res.rc)
endif()
add_executable(GravityDefied ${SOURCES})
target_compile_features(GravityDefied PRIVATE cxx_std_17)
target_compile_options(GravityDefied PRIVATE -Wall -Wextra)
target_include_directories(GravityDefied PRIVATE
${SDL2_INCLUDE_DIRS}
${SDL2_TTF_INCLUDE_DIRS}
${SDL2_IMAGE_INCLUDE_DIRS})
target_link_directories(GravityDefied PRIVATE
${SDL2_LIBRARY_DIRS}
${SDL2_TTF_LIBRARY_DIRS}
${SDL2_IMAGE_LIBRARY_DIRS})
set_target_properties(GravityDefied PROPERTIES LINK_FLAGS_RELEASE -s)
if(WIN32)
target_link_options(GravityDefied PRIVATE -static -mwindows)
target_link_libraries(GravityDefied
${SDL2_STATIC_LIBRARIES}
${SDL2_TTF_STATIC_LIBRARIES}
${SDL2_IMAGE_STATIC_LIBRARIES}
Assets::Assets)
else()
target_link_libraries(GravityDefied
${SDL2_LIBRARIES}
${SDL2_TTF_LIBRARIES}
${SDL2_IMAGE_LIBRARIES}
Assets::Assets)
endif()
# Copy assets to the build directory
file(COPY assets/levels.mrg DESTINATION ${CMAKE_BINARY_DIR})