-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathCMakeLists.txt
277 lines (236 loc) · 8.79 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
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
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
#-----------------------------
# Initialising stuff
#-----------------------------
cmake_minimum_required(VERSION 3.21)
project(PlatinumEngine VERSION 0.0.2)
if (APPLE)
enable_language(OBJC)
endif()
set(CMAKE_CXX_STANDARD 17)
set(CMAKE_OSX_ARCHITECTURES "arm64;x86_64")
# static libraries please
set(BUILD_SHARED_LIBS FALSE)
# make executable run in project's root directory
set(CMAKE_RUNTIME_OUTPUT_DIRECTORY ${CMAKE_CURRENT_LIST_DIR})
# FetchContent to fetch git repos remotely
include(FetchContent)
# enable CTest
enable_testing()
#-----------------------------
#-----------------------------
# External libraries from git repos
#-----------------------------
# glfw
set(GLFW_BUILD_DOCS OFF)
set(GLFW_BUILD_TESTS OFF)
set(GLFW_BUILD_EXAMPLES OFF)
FetchContent_Declare(glfw GIT_REPOSITORY https://github.com/glfw/glfw.git GIT_TAG 3.3.6)
FetchContent_MakeAvailable(glfw)
#-----------------------------
# Dear ImGui
FetchContent_Declare(imgui GIT_REPOSITORY https://github.com/ocornut/imgui.git GIT_TAG origin/docking)
FetchContent_MakeAvailable(imgui)
add_subdirectory("CMake Subfolders/ImGui CMake")
#-----------------------------
# ImGuiFileDialog
add_compile_definitions(USE_BOOKMARK)
FetchContent_Declare(imguifiledialog GIT_REPOSITORY https://github.com/aiekick/ImGuiFileDialog.git GIT_TAG v0.6.4)
FetchContent_MakeAvailable(imguifiledialog)
include_directories(${FETCHCONTENT_BASE_DIR}/imguifiledialog-src)
#-----------------------------
# Immediate Mode Plotting (implot)
FetchContent_Declare(implot GIT_REPOSITORY https://github.com/epezent/implot.git GIT_TAG v0.13)
FetchContent_MakeAvailable(implot)
add_subdirectory("CMake Subfolders/ImPlot CMake")
#-----------------------------
# GLM
FetchContent_Declare(glm GIT_REPOSITORY https://github.com/g-truc/glm.git GIT_TAG 0.9.9.8)
FetchContent_MakeAvailable(glm)
add_compile_definitions(GLM_FORCE_LEFT_HANDED)
#-----------------------------
# assimp
set(ASSIMP_BUILD_ALL_IMPORTERS_BY_DEFAULT FALSE)
set(ASSIMP_BUILD_OBJ_IMPORTER TRUE)
set(ASSIMP_BUILD_FBX_IMPORTER TRUE)
set(ASSIMP_BUILD_BLEND_IMPORTER FALSE)
set(ASSIMP_NO_EXPORT TRUE)
set(ASSIMP_BUILD_TESTS FALSE)
FetchContent_Declare(assimp GIT_REPOSITORY https://github.com/assimp/assimp.git GIT_TAG 5.2.0)
FetchContent_MakeAvailable(assimp)
#-----------------------------
# Catch2 - testing framework
set(CATCH_BUILD_STATIC_LIBRARY TRUE)
FetchContent_Declare(Catch2 GIT_REPOSITORY https://github.com/catchorg/Catch2.git GIT_TAG v2.13.8)
FetchContent_MakeAvailable(Catch2)
#-----------------------------
# glew
set(glew-cmake_BUILD_SHARED OFF)
set(USE_GLU "Use GLU" ON)
FetchContent_Declare(glew GIT_REPOSITORY https://github.com/Perlmint/glew-cmake.git GIT_TAG glew-cmake-2.2.0)
FetchContent_MakeAvailable(glew)
#-----------------------------
# SDL
set(SDL_SHARED OFF)
set(SDL_STATIC ON)
FetchContent_Declare(sdl GIT_REPOSITORY https://github.com/libsdl-org/SDL.git GIT_TAG 2.0.22-RC1)
FetchContent_MakeAvailable(sdl)
set(SDL2_INCLUDE_DIR "${FETCHCONTENT_BASE_DIR}/sdl-src/include")
#-----------------------------
# SDL2 Mixer
FetchContent_Declare(sdl2mixer GIT_REPOSITORY https://github.com/libsdl-org/SDL_mixer.git GIT_TAG release-2.0.4)
FetchContent_MakeAvailable(sdl2mixer)
add_subdirectory("CMake Subfolders/SDL2Mixer CMake")
set(SDL2_MIXER_INCLUDE_DIR "${FETCHCONTENT_BASE_DIR}/sdl2mixer-src")
#-----------------------------
# imguizmo
FetchContent_Declare(imguizmo GIT_REPOSITORY https://github.com/CedricGuillemet/ImGuizmo.git GIT_TAG origin/master)
FetchContent_MakeAvailable(imguizmo)
#-----------------------------
# stb_image
FetchContent_Declare(stb GIT_REPOSITORY https://github.com/nothings/stb.git GIT_TAG origin/master)
FetchContent_MakeAvailable(stb)
#----------------------------
# bullet3 physics library
FetchContent_Declare(bullet3 GIT_REPOSITORY https://github.com/bulletphysics/bullet3.git GIT_TAG 3.22b)
FetchContent_MakeAvailable(bullet3)
#-----------------------------
# ozz
set(ozz_build_fbx OFF)
set(ozz_build_samples OFF)
set(ozz_build_howtos ON)
set(ozz_build_tests OFF)
set(ozz_build_tools ON)
set(ozz_build_postfix OFF)
set(ozz_build_simd_ref ON)
FetchContent_Declare(ozz GIT_REPOSITORY https://github.com/guillaumeblanc/ozz-animation.git GIT_TAG 0.14.0)
FetchContent_MakeAvailable(ozz)
#-----------------------------
# Add more libraries from git repos here:
#-----------------------------
#-----------------------------
# IMPORTANT SECTION! Source code
#-----------------------------
# New place to put all your source code files into:
set(PROJECT_SOURCES_WITHOUT_MAIN
# order by folder structure
"${FETCHCONTENT_BASE_DIR}/imguifiledialog-src/ImGuiFileDialog.cpp;"
"${FETCHCONTENT_BASE_DIR}/imguizmo-src/ImGuizmo.cpp;"
"Source/Animation/Animation.cpp;"
"Source/Animation/AnimationLocalTimer.cpp;"
"Source/AssetDatabase/AssetDatabase.cpp;"
"Source/Audio/AudioClip.cpp;"
"Source/ComponentComposition/Camera.cpp;"
"Source/ComponentComposition/AudioComponent.cpp;"
"Source/ComponentComposition/AnimationComponent.cpp;"
"Source/ComponentComposition/AnimationAttachment.cpp;"
"Source/ComponentComposition/Color.cpp;"
"Source/ComponentComposition/Component.cpp;"
"Source/ComponentComposition/GameObject.cpp;"
"Source/ComponentComposition/MeshRender.cpp;"
"Source/ComponentComposition/Transform.cpp;"
"Source/ComponentComposition/Light.cpp;"
"Source/ComponentComposition/Objects.cpp;"
"Source/ComponentComposition/RigidBody.cpp;"
"Source/ComponentComposition/BoxCollider.cpp;"
"Source/ComponentComposition/CapsuleCollider.cpp;"
"Source/ComponentComposition/SphereCollider.cpp;"
"Source/ComponentComposition/Collider.cpp;"
"Source/ComponentComposition/ParticleEffect.cpp;"
"Source/GameWindow/GameWindow.cpp;"
"Source/IDSystem/IDSystem.cpp;"
"Source/InputManager/InputManager.cpp;"
"Source/Inspector/InspectorWindow.cpp;"
"Source/Loaders/LoaderCommon.cpp;"
"Source/Loaders/MeshLoader.cpp;"
"Source/Logger/Logger.cpp;"
"Source/Maths/Common.cpp;"
"Source/Maths/Matrices.cpp;"
"Source/Maths/Quaternion.cpp;"
"Source/Maths/Vectors.cpp;"
"Source/OpenGL/Framebuffer.cpp;"
"Source/OpenGL/GLCheck.cpp;"
"Source/OpenGL/GLEnumInfo.cpp;"
"Source/OpenGL/Mesh.cpp;"
"Source/OpenGL/ShaderInput.cpp;"
"Source/OpenGL/ShaderProgram.cpp;"
"Source/OpenGL/Texture.cpp;"
"Source/OpenGL/Material.cpp;"
"Source/Physics/Physics.cpp;"
"Source/PlatformingGame/Player.cpp;"
"Source/PlatformingGame/DayNightCycle.cpp;"
"Source/ParticleEffects/ParticleEmitter.cpp"
"Source/ParticleEffects/ParticleRenderer.cpp;"
"Source/Profiler/Profiler.cpp;"
"Source/Project/ProjectWindow.cpp;"
"Source/Renderer/Renderer.cpp;"
"Source/SceneEditor/EditorCamera.cpp;"
"Source/SceneEditor/SceneEditor.cpp;"
"Source/SceneManager/HierarchyWindow.cpp;"
"Source/SceneManager/Scene.cpp;"
"Source/TypeDatabase/TypeDatabase.cpp;"
"Source/TypeDatabase/TypeDatabaseInit.cpp;"
"Source/WindowManager/Filedialog.cpp;"
"Source/WindowManager/WindowManager.cpp;"
"Source/Application.cpp;"
)
add_executable(${PROJECT_NAME} Source/main.cpp ${PROJECT_SOURCES_WITHOUT_MAIN})
#-----------------------------
#-----------------------------
# IMPORTANT SECTION! Unit testing
#-----------------------------
# Add unit tests here:
set(UNIT_TESTS
"Test/TestTemplate.cpp;"
"Test/Maths/VectorsTest.cpp;"
"Test/Maths/MatricesTest.cpp;"
"Test/SceneEditor/EditorCameraTest.cpp;"
"Test/TypeDatabase/TestTypeDatabase.cpp;"
"Test/IDSystem/TestIDSystem.cpp;"
Include/Animation/AnimationLocalTimer.h Source/Animation/AnimationLocalTimer.cpp Include/ComponentComposition/AnimationAttachment.h Source/ComponentComposition/AnimationAttachment.cpp)
add_executable(tests ${PROJECT_SOURCES_WITHOUT_MAIN} ${UNIT_TESTS})
#-----------------------------
#-----------------------------
# IMPORTANT SECTION! Include files
#-----------------------------
# list of folders to include
set(PROJECT_INCLUDES
"Include;"
"Fonts;"
"${FETCHCONTENT_BASE_DIR}/imguizmo-src;"
"${FETCHCONTENT_BASE_DIR}/stb-src;"
"${FETCHCONTENT_BASE_DIR}/bullet3-src/src"
"${SDL2_INCLUDE_DIR}"
"${SDL2_MIXER_INCLUDE_DIR}"
)
# different targets
target_include_directories(${PROJECT_NAME} PRIVATE ${PROJECT_INCLUDES})
target_include_directories(tests PRIVATE ${PROJECT_INCLUDES})
#-----------------------------
#-----------------------------
# Linking libraries
#-----------------------------
# list of libraries we're using in the main engine
set(PROJECT_LIBRARIES
# good luck trying to find these names and trying to match them
# CMake is so stupid
"glfw;"
"imgui;"
"implot;"
"glm;"
"assimp;"
"libglew_static;"
# Bullet3D libs
"BulletDynamics;"
"Bullet3Common;"
"BulletCollision;"
"LinearMath;"
#"BulletInverseDynamics;"
#"BulletSoftBody;" #shouldnt be necessary
"SDL2_mixer;"
"ozz_animation;"
"ozz_animation_offline;"
)
# different targets
target_link_libraries(${PROJECT_NAME} PRIVATE ${PROJECT_LIBRARIES})
target_link_libraries(tests PRIVATE ${PROJECT_LIBRARIES} Catch2::Catch2WithMain)
#-----------------------------