forked from lethal-guitar/RigelEngine
-
Notifications
You must be signed in to change notification settings - Fork 0
/
CMakeLists.txt
165 lines (131 loc) · 4.35 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
cmake_minimum_required(VERSION 3.12 FATAL_ERROR)
project(RigelEngine)
set(CMAKE_CXX_STANDARD_REQUIRED ON)
set(CMAKE_CXX_STANDARD 17)
set(CMAKE_CXX_EXTENSIONS OFF)
set(CMAKE_EXPORT_COMPILE_COMMANDS ON)
set(main_exe_name RigelEngine)
# Project settings
###############################################################################
option(USE_GL_ES "Use OpenGL ES instead of regular OpenGL" OFF)
option(WARNINGS_AS_ERRORS "Treat compiler warnings as errors" ON)
# Dependencies
###############################################################################
set(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} "${CMAKE_SOURCE_DIR}/cmake/Modules/")
if("${CMAKE_SYSTEM_NAME}" STREQUAL "Emscripten")
set(WEBASSEMBLY_GAME_PATH "" CACHE PATH "Path to folder containing Duke Nukem II files")
set(USE_GL_ES ON)
if (NOT WEBASSEMBLY_GAME_PATH)
message(FATAL_ERROR
"WEBASSEMBLY_GAME_PATH not defined. This is required for a Webassembly build. Point it to a folder containing Duke Nukem II data files. Remove any trailing '/' from the path.")
else()
message(STATUS "Bundling game data from path: ${WEBASSEMBLY_GAME_PATH}")
endif()
add_compile_options(
"SHELL:-s WASM=1"
-O3
)
add_library(SDL2::Core INTERFACE IMPORTED)
set_target_properties(SDL2::Core PROPERTIES
INTERFACE_COMPILE_OPTIONS
"SHELL:-s USE_SDL=2"
INTERFACE_LINK_OPTIONS
"SHELL:-s USE_SDL=2"
)
add_library(SDL2::Mixer INTERFACE IMPORTED)
set_target_properties(SDL2::Mixer PROPERTIES
INTERFACE_COMPILE_OPTIONS
"SHELL:-s USE_SDL_MIXER=2"
INTERFACE_LINK_OPTIONS
"SHELL:-s USE_SDL_MIXER=2"
)
add_library(Boost::boost INTERFACE IMPORTED)
set_target_properties(Boost::boost PROPERTIES
INTERFACE_COMPILE_OPTIONS
"SHELL:-s USE_BOOST_HEADERS=1"
)
else()
set(Boost_USE_STATIC_LIBS ON)
find_package(Boost 1.65 COMPONENTS program_options REQUIRED)
find_package(SDL2 REQUIRED)
find_package(SDL2_mixer REQUIRED)
endif()
find_package(Filesystem REQUIRED)
# Compiler settings
###############################################################################
if(MSVC)
add_compile_options(
/Zc:__cplusplus
/permissive-
/MP
/W4
/EHsc
/wd4100 # Unused parameter
/wd4503 # Decorated name length exceeded
/wd4800 # Forcing value to bool
)
add_definitions(-D_SCL_SECURE_NO_WARNINGS)
if (WARNINGS_AS_ERRORS)
add_compile_options(/WX)
endif()
elseif(CMAKE_CXX_COMPILER_ID MATCHES "Clang")
add_compile_options(
-Weverything
-Wno-unknown-warning-option
-Wno-c++98-compat
-Wno-c++98-compat-pedantic
-Wno-covered-switch-default
-Wno-exit-time-destructors
-Wno-missing-braces
-Wno-padded
-Wno-sign-conversion
-Wno-switch-enum
-Wno-unused-parameter
-Wno-unused-lambda-capture
-Wno-weak-vtables
-Wno-global-constructors
-Wno-float-equal
-Wno-double-promotion
-fcolor-diagnostics
)
if (WARNINGS_AS_ERRORS)
add_compile_options(-Werror)
endif()
elseif(CMAKE_COMPILER_IS_GNUCXX)
add_compile_options(
-Wall
-Wextra
-pedantic
-Wno-maybe-uninitialized
-Wno-unused-parameter
)
if (WARNINGS_AS_ERRORS)
add_compile_options(-Werror)
endif()
else()
message(FATAL_ERROR "Unrecognized compiler")
endif()
# 3rd party build targets
###############################################################################
set(ENTITYX_BUILD_SHARED false CACHE INTERNAL "")
set(ENTITYX_BUILD_TESTING false CACHE INTERNAL "")
set(ENTITYX_DT_TYPE double CACHE INTERNAL "")
set(ENTITYX_RUN_BENCHMARKS false CACHE INTERNAL "")
set(ENTITYX_MAX_COMPONENTS 64 CACHE INTERNAL "")
add_subdirectory(3rd_party/dbopl)
add_subdirectory(3rd_party/entityx)
add_subdirectory(3rd_party/glad)
add_subdirectory(3rd_party/speex_resampler)
add_subdirectory(3rd_party/imgui)
add_subdirectory(3rd_party/imgui-filebrowser)
target_compile_options(entityx PRIVATE
-w
)
# RigelEngine build targets
###############################################################################
add_subdirectory(src)
if(NOT "${CMAKE_SYSTEM_NAME}" STREQUAL "Emscripten")
enable_testing()
add_subdirectory(modding_tools)
add_subdirectory(test)
endif()