-
Notifications
You must be signed in to change notification settings - Fork 58
/
Copy pathCMakeLists.txt
166 lines (124 loc) · 5.14 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
cmake_minimum_required(VERSION 3.1.0 FATAL_ERROR)
set(RADIX_LIBRARY RadixEngine)
if (COVERAGE)
message("-- Coverage Enabled")
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} --coverage -fprofile-arcs -ftest-coverage")
endif ()
if(NOT DEFINED CMAKE_BUILD_TYPE)
set(CMAKE_BUILD_TYPE RelWithDebInfo CACHE STRING "Build type")
endif()
project(${RADIX_LIBRARY} CXX C)
set(CMAKE_CXX_STANDARD 14)
list(APPEND CMAKE_MODULE_PATH ${CMAKE_CURRENT_SOURCE_DIR}/cmake)
#### UTILITY ####
set(RADIX_DEFINITIONS "")
function(radix_add_exported_definition)
add_definitions("-D${ARGV0}")
list(APPEND RADIX_DEFINITIONS "${ARGV0}")
set(RADIX_DEFINITIONS "${RADIX_DEFINITIONS}" PARENT_SCOPE)
endfunction(radix_add_exported_definition)
#### COMPILE-TIME SETTINGS ####
set(RADIX_GL_LOADER "glad" CACHE STRING "OpenGL loader to use. One of 'libepoxy', 'glad'")
if ("${RADIX_GL_LOADER}" STREQUAL "libepoxy")
set(RADIX_GL_USE_LIBEPOXY TRUE)
radix_add_exported_definition("RADIX_GL_USE_LIBEPOXY")
endif()
if ("${RADIX_GL_LOADER}" STREQUAL "glad")
set(RADIX_GL_USE_GLAD TRUE)
radix_add_exported_definition("RADIX_GL_USE_GLAD")
endif()
#### PLATFORM-SPECIFIC FIXES ####
if(DEFINED WIN32)
add_definitions("-D_USE_MATH_DEFINES")
endif()
#### LIBRARIES ####
set(RADIX_INCLUDE_DIRS "")
find_package(OpenGL REQUIRED)
list(APPEND RADIX_INCLUDE_DIRS ${OPENGL_INCLUDE_DIR})
list(APPEND RADIX_INCLUDE_DIRS ${CMAKE_CURRENT_SOURCE_DIR}/external/stx/include)
set(RADIX_LIBRARIES ${OPENGL_gl_LIBRARY})
find_package(PkgConfig REQUIRED)
if (RADIX_GL_USE_LIBEPOXY)
pkg_search_module(EPOXY REQUIRED epoxy)
list(APPEND RADIX_INCLUDE_DIRS ${EPOXY_INCLUDE_DIRS})
list(APPEND RADIX_LIBRARIES ${EPOXY_LIBRARIES})
elseif (RADIX_GL_USE_GLAD)
set(GLAD_INCLUDE_DIR "${CMAKE_CURRENT_SOURCE_DIR}/external/glad")
set(GLAD_SRC "${GLAD_INCLUDE_DIR}/glad.c")
add_library("GLAD" ${GLAD_SRC})
list(APPEND RADIX_INCLUDE_DIRS ${GLAD_INCLUDE_DIR})
list(APPEND RADIX_LIBRARIES GLAD)
endif()
find_package(Assimp REQUIRED)
list(APPEND RADIX_INCLUDE_DIRS ${ASSIMP_INCLUDE_DIRS})
list(APPEND RADIX_LIBRARIES ${ASSIMP_LIBRARIES} )
find_package(SDL2 REQUIRED)
find_package(SDL2_mixer REQUIRED)
list(APPEND RADIX_INCLUDE_DIRS ${SDL2_INCLUDE_DIR} ${SDL2_MIXER_INCLUDE_DIRS})
list(APPEND RADIX_LIBRARIES ${SDL2_LIBRARY} ${SDL2_MIXER_LIBRARIES} )
find_package(TinyXML2 2.0.0 REQUIRED)
list(APPEND RADIX_INCLUDE_DIRS ${TINYXML2_INCLUDE_DIR})
list(APPEND RADIX_LIBRARIES ${TINYXML2_LIBRARIES})
add_definitions("-DTINYXML2_MAJOR_VERSION=${TINYXML2_MAJOR_VERSION}")
add_definitions("-DTINYXML2_MINOR_VERSION=${TINYXML2_MINOR_VERSION}")
add_definitions("-DTINYXML2_PATCH_VERSION=${TINYXML2_PATCH_VERSION}")
add_definitions("-DTINYXML2_VERSION_CODE=${TINYXML2_VERSION_CODE}")
find_package(json11 REQUIRED)
list(APPEND RADIX_INCLUDE_DIRS ${JSON11_INCLUDE_DIR})
list(APPEND RADIX_LIBRARIES ${JSON11_LIBRARY})
find_package(Catch REQUIRED)
list(APPEND RADIX_INCLUDE_DIRS ${CATCH_INCLUDE_DIR})
find_package(Linenoise REQUIRED)
list(APPEND RADIX_INCLUDE_DIRS ${LINENOISE_INCLUDE_DIR})
find_package(Bullet 2.82 REQUIRED)
list(APPEND RADIX_INCLUDE_DIRS ${BULLET_INCLUDE_DIR})
list(APPEND RADIX_LIBRARIES ${BULLET_LIBRARIES})
find_package(VHACD REQUIRED)
list(APPEND RADIX_INCLUDE_DIRS ${VHACD_INCLUDE_DIR})
list(APPEND RADIX_LIBRARIES ${VHACD_LIBRARY})
find_package(FreeImage REQUIRED)
list(APPEND RADIX_INCLUDE_DIRS ${FREEIMAGE_INCLUDE_DIR})
list(APPEND RADIX_LIBRARIES ${FREEIMAGE_LIBRARIES})
find_package(AngelScript REQUIRED)
list(APPEND RADIX_INCLUDE_DIRS ${ANGELSCRIPT_INCLUDE_DIRS})
list(APPEND RADIX_LIBRARIES ${ANGELSCRIPT_LIBRARY})
find_package(easy_profiler REQUIRED)
list(APPEND RADIX_INCLUDE_DIRS ${EASY_PROFILER_INCLUDE_DIR})
set(RADIX_ENABLE_PROFILER ON CACHE BOOL "Enable Radix's profiler")
if (RADIX_ENABLE_PROFILER)
list(APPEND RADIX_LIBRARIES ${EASY_PROFILER_LIBRARIES})
else ()
radix_add_exported_definition("DISABLE_EASY_PROFILER")
endif ()
set(PORTAL_TEST_LIBRARIES ${RADIX_LIBRARIES})
list(APPEND RADIX_INCLUDE_DIRS "${CMAKE_CURRENT_SOURCE_DIR}/external/serine/include")
#### ENGINE ####
if (${CMAKE_CXX_COMPILER_ID} STREQUAL "GNU")
add_definitions("-Wall")
endif ()
find_package(RadixEntity REQUIRED)
list(APPEND RADIX_INCLUDE_DIRS ${RADIXENTITY_INCLUDE_DIR})
list(APPEND RADIX_LIBRARIES ${RADIXENTITY_LIBRARIES})
set(RADIX_INCLUDE_DIR "${CMAKE_CURRENT_SOURCE_DIR}/include")
list(APPEND RADIX_INCLUDE_DIRS "${RADIX_INCLUDE_DIR}")
include_directories(${RADIX_INCLUDE_DIRS})
add_subdirectory(source)
add_library(${RADIX_LIBRARY} STATIC ${RADIX_SOURCES})
target_link_libraries(${RADIX_LIBRARY} ${RADIX_LIBRARIES} dl)
# Export
list(APPEND RADIX_LIBRARIES ${RADIX_LIBRARY})
if (RADIX_EXPORT_CMAKE_PACKAGE_VARS)
set(RADIX_LIBRARY "${RADIX_LIBRARY}" PARENT_SCOPE)
set(RADIX_LIBRARIES "${RADIX_LIBRARIES}" PARENT_SCOPE)
set(RADIX_INCLUDE_DIR "${RADIX_INCLUDE_DIR}" PARENT_SCOPE)
set(RADIX_INCLUDE_DIRS "${RADIX_INCLUDE_DIRS}" PARENT_SCOPE)
set(RADIX_DEFINITIONS "${RADIX_DEFINITIONS}" PARENT_SCOPE)
endif ()
#### UNIT TESTING ####
include_directories(${RADIX_INCLUDE_DIRS} ${UnitTestPlusPlus_INCLUDE_DIRS})
enable_testing()
add_subdirectory(tests)
if (CMAKE_VERSION VERSION_GREATER 2.8.5)
include(FeatureSummary)
feature_summary(WHAT ALL)
endif ()