-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathCMakeLists.txt
More file actions
174 lines (147 loc) · 6.51 KB
/
CMakeLists.txt
File metadata and controls
174 lines (147 loc) · 6.51 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
cmake_minimum_required(VERSION 3.20 FATAL_ERROR)
# -----------------------------------------
# Project
# -----------------------------------------
project(
Surge
VERSION 1.3.0
LANGUAGES CXX
)
# Generate compile_commands.json for IDEs
set(CMAKE_EXPORT_COMPILE_COMMANDS ON CACHE INTERNAL "")
# -----------------------------------------
# In-source build guard
# -----------------------------------------
if(PROJECT_SOURCE_DIR STREQUAL PROJECT_BINARY_DIR)
message(
FATAL_ERROR
"In-source builds not allowed. Please make a new directory (called a build directory) and run CMake from there."
)
endif()
# -----------------------------------------
# External dependencies
# -----------------------------------------
find_package(EnTT CONFIG REQUIRED)
find_package(Freetype REQUIRED)
find_package(fmt CONFIG REQUIRED)
find_package(glad CONFIG REQUIRED)
find_package(glfw3 CONFIG REQUIRED)
find_package(gsl-lite CONFIG REQUIRED)
find_package(imgui CONFIG REQUIRED)
find_package(mimalloc CONFIG REQUIRED)
find_package(OpenEXR CONFIG REQUIRED)
find_package(OpenGL REQUIRED)
find_package(ryml CONFIG REQUIRED)
find_package(Stb REQUIRED)
find_package(tl-expected CONFIG REQUIRED)
find_package(Taskflow CONFIG REQUIRED)
find_package(Vulkan REQUIRED)
find_package(VulkanHeaders CONFIG)
find_package(VulkanMemoryAllocator CONFIG REQUIRED)
find_package(xxHash CONFIG REQUIRED)
find_program(
GLSL_VALIDATOR
glslangValidator
HINTS
/usr/bin /usr/local/bin
$ENV{VULKAN_SDK}/Bin/
$ENV{VULKAN_SDK}/Bin32/
)
# -----------------------------------------
# Operating system and compiler detection
# -----------------------------------------
if(NOT CMAKE_SYSTEM_NAME STREQUAL "Windows")
set(SURGE_SYSTEM_IS_POSIX "IS_POSIX")
else()
set(SURGE_SYSTEM_IS_POSIX "NOT_POSIX")
endif()
message(STATUS "Selected compiler: ${CMAKE_CXX_COMPILER_ID}")
if(CMAKE_CXX_COMPILER_ID MATCHES "GNU" OR CMAKE_CXX_COMPILER_ID MATCHES "Clang")
set(SURGE_COMPILER_FLAG_STYLE "gcc")
else()
set(SURGE_COMPILER_FLAG_STYLE "msvc")
if (POLICY CMP0141)
cmake_policy(SET CMP0141 NEW)
set(CMAKE_MSVC_DEBUG_INFORMATION_FORMAT "$<IF:$<AND:$<C_COMPILER_ID:MSVC>,$<CXX_COMPILER_ID:MSVC>>,$<$<CONFIG:Debug,RelWithDebInfo>:EditAndContinue>,$<$<CONFIG:Debug,RelWithDebInfo>:ProgramDatabase>>")
endif()
endif()
# -----------------------------------------
# Logging options
# -----------------------------------------
option(SURGE_USE_LOG "Enable log messages" ON)
option(SURGE_USE_LOG_COLOR "Use colors on log outputs" ON)
option(SURGE_GL_LOG "Log OpenGL events" ON)
option(SURGE_LOG_GL_NOTIFICATIONS "Produce log outputs on GL_DEBUG_SEVERITY_NOTIFICATION events" ON)
option(SURGE_USE_VK_VALIDATION_LAYERS "Use Vulkan Validation layers" ON)
# -----------------------------------------
# Compilation flag options
# -----------------------------------------
if(CMAKE_BUILD_TYPE STREQUAL "Debug")
option(SURGE_ENABLE_SANITIZERS "Compiles code with sanitizers" ON)
option(SURGE_ENABLE_OPTIMIZATIONS "Compiles code with optimizations" OFF)
option(SURGE_ENABLE_LTO "Compiles code with link time optimizations" OFF)
option(SURGE_ENABLE_FAST_MATH "Compiles code with fast math mode" OFF)
option(SURGE_ENABLE_TUNING "Compiles code with architecture tuning" OFF)
option(SURGE_DEBUG_MEMORY "Enable custom allocators debug facilities" OFF)
option(SURGE_ENABLE_HR "Enable module hot reloading when pressing LCTRL + F5" ON)
option(SURGE_ENABLE_TRACY "Enables Tracy profiler annotations" OFF)
option(SURGE_ENABLE_FRAME_STEPPING "Enables frame-by-frame stepping when pressing LCTRL + F6" ON)
elseif(CMAKE_BUILD_TYPE STREQUAL "Release")
option(SURGE_ENABLE_SANITIZERS "Compiles code with sanitizers" OFF)
option(SURGE_ENABLE_OPTIMIZATIONS "Compiles code with optimizations" ON)
option(SURGE_ENABLE_LTO "Compiles code with link time optimizations" ON)
option(SURGE_ENABLE_FAST_MATH "Compiles code with fast math mode" ON)
option(SURGE_ENABLE_TUNING "Compiles code with architecture tuning" ON)
option(SURGE_DEBUG_MEMORY "Enable custom allocators debug facilities" OFF)
option(SURGE_ENABLE_HR "Enable module hot reloading when pressing LCTRL + F5" OFF)
option(SURGE_ENABLE_TRACY "Enables Tracy profiler annotations" OFF)
option(SURGE_ENABLE_FRAME_STEPPING "Enables frame-by-frame stepping when pressing LCTRL + F6" OFF)
elseif(CMAKE_BUILD_TYPE STREQUAL "Profile" OR CMAKE_BUILD_TYPE STREQUAL "RelWithDebInfo")
option(SURGE_ENABLE_SANITIZERS "Compiles code with sanitizers" OFF)
option(SURGE_ENABLE_OPTIMIZATIONS "Compiles code with optimizations" ON)
option(SURGE_ENABLE_LTO "Compiles code with link time optimizations" ON)
option(SURGE_ENABLE_FAST_MATH "Compiles code with fast math mode" ON)
option(SURGE_ENABLE_TUNING "Compiles code with architecture tuning" ON)
option(SURGE_DEBUG_MEMORY "Enable custom allocators debug facilities" OFF)
option(SURGE_ENABLE_HR "Enable module hot reloading when pressing LCTRL + F5" OFF)
option(SURGE_ENABLE_TRACY "Enables Tracy profiler annotations" ON)
option(SURGE_ENABLE_FRAME_STEPPING "Enables frame-by-frame stepping when pressing LCTRL + F6" OFF)
endif()
if(SURGE_ENABLE_TRACY)
option(TRACY_ENABLE "" ON)
option(TRACY_CALLSTACK "" ON)
option(TRACY_STATIC "" OFF)
option(TRACY_ON_DEMAND "" ON)
option(TRACY_DELAYED_INIT "" ON)
option(TRACY_MANUAL_LIFETIME "" ON)
add_definitions(-DTRACY_DELAYED_INIT -DTRACY_MANUAL_LIFETIME)
if(CMAKE_SYSTEM_NAME STREQUAL "Linux")
option(TRACY_LIBUNWIND_BACKTRACE "" ON)
option(TRACY_LIBBACKTRACE_ELF_DYNLOAD_SUPPORT "" ON)
option(TRACY_DEBUGINFOD "" ON)
add_definitions(-DTRACY_DEBUGINFOD)
endif()
add_subdirectory(tracy)
endif()
# -----------------------------------------
# Buffer sizes
# -----------------------------------------
if(NOT DEFINED SURGE_OPENGL_ERROR_BUFFER_SIZE)
set(SURGE_OPENGL_ERROR_BUFFER_SIZE 1024)
elseif(SURGE_OPENGL_ERROR_BUFFER_SIZE LESS 1024)
message(WARNING "The variable SURGE_OPENGL_ERROR_BUFFER_SIZE should be set to at least 1024. It will be automatically set to this value.")
set(SURGE_OPENGL_ERROR_BUFFER_SIZE 1024)
endif()
# -----------------------------------------
# Engine core target
# -----------------------------------------
add_subdirectory(${CMAKE_CURRENT_LIST_DIR}/core)
# -----------------------------------------
# Engine player targets
# -----------------------------------------
add_subdirectory(${CMAKE_CURRENT_LIST_DIR}/player_gl)
add_subdirectory(${CMAKE_CURRENT_LIST_DIR}/player_vk)
# -----------------------------------------
# Module targets
# -----------------------------------------
add_subdirectory(${CMAKE_CURRENT_LIST_DIR}/modules)