forked from thunderbrewhq/thunderbrew
-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathCMakeLists.txt
129 lines (107 loc) · 3.79 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
cmake_minimum_required(VERSION 3.1)
if (${CMAKE_SOURCE_DIR} STREQUAL ${CMAKE_BINARY_DIR})
message(FATAL_ERROR
"In-source builds not allowed.
Please make a new directory (called a build directory) and run CMake from there.
You may need to remove CMakeCache.txt."
)
endif ()
# OS variables
set(CMAKE_OSX_DEPLOYMENT_TARGET "10.14" CACHE STRING "macOS Deployment Target" FORCE)
# Project
project(whoa)
if (CMAKE_INSTALL_PREFIX_INITIALIZED_TO_DEFAULT)
set(CMAKE_INSTALL_PREFIX "dist" CACHE PATH "Installation prefix" FORCE)
endif ()
set(CMAKE_ARCHIVE_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/lib)
set(CMAKE_LIBRARY_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/lib)
set(CMAKE_RUNTIME_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/bin)
set(CMAKE_CXX_STANDARD 11)
set(CMAKE_BUILD_TYPE Debug)
include(lib/system/cmake/system.cmake)
# Build options
# UBsan
set(WHOA_UB_SAN_HELP_TEXT "Disable/Enable the Undefined Behavior Sanitizer. This is turned on by default in Debug build types. Has no effect when using MSVC.")
if (CMAKE_BUILD_TYPE STREQUAL "Debug")
option(WHOA_UB_SAN WHOA_UB_SAN_HELP_TEXT 1)
else ()
option(WHOA_UB_SAN WHOA_UB_SAN_HELP_TEXT 0)
endif ()
unset(WHOA_UB_SAN_HELP_TEXT)
# GLSDL
if (WHOA_SYSTEM_WIN)
# GLSDL can be disabled on Windows to save time
option(WHOA_BUILD_GLSDL "Disable/Enable compilation of the OpenGL/SDL2 graphics rendering device on Windows." 0)
elseif (WHOA_SYSTEM_MAC)
# No need for this, we already have a functioning OpenGL rendering device (CGxDeviceGLL)
set(WHOA_BUILD_GLSDL 0)
else ()
# Right now GLSDL is the only rendering device for Linux
set(WHOA_BUILD_GLSDL 1)
endif ()
if (WHOA_BUILD_GLSDL)
add_definitions(-DWHOA_BUILD_GLSDL)
endif ()
# FMOD
option(WHOA_BUILD_FMOD "Disable/Enable the use of the FMOD sound API. This introduces a dependency on a proprietary FMOD dynamically linked library." 0)
# Compiler options
if (CMAKE_CXX_COMPILER_ID STREQUAL "Clang" OR CMAKE_CXX_COMPILER_ID STREQUAL "GNU")
# Some templates abuse offsetof
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wno-invalid-offsetof")
if (CMAKE_BUILD_TYPE STREQUAL "Debug" AND WHOA_UB_SAN)
# Enable UBsan
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fsanitize=undefined")
# Allow strange alignments
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fno-sanitize=alignment")
# Make encountering UB an unrecoverable error
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fno-sanitize-recover=all")
else ()
# Disable UBsan completely
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fno-sanitize=undefined")
endif ()
endif ()
# MinGW Options
if (WHOA_SYSTEM_WIN AND CMAKE_CXX_COMPILER_ID STREQUAL "GNU")
set(CMAKE_EXE_LINKER_FLAGS ${CMAKE_EXE_LINKER_FLAGS} "-static-libgcc -static-libstdc++ -static")
endif ()
# OS defines
if (WHOA_SYSTEM_WIN)
# Avoid win32 header hell
add_compile_definitions(
NOMINMAX
WIN32_LEAN_AND_MEAN
)
# Make DirectXMath boring
add_definitions(
-D_XM_NO_INTRINSICS_
)
# Lua uses various "unsafe" C functions
add_definitions(
-D_CRT_SECURE_NO_WARNINGS
)
endif ()
if (WHOA_SYSTEM_MAC)
# Suppress OpenGL deprecation warnings
add_definitions(
-DGL_SILENCE_DEPRECATION
)
endif ()
# Threads
if (WHOA_SYSTEM_LINUX OR WHOA_SYSTEM_MAC)
set(CMAKE_THREAD_PREFER_PTHREAD TRUE)
find_package(Threads REQUIRED)
endif ()
# Library search paths
if (WHOA_SYSTEM_MAC)
set(CMAKE_SKIP_BUILD_RPATH FALSE)
set(CMAKE_BUILD_WITH_INSTALL_RPATH TRUE)
set(CMAKE_INSTALL_RPATH "@executable_path")
elseif (WHOA_SYSTEM_LINUX)
set(CMAKE_SKIP_BUILD_RPATH FALSE)
set(CMAKE_BUILD_WITH_INSTALL_RPATH TRUE)
set(CMAKE_INSTALL_RPATH "$ORIGIN")
endif ()
add_subdirectory(lib)
add_subdirectory(src)
add_subdirectory(test)
add_subdirectory(vendor)