-
Notifications
You must be signed in to change notification settings - Fork 13
/
CMakeLists.txt
227 lines (178 loc) · 6.91 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
##########################################
# Edge Classic - CMake Script
##########################################
cmake_minimum_required(VERSION 3.20)
project(
edge-classic
LANGUAGES C CXX
VERSION 0.1.0
)
set(CMAKE_C_STANDARD 11)
set(CMAKE_C_STANDARD_REQUIRED True)
set(CMAKE_CXX_STANDARD 17)
set(CMAKE_CXX_STANDARD_REQUIRED True)
# Rendering Options
# Sokol Renderer (Beta)
option(EDGE_SOKOL "Enable Sokol Renderer (Beta)" OFF)
option(EDGE_SOKOL_GL "Sokol GL" OFF)
option(EDGE_SOKOL_D3D11 "Sokol D3D11" OFF)
# GL4ES Backend
option(EDGE_GL_ES2 "Enable GLES2 Rendering Backend" OFF)
# Optional Features
option(EDGE_COAL_SUPPORT "Enable support for COAL scripting" ON)
option(EDGE_DEHACKED_SUPPORT "Enable support for Dehacked patch conversion" ON)
option(EDGE_DOOM_SFX_SUPPORT "Enable support for Doom/PC Speaker sound format" ON)
option(EDGE_FLAC_SUPPORT "Enable support for FLAC music format" ON)
option(EDGE_IMF_SUPPORT "Enable support for IMF music format" ON)
option(EDGE_MP3_SUPPORT "Enable support for MP3 music format" ON)
option(EDGE_MUS_SUPPORT "Enable support for MUS MIDI format" ON)
option(EDGE_OGG_SUPPORT "Enable support for OGG music format" ON)
option(EDGE_RAD_SUPPORT "Enable support for Reality Adlib Tracker v2 music" ON)
option(EDGE_SID_SUPPORT "Enable support for C64 SID music" ON)
option(EDGE_TRACKER_SUPPORT "Enable support for Tracker music (MOD/XM/S3M/IT)" ON)
option(EDGE_XMI_SUPPORT "Enable support for XMI MIDI format" ON)
option(EDGE_VWAD_SUPPORT "Enable support for k8vavoom VWAD archives" ON)
option(EDGE_WAV_SUPPORT "Enable support for WAV sound format" ON)
# Development
option(EDGE_SANITIZE "Enable code sanitizing" OFF)
option(EDGE_PROFILING "Enable Profiling" OFF)
include("${CMAKE_SOURCE_DIR}/cmake/EDGEClassic.cmake")
if ("${CMAKE_CXX_COMPILER_ID}" STREQUAL "Clang" OR "${CMAKE_CXX_COMPILER_ID}" STREQUAL "AppleClang")
set(CLANG true)
else()
set(CLANG false)
endif()
if (EMSCRIPTEN)
include("${CMAKE_SOURCE_DIR}/cmake/Emscripten.cmake")
endif()
if (MSVC)
# Disable RTTI
string(FIND "${CMAKE_CXX_FLAGS}" "/GR" MSVC_HAS_GR)
if(MSVC_HAS_GR)
string(REGEX REPLACE "/GR" "/GR-" CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS}")
else()
add_compile_options(/GR-)
endif()
# Disable C++ Exceptions
string(REGEX REPLACE "/EHsc" "" CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS}")
add_compile_options(/D_HAS_EXCEPTIONS=0)
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} /fp:fast")
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} /fp:fast")
if (NOT CLANG)
# get the number of logical cores for parallel build
cmake_host_system_information(RESULT LOGICAL_CORES QUERY NUMBER_OF_LOGICAL_CORES)
math(EXPR COMPILE_CORES "${LOGICAL_CORES} - 1")
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} /MP${COMPILE_CORES}")
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} /MP${COMPILE_CORES}")
endif()
# Disable some very noisy warnings from the MSVC build
# CRT security and POSIX deprecation warnings
add_definitions("-D_CRT_SECURE_NO_WARNINGS /wd4996")
# Loss of precision/data on assignment, requires lots of explicit casting
add_definitions("/wd4244 /wd4267")
# Unreferenced formal parameter, and there are many of these
add_definitions("/wd4100")
# warning level for edge specific source files
set (EDGE_WARNING_LEVEL "/W4")
# To use the sanitizer with MSVC, you will need to either have your Visual Studio
# or Build Tools install in your PATH variable, or copy the appropriate DLL to the program
# folder before launching. The paths and filenames can vary based on your setup,
# but, as an example, for a 64-bit Debug build using MSVC 2022 Build Tools, the path would be
# C:\Program Files (x86)\Microsoft Visual Studio\2022\BuildTools\VC\Tools\MSVC\<version number>\bin\Hostx64\x64
# and the file would be clang_rt.asan_dbg_dynamic-x86_64.dll
if (EDGE_SANITIZE AND MSVC_VERSION GREATER_EQUAL 1929)
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} /fsanitize=address /Oy-")
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} /fsanitize=address /Oy-")
endif()
if (CLANG)
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wno-c++98-compat -Wno-c++98-compat-pedantic")
endif()
set(CMAKE_EXE_LINKER_FLAGS "/SUBSYSTEM:WINDOWS")
else()
if (WIN32 AND CLANG)
add_definitions("-D_CRT_SECURE_NO_WARNINGS")
endif()
# warning level for edge specific source files
set (EDGE_WARNING_LEVEL -Wextra)
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -Wall -fno-exceptions -fno-strict-aliasing")
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wall -fno-exceptions -fno-rtti -fno-strict-aliasing")
if (EDGE_SANITIZE)
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -fsanitize=address -fno-omit-frame-pointer")
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fsanitize=address -fno-omit-frame-pointer")
set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} -fsanitize=address")
if (NOT CLANG)
set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} -static-libasan")
endif()
endif()
if (MSYS)
set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} -static -mwindows")
endif()
endif()
# set some directory values for various situations
if(${CMAKE_SYSTEM} MATCHES "BSD")
include_directories("/usr/local/include")
endif()
if (MSVC)
set(SDL2_DIR "${CMAKE_SOURCE_DIR}/libraries/sdl2")
endif()
find_package(SDL2 REQUIRED)
# set certain definitions (if appropriate)
if (APPLE)
include_directories(${SDL2_INCLUDE_DIR})
if(${CMAKE_SYSTEM_PROCESSOR} MATCHES "arm64" AND APPLE)
add_compile_definitions(APPLE_SILICON)
elseif(${CMAKE_SYSTEM_PROCESSOR} MATCHES "x86_64" AND APPLE)
add_compile_definitions(NOT_APPLE_SILICON)
endif()
endif()
if (EDGE_SOKOL)
add_definitions(-DEDGE_SOKOL)
elseif (NOT EDGE_GL_ES2)
find_package(OpenGL REQUIRED)
else()
add_definitions(-DEDGE_GL_ES2)
endif()
if (EDGE_COAL_SUPPORT)
add_definitions(-DEDGE_COAL_SUPPORT)
endif()
if (EDGE_DEHACKED_SUPPORT)
add_definitions(-DEDGE_DEHACKED_SUPPORT)
endif()
if (EDGE_DOOM_SFX_SUPPORT)
add_definitions(-DEDGE_DOOM_SFX_SUPPORT)
endif()
if (EDGE_FLAC_SUPPORT)
add_definitions(-DEDGE_FLAC_SUPPORT)
endif()
if (EDGE_IMF_SUPPORT)
add_definitions(-DEDGE_IMF_SUPPORT)
endif()
if (EDGE_MP3_SUPPORT)
add_definitions(-DEDGE_MP3_SUPPORT)
endif()
if (EDGE_MUS_SUPPORT)
add_definitions(-DEDGE_MUS_SUPPORT)
endif()
if (EDGE_OGG_SUPPORT)
add_definitions(-DEDGE_OGG_SUPPORT)
endif()
if (EDGE_RAD_SUPPORT)
add_definitions(-DEDGE_RAD_SUPPORT)
endif()
if (EDGE_SID_SUPPORT)
add_definitions(-DEDGE_SID_SUPPORT)
endif()
if (EDGE_TRACKER_SUPPORT)
add_definitions(-DEDGE_TRACKER_SUPPORT)
endif()
if (EDGE_VWAD_SUPPORT)
add_definitions(-DEDGE_VWAD_SUPPORT)
endif()
if (EDGE_XMI_SUPPORT)
add_definitions(-DEDGE_XMI_SUPPORT)
endif()
if (EDGE_WAV_SUPPORT)
add_definitions(-DEDGE_WAV_SUPPORT)
endif()
add_subdirectory(libraries)
add_subdirectory(source_files)