-
Notifications
You must be signed in to change notification settings - Fork 1
/
CMakeLists.txt
172 lines (146 loc) · 6.54 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
cmake_minimum_required(VERSION 3.0.0) # Selects the minimum version of CMake required to run this file
project(COIN-QUEST VERSION 1.0.0) # Here we select the project name and version
# Here we select C++17 with all the standards required and all compiler-specific extensions disabled
set(CMAKE_CXX_STANDARD 17)
set(CMAKE_CXX_STANDARD_REQUIRED ON)
set(CMAKE_CXX_EXTENSIONS OFF)
# These are the options we select for building GLFW as a library
set(GLFW_BUILD_DOCS OFF CACHE BOOL "" FORCE) # Don't build Documentation
set(GLFW_BUILD_TESTS OFF CACHE BOOL "" FORCE) # Don't build Tests
set(GLFW_BUILD_EXAMPLES OFF CACHE BOOL "" FORCE) # Don't build Examples
set(GLFW_INSTALL OFF CACHE BOOL "" FORCE) # Don't build Installation Information
set(GLFW_USE_HYBRID_HPG ON CACHE BOOL "" FORCE) # Add variables to use High Performance Graphics Card if available
add_subdirectory(vendor/glfw) # Build the GLFW project to use later as a library
if(NOT CMAKE_BUILD_TYPE)
set(CMAKE_BUILD_TYPE Release)
endif()
message(STATUS "Build type: ${CMAKE_BUILD_TYPE}")
set(CMAKE_CXX_FLAGS "-Wall")
set(CMAKE_CXX_FLAGS_DEBUG "-g")
set(CMAKE_CXX_FLAGS_RELEASE "-O3")
# A variable with all the source files of GLAD
set(GLAD_SOURCE vendor/glad/src/gl.c)
# A variables with all the source files of Dear ImGui
set(IMGUI_SOURCES
vendor/imgui/imgui.cpp
vendor/imgui/imgui_demo.cpp
vendor/imgui/imgui_draw.cpp
vendor/imgui/imgui_widgets.cpp
vendor/imgui/imgui_impl/imgui_impl_glfw.cpp
vendor/imgui/imgui_impl/imgui_impl_opengl3.cpp
)
# Combine all vendor source files together into a single variable
set(VENDOR_SOURCES ${GLAD_SOURCE} ${IMGUI_SOURCES})
# A variable with all our source files that are common between executable targets (examples)
set(COMMON_SOURCES
source/common/application.hpp
source/common/application.cpp
source/common/input/keyboard.hpp
source/common/input/mouse.hpp
source/common/asset-loader.cpp
source/common/asset-loader.hpp
source/common/deserialize-utils.hpp
source/common/shader/shader.hpp
source/common/shader/shader.cpp
source/common/mesh/vertex.hpp
source/common/mesh/mesh.hpp
source/common/mesh/mesh-utils.hpp
source/common/mesh/mesh-utils.cpp
source/common/texture/sampler.hpp
source/common/texture/sampler.cpp
source/common/texture/texture2d.hpp
source/common/texture/texture-utils.hpp
source/common/texture/texture-utils.cpp
source/common/texture/screenshot.hpp
source/common/texture/screenshot.cpp
source/common/material/pipeline-state.hpp
source/common/material/pipeline-state.cpp
source/common/material/material.hpp
source/common/material/material.cpp
source/common/ecs/component.hpp
source/common/ecs/tag-component.hpp
source/common/ecs/transform.hpp
source/common/ecs/transform.cpp
source/common/ecs/entity.hpp
source/common/ecs/entity.cpp
source/common/ecs/world.hpp
source/common/ecs/world.cpp
source/common/components/camera.hpp
source/common/components/camera.cpp
source/common/components/light.hpp
source/common/components/light.cpp
source/common/components/light_spectrum.hpp
source/common/components/light_spectrum.cpp
source/common/components/mesh-renderer.hpp
source/common/components/mesh-renderer.cpp
source/common/components/free-camera-controller.hpp
source/common/components/free-camera-controller.cpp
source/common/components/movement.hpp
source/common/components/movement.cpp
source/common/components/component-deserializer.hpp
source/common/components/player-movement-controller.hpp
source/common/components/player-movement-controller.cpp
source/common/components/player.hpp
source/common/components/collision.hpp
source/common/components/collision.cpp
source/common/components/generated.hpp
source/common/components/coin.hpp
source/common/components/tags/obstacle.hpp
source/common/components/tags/heart.hpp
source/common/systems/forward-renderer.hpp
source/common/systems/forward-renderer.cpp
source/common/systems/free-camera-controller.hpp
source/common/systems/movement.hpp
source/common/systems/player-movement-controller.hpp
source/common/systems/hud.hpp
source/common/systems/collision.hpp
source/common/systems/generator.hpp
)
# Define the directories in which to search for the included headers
include_directories(
source/common
vendor/glfw/include
vendor/glad/include
vendor/glm
vendor/imgui
vendor/utils
)
set(CMAKE_RUNTIME_OUTPUT_DIRECTORY ${PROJECT_SOURCE_DIR}/bin)
set(CMAKE_RUNTIME_OUTPUT_DIRECTORY_DEBUG ${PROJECT_SOURCE_DIR}/bin)
set(CMAKE_RUNTIME_OUTPUT_DIRECTORY_RELEASE ${PROJECT_SOURCE_DIR}/bin)
set(STATES_SOURCES
source/states/play-state.hpp
source/states/menu-state.hpp
source/states/shader-test-state.hpp
source/states/mesh-test-state.hpp
source/states/transform-test-state.hpp
source/states/pipeline-test-state.hpp
source/states/texture-test-state.hpp
source/states/sampler-test-state.hpp
source/states/material-test-state.hpp
source/states/entity-test-state.hpp
source/states/renderer-test-state.hpp
)
# sdl mixer
set(CMAKE_PREFIX_PATH ${CMAKE_SOURCE_DIR}/vendor/sdl)
find_package(SDL2 REQUIRED)
set(CMAKE_PREFIX_PATH ${CMAKE_SOURCE_DIR}/vendor/sdl_mixer)
find_package(SDL2_mixer REQUIRED)
# Specify the DLL we want to copy to the binary folder
set(DLL_FILES_COPY
${CMAKE_SOURCE_DIR}/vendor/sdl/lib/x64/SDL2.dll
${CMAKE_SOURCE_DIR}/vendor/sdl_mixer/lib/x64/SDL2_mixer.dll
)
# For each example, we add an executable target
# Each target compiles one example source file and the common & vendor source files
# Then we link GLFW with each target
add_executable(GAME_APPLICATION source/main.cpp ${STATES_SOURCES} ${COMMON_SOURCES} ${VENDOR_SOURCES})
target_link_libraries(GAME_APPLICATION glfw SDL2::SDL2 SDL2::SDL2main SDL2_mixer::SDL2_mixer)
# Copy the DLL files to the binary folder during the build process
foreach(DLL_FILE ${DLL_FILES_COPY})
add_custom_command(TARGET GAME_APPLICATION POST_BUILD
COMMAND ${CMAKE_COMMAND} -E copy_if_different
"${DLL_FILE}"
${PROJECT_SOURCE_DIR}/bin
)
endforeach()