-
Notifications
You must be signed in to change notification settings - Fork 4
/
Copy pathCMakeLists.txt
163 lines (149 loc) · 4.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
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
cmake_minimum_required(VERSION 3.14...3.30)
project(
stepbystep-secret
LANGUAGES CXX C
)
option(USE_DEAR_IMGUI "Use Dear ImGUI" OFF)
option(USE_SOLOUD "Use soloud" OFF)
set(WEBGPU_BACKEND "wgpu" CACHE STRING "WebGPU backend (wgpu or dawn)")
## Load packages
include(FetchContent)
set(FETCHCONTENT_QUIET FALSE)
FetchContent_Declare(
glfw3
GIT_REPOSITORY https://github.com/glfw/glfw.git
GIT_TAG 3.4
GIT_SHALLOW TRUE
GIT_PROGRESS TRUE
)
set(GLFW_BUILD_DOCS OFF CACHE BOOL "" FORCE)
set(GLFW_BUILD_TESTS OFF CACHE BOOL "" FORCE)
set(GLFW_BUILD_EXAMPLES OFF CACHE BOOL "" FORCE)
set(GLFW_INSTALL OFF CACHE BOOL "" FORCE)
FetchContent_MakeAvailable( glfw3 )
FetchContent_Declare(
glm
GIT_REPOSITORY https://github.com/g-truc/glm.git
GIT_TAG 1.0.1
GIT_SHALLOW TRUE
GIT_PROGRESS TRUE
)
FetchContent_MakeAvailable( glm )
## Can change `wgpu` to `dawn`
set(WEBGPU_BACKEND "wgpu" CACHE STRING "WebGPU backend (wgpu or dawn)")
FetchContent_Declare(
webgpu
GIT_REPOSITORY https://github.com/yig/WebGPU-distribution
GIT_TAG main
GIT_SHALLOW TRUE
GIT_PROGRESS TRUE
)
FetchContent_MakeAvailable( webgpu )
FetchContent_Declare(
glfw3webgpu
GIT_REPOSITORY https://github.com/eliemichel/glfw3webgpu
GIT_TAG main
GIT_SHALLOW TRUE
GIT_PROGRESS TRUE
)
FetchContent_MakeAvailable( glfw3webgpu )
if( USE_SOLOUD )
FetchContent_Declare(
soloud
GIT_REPOSITORY https://github.com/jarikomppa/soloud
GIT_TAG master
GIT_SHALLOW TRUE
GIT_PROGRESS TRUE
)
FetchContent_MakeAvailable( soloud )
## SoLoud doesn't have its own `CMakeLists.txt`, so let's declare a library directly from its sources.
file(GLOB soloud_sources "${soloud_SOURCE_DIR}/src/audiosource/*/*.c*" "${soloud_SOURCE_DIR}/src/c_api/*.c*" "${soloud_SOURCE_DIR}/src/core/*.c*" "${soloud_SOURCE_DIR}/src/filter/*.c*" "${soloud_SOURCE_DIR}/src/backend/miniaudio/soloud_miniaudio.cpp")
add_library(soloud ${soloud_sources})
target_compile_definitions(soloud PRIVATE WITH_MINIAUDIO)
target_include_directories(soloud PUBLIC "${soloud_SOURCE_DIR}/include")
if(APPLE)
find_library(AudioUnit_LIBRARY AudioUnit)
find_library(CoreAudio_LIBRARY CoreAudio)
target_link_libraries(soloud INTERFACE ${AudioUnit_LIBRARY} ${CoreAudio_LIBRARY})
target_compile_definitions(soloud PRIVATE MA_NO_RUNTIME_LINKING)
endif()
if(WINDOWS)
target_compile_definitions( soloud PRIVATE MA_NO_JACK )
endif()
endif()
FetchContent_Declare(
stb
GIT_REPOSITORY https://github.com/nothings/stb/
GIT_TAG master
GIT_SHALLOW TRUE
GIT_PROGRESS TRUE
)
FetchContent_MakeAvailable( stb )
## stb doesn't have a `CMakeLists.txt`. Let's declare a header-only library with an include path.
add_library( stb INTERFACE )
target_include_directories( stb INTERFACE ${stb_SOURCE_DIR} )
FetchContent_Declare(
spdlog
GIT_REPOSITORY https://github.com/gabime/spdlog/
GIT_TAG v1.x
GIT_SHALLOW TRUE
GIT_PROGRESS TRUE
)
FetchContent_MakeAvailable( spdlog )
FetchContent_Declare(
lua
GIT_REPOSITORY https://github.com/walterschell/Lua
GIT_TAG v5.4.5
GIT_SHALLOW TRUE
GIT_PROGRESS TRUE
)
set(LUA_ENABLE_TESTING OFF CACHE BOOL "" FORCE)
FetchContent_MakeAvailable( lua )
FetchContent_Declare(
sol2
GIT_REPOSITORY https://github.com/yig/sol2
GIT_TAG develop
GIT_SHALLOW TRUE
GIT_PROGRESS TRUE
)
FetchContent_MakeAvailable( sol2 )
if( USE_DEAR_IMGUI )
FetchContent_Declare(
imgui
GIT_REPOSITORY https://github.com/ocornut/imgui
GIT_TAG v1.91.0
GIT_SHALLOW TRUE
GIT_PROGRESS TRUE
)
FetchContent_MakeAvailable( imgui )
## imgui doesn't have a `CMakeLists.txt`, so let's create a library for it.
file( GLOB imgui_sources "${imgui_SOURCE_DIR}/*.c*" "${imgui_SOURCE_DIR}/backends/imgui_impl_wgpu.cpp*" "${imgui_SOURCE_DIR}/backends/imgui_impl_glfw.cpp*" )
add_library( imgui ${imgui_sources} )
target_include_directories( imgui PUBLIC "${imgui_SOURCE_DIR}" "${imgui_SOURCE_DIR}/backends" )
target_link_libraries( imgui PUBLIC glfw webgpu )
set_target_properties( imgui PROPERTIES CXX_STANDARD 17 )
endif()
## Declare the engine library
add_library(illengine STATIC
src/Engine.cpp
src/GraphicsManager.cpp
src/InputManager.cpp
src/ResourceManager.cpp
src/SoundManager.cpp
src/ScriptManager.cpp
src/GUIManager.cpp
)
set_target_properties(illengine PROPERTIES CXX_STANDARD 20 )
target_include_directories(illengine PUBLIC src)
target_link_libraries(illengine PUBLIC glfw glm::glm spdlog::spdlog webgpu glfw3webgpu stb sol2 lua_static)
if( USE_DEAR_IMGUI )
target_link_libraries(illengine PUBLIC imgui)
endif()
if( USE_SOLOUD )
target_link_libraries(illengine PUBLIC soloud)
endif()
## Declare the game executable
add_executable(helloworld demo/helloworld.cpp)
set_target_properties(helloworld PROPERTIES CXX_STANDARD 20 )
target_link_libraries(helloworld PRIVATE illengine)
target_copy_webgpu_binaries(helloworld)