-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathCMakeLists.txt
More file actions
127 lines (118 loc) · 3.39 KB
/
CMakeLists.txt
File metadata and controls
127 lines (118 loc) · 3.39 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
cmake_minimum_required(VERSION 3.14)
project(shippy)
set(CMAKE_CXX_STANDARD 17)
set(CMAKE_CXX_STANDARD_REQUIRED ON)
# Fetch Box2D
include(FetchContent)
FetchContent_Declare(
box2d
GIT_REPOSITORY https://github.com/erincatto/box2d.git
GIT_TAG v3.1.1
)
FetchContent_MakeAvailable(box2d)
# Fetch libpd (desktop only for now — Android integration is a follow-up plan)
if(NOT ANDROID)
set(PD_UTILS OFF CACHE BOOL "" FORCE)
set(PD_EXTRA ON CACHE BOOL "" FORCE)
set(PD_MULTI OFF CACHE BOOL "" FORCE)
# libpd's root CMakeLists still targets an older CMake; allow it to configure.
set(CMAKE_POLICY_VERSION_MINIMUM 3.5 CACHE STRING "" FORCE)
FetchContent_Declare(
libpd
GIT_REPOSITORY https://github.com/libpd/libpd.git
GIT_TAG 0.14.1
GIT_SUBMODULES_RECURSE TRUE
)
FetchContent_MakeAvailable(libpd)
# Pure Data's C code predates modern Clang's strict default of treating
# implicit-function-declaration as an error (for alloca in x_file.c, etc.).
foreach(_pd_tgt libpd libpd_static)
if(TARGET ${_pd_tgt})
target_compile_options(${_pd_tgt} PRIVATE
-Wno-error=implicit-function-declaration
-Wno-implicit-function-declaration)
endif()
endforeach()
endif()
if(ANDROID)
# On Android, fetch SDL3 libraries from source
FetchContent_Declare(
SDL3
GIT_REPOSITORY https://github.com/libsdl-org/SDL.git
GIT_TAG release-3.4.4
GIT_SHALLOW TRUE
)
FetchContent_Declare(
SDL3_ttf
GIT_REPOSITORY https://github.com/libsdl-org/SDL_ttf.git
GIT_TAG release-3.2.2
GIT_SHALLOW TRUE
)
FetchContent_Declare(
SDL3_mixer
GIT_REPOSITORY https://github.com/libsdl-org/SDL_mixer.git
GIT_TAG release-3.2.0
GIT_SHALLOW TRUE
)
set(SDL_SHARED ON CACHE BOOL "" FORCE)
set(SDL_STATIC OFF CACHE BOOL "" FORCE)
# Only need OGG/Vorbis for our audio - disable everything else
set(SDLMIXER_MP3 OFF CACHE BOOL "" FORCE)
set(SDLMIXER_MOD OFF CACHE BOOL "" FORCE)
set(SDLMIXER_MIDI OFF CACHE BOOL "" FORCE)
set(SDLMIXER_FLAC OFF CACHE BOOL "" FORCE)
set(SDLMIXER_OPUS OFF CACHE BOOL "" FORCE)
set(SDLMIXER_WAVPACK OFF CACHE BOOL "" FORCE)
set(SDLMIXER_GME OFF CACHE BOOL "" FORCE)
set(SDLMIXER_VORBIS_STB ON CACHE BOOL "" FORCE)
FetchContent_MakeAvailable(SDL3 SDL3_ttf SDL3_mixer)
else()
# On desktop, use system-installed SDL3
find_package(SDL3 REQUIRED)
find_package(SDL3_ttf REQUIRED)
find_package(SDL3_mixer REQUIRED)
endif()
set(SOURCES
main.cpp
object.cpp
body.cpp
loot.cpp
game.cpp
ship.cpp
space.cpp
biases.cpp
duder.cpp
starfield.cpp
sdl_compat.cpp
physics_world.cpp
projectile.cpp
asteroid.cpp
cuzer.cpp
ai.cpp
platform.cpp
touch_input.cpp
pdaudio.cpp
)
if(ANDROID)
add_library(shippy SHARED ${SOURCES})
target_link_libraries(shippy
SDL3::SDL3
SDL3_ttf::SDL3_ttf
SDL3_mixer::SDL3_mixer
box2d
log
)
else()
add_executable(shippy ${SOURCES})
target_link_libraries(shippy
SDL3::SDL3
SDL3_ttf::SDL3_ttf
SDL3_mixer::SDL3_mixer
box2d
libpd_static
)
target_include_directories(shippy PRIVATE
${libpd_SOURCE_DIR}/libpd_wrapper
${libpd_SOURCE_DIR}/pure-data/src
)
endif()