-
-
Notifications
You must be signed in to change notification settings - Fork 92
/
CMakeLists.txt
175 lines (151 loc) · 6.26 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
cmake_minimum_required(VERSION 3.15)
# if(CMAKE_GENERATOR STREQUAL "Xcode")
# set(CMAKE_OSX_ARCHITECTURES "$(ARCHS_STANDARD)" CACHE STRING "")
# endif()
include(CMakeLists.local OPTIONAL)
if (NOT CMAKE_BUILD_TYPE)
set(CMAKE_BUILD_TYPE "Debug" CACHE STRING "Compile Type" FORCE)
endif()
set_property(CACHE CMAKE_BUILD_TYPE PROPERTY STRINGS Debug Release MinSizeRel RelWithDebInfo Profile)
option(UNITTESTS "Builds with unittests" ON)
option(VISUALTESTS "Builds with visual tests (src/tests)" ON)
option(VOXEDIT "Builds voxedit" ON)
option(THUMBNAILER "Builds thumbnailer" ON)
option(VOXCONVERT "Builds voxconvert" ON)
option(USE_OPENGLES "Enable OpenGLES" OFF)
option(USE_CCACHE "Use ccache" ON)
option(USE_DOXYGEN_CHECK "Use -Wdocumentation if available" OFF)
option(USE_CPPCHECK "Enable cppcheck" OFF)
option(USE_CLANG_TIDY "Enable Clang Tidy" OFF)
option(USE_IMGUITESTENGINE "Enable imgui test engine" OFF)
option(USE_STACKTRACES "Enable stacktraces" ON)
option(USE_SANITIZERS "Enable sanitizer" OFF)
option(USE_GLSLANG_VALIDATOR "Enable the use of the standalone glslang validator" OFF)
option(USE_LIBS_FORCE_LOCAL "Don't use systemwide installations" OFF)
set(ROOT_PROJECT_MAJOR_VERSION 0)
set(ROOT_PROJECT_MINOR_VERSION 0)
set(ROOT_PROJECT_MICRO_VERSION 35)
set(ROOT_PROJECT_PATCH_VERSION 0)
set(ROOT_PROJECT_VERSION "${ROOT_PROJECT_MAJOR_VERSION}.${ROOT_PROJECT_MINOR_VERSION}.${ROOT_PROJECT_MICRO_VERSION}.${ROOT_PROJECT_PATCH_VERSION}")
set(ROOT_PROJECT_NAME vengi)
project(${ROOT_PROJECT_NAME} VERSION ${ROOT_PROJECT_VERSION})
set(ROOT_DIR ${CMAKE_CURRENT_SOURCE_DIR} CACHE STRING "Root dir")
set(DATA_DIR ${ROOT_DIR}/data CACHE STRING "" FORCE)
set(SCRIPTS_CMAKE_DIR ${PROJECT_SOURCE_DIR}/cmake)
set(GENERATE_DIR ${CMAKE_BINARY_DIR}/generated CACHE STRING "Generated code dir")
set(PKGDATADIR "" CACHE STRING "System directory to search for data files (must end on /)")
add_custom_target(codegen)
include(CheckCCompilerFlag)
include(CheckCXXCompilerFlag)
include(CheckCXXSourceCompiles)
include(CheckIPOSupported)
include(CMakeParseArguments)
include(CheckIncludeFiles)
include(GNUInstallDirs)
if (${CMAKE_SYSTEM_NAME} STREQUAL "Windows")
set(WINDOWS 1)
elseif (${CMAKE_SYSTEM_NAME} STREQUAL "Android")
set(LINUX 1)
elseif (${CMAKE_SYSTEM_NAME} STREQUAL "Linux")
set(LINUX 1)
elseif (${CMAKE_SYSTEM_NAME} STREQUAL "Emscripten")
set(EMSCRIPTEN 1)
set(USE_STACKTRACES OFF)
set(USE_OPENGLES ON)
elseif (APPLE)
else()
message(WARNING "Unknown host system: ${CMAKE_SYSTEM_NAME}. Default to linux")
set(LINUX 1)
endif()
set(CMAKE_CXX_STANDARD 17)
set(CMAKE_CXX_STANDARD_REQUIRED on)
set(CMAKE_CXX_EXTENSIONS off)
set(CMAKE_POSITION_INDEPENDENT_CODE ON)
if (${CMAKE_BUILD_TYPE} MATCHES "Release")
set(CMAKE_LINK_WHAT_YOU_USE ON)
option(USE_LINK_TIME_OPTIMIZATION "Enable link time optimization" ON)
else()
option(USE_LINK_TIME_OPTIMIZATION "Enable link time optimization" OFF)
endif()
check_ipo_supported(RESULT HAVE_LTO OUTPUT error)
if (HAVE_LTO)
if (USE_LINK_TIME_OPTIMIZATION)
set(CMAKE_INTERPROCEDURAL_OPTIMIZATION ON)
message(STATUS "IPO / LTO enabled")
else()
message(STATUS "IPO / LTO disabled")
endif()
else()
message(STATUS "IPO / LTO not supported: <${error}>")
endif()
if (MSVC)
include(${SCRIPTS_CMAKE_DIR}/system/msvc.cmake)
elseif (WINDOWS)
include(${SCRIPTS_CMAKE_DIR}/system/mingw.cmake)
elseif (APPLE)
include(${SCRIPTS_CMAKE_DIR}/system/apple.cmake)
elseif (EMSCRIPTEN)
include(${SCRIPTS_CMAKE_DIR}/system/emscripten.cmake)
else()
include(${SCRIPTS_CMAKE_DIR}/system/linux.cmake)
endif()
find_program(GLSLANG_EXECUTABLE NAMES glslangValidator glslang-standalone)
if (GLSLANG_EXECUTABLE)
message(STATUS "Found glslang tool at ${GLSLANG_EXECUTABLE}")
elseif(USE_GLSLANG_VALIDATOR)
message(WARNING "Couldn't find glslang tool but using it was requested")
endif()
include(${SCRIPTS_CMAKE_DIR}/git.cmake)
include(${SCRIPTS_CMAKE_DIR}/util.cmake)
include(${SCRIPTS_CMAKE_DIR}/genshader.cmake)
include(${SCRIPTS_CMAKE_DIR}/externallib.cmake)
include(${SCRIPTS_CMAKE_DIR}/valgrind.cmake)
include(${SCRIPTS_CMAKE_DIR}/perf.cmake)
include(${SCRIPTS_CMAKE_DIR}/heaptrack.cmake)
include(${SCRIPTS_CMAKE_DIR}/apitrace.cmake)
include(${SCRIPTS_CMAKE_DIR}/debug.cmake)
include(${SCRIPTS_CMAKE_DIR}/googletest.cmake)
include(${SCRIPTS_CMAKE_DIR}/lua.cmake)
include(${SCRIPTS_CMAKE_DIR}/macros.cmake)
include(${SCRIPTS_CMAKE_DIR}/pack.cmake)
include(CPack)
# First for the generic no-config case (e.g. with mingw)
set(CMAKE_RUNTIME_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR})
set(CMAKE_ARCHIVE_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/${CMAKE_BUILD_TYPE}/lib)
set(CMAKE_LIBRARY_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/${CMAKE_BUILD_TYPE}/lib)
# Second, for multi-config builds (e.g. msvc)
foreach(OUTPUTCONFIG ${CMAKE_CONFIGURATION_TYPES})
string(TOUPPER ${OUTPUTCONFIG} OUTPUTCONFIG)
set(CMAKE_RUNTIME_OUTPUT_DIRECTORY_${OUTPUTCONFIG} ${CMAKE_BINARY_DIR})
set(CMAKE_LIBRARY_OUTPUT_DIRECTORY_${OUTPUTCONFIG} ${CMAKE_BINARY_DIR}/${CMAKE_BUILD_TYPE}/lib)
set(CMAKE_ARCHIVE_OUTPUT_DIRECTORY_${OUTPUTCONFIG} ${CMAKE_BINARY_DIR}/${CMAKE_BUILD_TYPE}/lib)
endforeach()
set(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} ${SCRIPTS_CMAKE_DIR})
set(CMAKE_EXPORT_COMPILE_COMMANDS ON)
set(CMAKE_WINDOWS_EXPORT_ALL_SYMBOLS ON)
find_host_program(GDB_EXECUTABLE NAMES ${GDB_BINARY} gdb)
find_host_program(LLDB_EXECUTABLE NAMES ${LLDB_BINARY} lldb)
include_directories(${CMAKE_CURRENT_BINARY_DIR})
# These includes are needed to let the include for IMPLICIT_DEPENDS for shaders work
include_directories(src/modules/video/shaders)
include_directories(src/modules)
add_subdirectory(contrib/libs)
add_subdirectory(tools)
if (UNITTESTS)
enable_testing()
set(CTEST_TEST_TIMEOUT 1800)
endif()
add_subdirectory(src)
configure_file(src/engine-git.h.in engine-git.h @ONLY)
configure_file(src/engine-config.h.in engine-config.h @ONLY)
message(STATUS "Generate engine-config.h in ${CMAKE_CURRENT_BINARY_DIR}")
find_package(Doxygen)
configure_file(${CMAKE_CURRENT_SOURCE_DIR}/Doxyfile.in ${CMAKE_CURRENT_BINARY_DIR}/Doxyfile @ONLY)
configure_file(${CMAKE_CURRENT_SOURCE_DIR}/Doxyfile-mcss.in ${CMAKE_CURRENT_BINARY_DIR}/Doxyfile-mcss @ONLY)
if (DOXYGEN_FOUND)
add_custom_target(doc ${DOXYGEN_EXECUTABLE} ${CMAKE_CURRENT_BINARY_DIR}/Doxyfile
WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}
COMMENT "Generating API documentation with Doxygen" VERBATIM
DEPENDS codegen
)
endif(DOXYGEN_FOUND)