-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathCMakeLists.txt
More file actions
205 lines (177 loc) · 5.35 KB
/
CMakeLists.txt
File metadata and controls
205 lines (177 loc) · 5.35 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
cmake_minimum_required (VERSION 3.28)
project ("GadgetCore" LANGUAGES C CXX)
# --------------------------------------- #
# ------------ CMake Scripts ------------ #
# --------------------------------------- #
include("${CMAKE_CURRENT_SOURCE_DIR}/cmake/GadgetCoreUtils.cmake")
# --------------------------------------- #
# ----- Fetch External Dependencies ----- #
# --------------------------------------- #
include(FetchContent)
set(BUILD_SHARED_LIBS OFF)
FetchContent_Declare(
catch2
GIT_REPOSITORY https://github.com/catchorg/Catch2.git
GIT_TAG v3.14.0
SYSTEM
EXCLUDE_FROM_ALL
)
set(CATCH_INSTALL_DOCS OFF)
set(CATCH_INSTALL_EXTRAS OFF)
FetchContent_MakeAvailable(catch2)
FetchContent_Declare(
SDL3
GIT_REPOSITORY https://github.com/libsdl-org/SDL.git
GIT_TAG release-3.4.4
SYSTEM
EXCLUDE_FROM_ALL
)
set(SDL_TEST_LIBRARY OFF)
FetchContent_MakeAvailable(SDL3)
FetchContent_Declare(
SDL3_Image
GIT_REPOSITORY https://github.com/libsdl-org/SDL_image.git
GIT_TAG release-3.2.4
SYSTEM
EXCLUDE_FROM_ALL
)
set(SDLIMAGE_AVIF OFF) # This is on by default and gives us some nonsense unrecoverable error
set(SDLIMAGE_STB OFF)
set(SDLIMAGE_GIF OFF)
set(SDLIMAGE_LBM OFF)
set(SDLIMAGE_PCX OFF)
set(SDLIMAGE_PNM OFF)
set(SDLIMAGE_QOI OFF)
set(SDLIMAGE_TIF OFF)
set(SDLIMAGE_WEBP OFF)
set(SDLIMAGE_XCF OFF)
set(SDLIMAGE_XPM OFF)
set(SDLIMAGE_XV OFF)
FetchContent_MakeAvailable(SDL3_Image)
FetchContent_Declare(
Assimp
GIT_REPOSITORY https://github.com/assimp/assimp.git
GIT_TAG v6.0.4
SYSTEM
EXCLUDE_FROM_ALL
)
set(ASSIMP_WARNINGS_AS_ERRORS OFF)
set(ASSIMP_BUILD_TESTS OFF)
set(ASSIMP_NO_EXPORT ON)
set(ASSIMP_BUILD_ALL_IMPORTERS_BY_DEFAULT OFF)
set(ASSIMP_BUILD_3DS_IMPORTER ON)
set(ASSIMP_BUILD_ASSBIN_IMPORTER ON)
set(ASSIMP_BUILD_GLTF_IMPORTER ON)
set(ASSIMP_BUILD_COLLADA_IMPORTER ON)
set(ASSIMP_BUILD_OBJ_IMPORTER ON)
set(ASSIMP_BUILD_PLY_IMPORTER ON)
set(ASSIMP_BUILD_BLEND_IMPORTER ON)
set(ASSIMP_BUILD_FBX_IMPORTER ON)
set(ASSIMP_BUILD_RAW_IMPORTER ON)
set(ASSIMP_BUILD_STL_IMPORTER ON)
set(ASSIMP_BUILD_USD_IMPORTER OFF) # I would like to support this but build fails on Linux
if (ANDROID)
add_compile_definitions(USE_FILE32API) # Forces minizip to use standard fopen instead of missing fopen64
endif()
FetchContent_MakeAvailable(Assimp)
FetchContent_Declare(
json
GIT_REPOSITORY https://github.com/nlohmann/json.git
GIT_TAG v3.12.0
SYSTEM
EXCLUDE_FROM_ALL
)
set(JSON_BuildTests OFF)
FetchContent_MakeAvailable(json)
# --------------------------------------- #
# ------------ Setup Tooling ------------ #
# --------------------------------------- #
GadgetCore_SetExceptionFlag(EXCEPTION_FLAG)
GadgetCore_EnableClangTidy(GadgetCore, EXCEPTION_FLAG, ".*[/\\]include[/\\]GCore[/\\]")
# --------------------------------------- #
# ------------ Setup Target ------------- #
# --------------------------------------- #
file (GLOB_RECURSE SRC_FILES CONFIGURE_DEPENDS
"src/*.cpp"
"src/*.h"
"src/*.hpp"
)
file (GLOB_RECURSE INC_FILES CONFIGURE_DEPENDS
"include/*.h"
"include/*.hpp"
)
add_library(GadgetCore STATIC ${SRC_FILES} ${INC_FILES})
option(GADGETCORE_BUILD_TESTS "Build tests for the GadgetCore project" ON)
option(GADGETCORE_BUILD_DEMOS "Build demos for the GadgetCore project" ON) # TODO - turn this off later
set_target_properties(GadgetCore PROPERTIES
CXX_EXTENSIONS NO
CMAKE_INTERPROCEDURAL_OPTIMIZATION TRUE
CXX_SCAN_FOR_MODULES OFF
)
target_compile_features(GadgetCore PUBLIC cxx_std_23)
target_include_directories(GadgetCore
PUBLIC
$<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/include>
$<INSTALL_INTERFACE:include>
PRIVATE
${CMAKE_CURRENT_SOURCE_DIR}/include/GCore
${assimp_SOURCE_DIR}/src
)
target_link_libraries(GadgetCore
PUBLIC
SDL3::SDL3
nlohmann_json::nlohmann_json
PRIVATE
SDL3_image::SDL3_image
assimp::assimp
)
# Treat discarding a [[nodiscard]] as an error
GadgetCore_NoDiscardAsError(GadgetCore)
# --------------------------------------- #
# ----- Build Type Specific Config ------ #
# --------------------------------------- #
if (CMAKE_BUILD_TYPE STREQUAL "Debug")
target_compile_definitions(GadgetCore PUBLIC GADGET_BUILD_DEBUG)
elseif (CMAKE_BUILD_TYPE STREQUAL "Release")
target_compile_definitions(GadgetCore PUBLIC GADGET_BUILD_RELEASE)
endif()
# --------------------------------------- #
# ------ Platform Specific Config ------- #
# --------------------------------------- #
if (CMAKE_SYSTEM_NAME STREQUAL "Windows")
target_compile_definitions(GadgetCore
PUBLIC
GADGET_PLATFORM_TYPE_PC
GADGET_PLATFORM_WINDOWS
)
elseif(CMAKE_SYSTEM_NAME STREQUAL "Darwin")
target_compile_definitions(GadgetCore
PUBLIC
GADGET_PLATFORM_TYPE_PC
GADGET_PLATFORM_MACOS
)
elseif(CMAKE_SYSTEM_NAME STREQUAL "Linux")
target_compile_definitions(GadgetCore
PUBLIC
GADGET_PLATFORM_TYPE_PC
GADGET_PLATFORM_LINUX
)
elseif(ANDROID)
target_compile_definitions(GadgetCore
PUBLIC
GADGET_PLATFORM_TYPE_MOBILE
GADGET_PLATFORM_ANDROID
)
endif()
# --------------------------- #
# ---------- Tests ---------- #
# --------------------------- #
if (GADGETCORE_BUILD_TESTS)
add_subdirectory(tests)
endif()
# --------------------------- #
# ---------- Demos ---------- #
# --------------------------- #
if (GADGETCORE_BUILD_DEMOS)
add_subdirectory(demos)
endif()