-
Notifications
You must be signed in to change notification settings - Fork 17
/
CMakeLists.txt
231 lines (203 loc) · 6.74 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
228
229
230
cmake_minimum_required (VERSION 2.8)
project (voxelTerrain)
# The version number.
set (blub_VERSION_MAJOR 1)
set (blub_VERSION_MINOR 2)
# Initialize CXXFLAGS.
if (NOT MSVC)
set(CMAKE_CXX_FLAGS "-Wall -std=c++11 -Wno-unused-variable ${CMAKE_CXX_FLAGS}")
endif()
#set(CMAKE_CXX_FLAGS_DEBUG "-O0 -g -D_DEBUG")
#set(CMAKE_CXX_FLAGS_MINSIZEREL "-Os -DNDEBUG")
#set(CMAKE_CXX_FLAGS_RELEASE "-O3 -DNDEBUG")
#set(CMAKE_CXX_FLAGS_RELWITHDEBINFO "-O2 -g")
set(CMAKE_DEBUG_POSTFIX "_d")
# Compiler-specific C++11 activation.
if ("${CMAKE_CXX_COMPILER_ID}" MATCHES "GNU")
execute_process(
COMMAND ${CMAKE_CXX_COMPILER} -dumpversion OUTPUT_VARIABLE GCC_VERSION)
if (NOT (GCC_VERSION VERSION_GREATER 4.7 OR GCC_VERSION VERSION_EQUAL 4.7))
message(FATAL_ERROR "${PROJECT_NAME} requires g++ 4.7 or greater.")
endif ()
elseif ("${CMAKE_CXX_COMPILER_ID}" MATCHES "Clang")
# for ccache
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Qunused-arguments")
elseif (MSVC AND NOT (MSVC_VERSION LESS 1700)) # minimum Visual Studio 2012 (msvc11)
set (CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} /wd4305 /wd4244 /EHsc")
else ()
message(FATAL_ERROR "Your C++ compiler does not support C++11. CMAKE_CXX_COMPILER_ID:${CMAKE_CXX_COMPILER_ID} ${MSVC_VERSION}")
endif ()
# options
if (NOT MSVC)
option (BUILD_SHARED_LIBS "build as shared libraries" ON)
else()
option (BUILD_SHARED_LIBS "build as shared libraries" OFF)
if (BUILD_SHARED_LIBS)
message( FATAL_ERROR "Only static-library-building is supported, because libblub misses Microsofts __declspec(...). - We'll fix." )
endif()
endif(NOT MSVC)
option (BLUB_BUILD_ASYNC "build async" ON)
#option (BLUB_BUILD_DATABASE "build database" ON)
#option (BLUB_BUILD_GRAPHIC "build graphic" ON)
#option (BLUB_BUILD_GUI "build gui" ON)
#option (BLUB_BUILD_INPUT "build input" ON)
option (BLUB_BUILD_MATH "build math" ON)
#option (BLUB_BUILD_NETWORK "build network" ON)
#option (BLUB_BUILD_PHYSIC "build physic" ON)
option (BLUB_BUILD_PROCEDURAL "build graphic" ON)
option (BLUB_BUILD_SERIALIZATION "build serialization" ON)
#option (BLUB_BUILD_SIGNALS "build signals" ON)
option (BLUB_BUILD_SYNC "build sync" ON)
#option (BLUB_BUILD_WEB "build web" ON)
option (BLUB_BUILD_EXAMPLES "build examples" ON)
#option (BLUB_BUILD_TESTS "build tests" ON)
option (BLUB_USE_ASSIMP "use assimp" OFF)
#option (BLUB_USE_BULLET "use bullet" ON)
#option (BLUB_USE_PHYSX "use physx" OFF)
#option (BLUB_USE_CEF3 "use cef3" ON)
option (BLUB_USE_OGRE3D "use ogre3d" ON)
option (BLUB_USE_OIS "use ois" ON)
#option (BLUB_USE_SOCI "use soci" ON)
unset (LIBS)
set(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} "${CMAKE_SOURCE_DIR}/cmake/Modules/")
# find boost
ADD_DEFINITIONS( -DBOOST_ALL_DYN_LINK )
if (NOT MSVC)
set( BOOST_ROOT "/usr/local" CACHE PATH "boost root")
else()
set( BOOST_ROOT "C:/local" CACHE PATH "boost root")
endif()
IF(NOT EXISTS ${BOOST_ROOT})
message(FATAL_ERROR "Could not find boost root: ${BOOST_ROOT}")
endif ()
if (MSVC)
find_package(Boost 1.55.0 REQUIRED COMPONENTS log log_setup system thread chrono date_time iostreams serialization unit_test_framework filesystem )
else()
find_package(Boost 1.55.0 REQUIRED COMPONENTS log log_setup system thread chrono date_time iostreams serialization unit_test_framework )
endif()
set (INCLUDES ${INCLUDES}
${Boost_INCLUDE_DIRS}
)
set (LIBS ${LIBS}
${Boost_LIBRARIES}
)
# find bzip2
if (NOT MSVC)
find_package(BZip2 REQUIRED)
set (LIBS ${LIBS}
${BZIP2_LIBRARIES}
)
endif()
# ogre3d
if(BLUB_USE_OGRE3D)
find_package(OGRE REQUIRED)
set (INCLUDES ${INCLUDES}
${OGRE_INCLUDE_DIRS}
)
set (LIBS ${LIBS}
${OGRE_LIBRARIES}
)
endif(BLUB_USE_OGRE3D)
# ois
if(BLUB_USE_OIS)
find_package(OIS REQUIRED)
set (INCLUDES ${INCLUDES}
${OIS_INCLUDE_DIRS}
)
set (LIBS ${LIBS}
${OIS_LIBRARIES}
)
endif(BLUB_USE_OIS)
# assimp
if(BLUB_USE_ASSIMP)
find_package(Assimp REQUIRED)
set (INCLUDES ${INCLUDES}
${ASSIMP_INCLUDE_DIRS}
)
set (LIBS ${LIBS}
${ASSIMP_LIBRARIES}
)
endif(BLUB_USE_ASSIMP)
if (BLUB_BUILD_DATABASE)
set( BLUB_LIBRARIES_TO_BUILD ${BLUB_LIBRARIES_TO_BUILD} database)
endif (BLUB_BUILD_DATABASE)
if (BLUB_BUILD_PHYSIC)
set( BLUB_LIBRARIES_TO_BUILD ${BLUB_LIBRARIES_TO_BUILD} physic)
endif (BLUB_BUILD_PHYSIC)
if (BLUB_BUILD_GRAPHIC)
set( BLUB_LIBRARIES_TO_BUILD ${BLUB_LIBRARIES_TO_BUILD} graphic)
endif (BLUB_BUILD_GRAPHIC)
if (BLUB_BUILD_INPUT)
set( BLUB_LIBRARIES_TO_BUILD ${BLUB_LIBRARIES_TO_BUILD} input)
endif (BLUB_BUILD_INPUT)
if (BLUB_BUILD_ASYNC)
set( BLUB_LIBRARIES_TO_BUILD ${BLUB_LIBRARIES_TO_BUILD} async)
endif (BLUB_BUILD_ASYNC)
if (BLUB_BUILD_GUI)
set( BLUB_LIBRARIES_TO_BUILD ${BLUB_LIBRARIES_TO_BUILD} gui)
endif (BLUB_BUILD_GUI)
if (BLUB_BUILD_MATH)
set( BLUB_LIBRARIES_TO_BUILD ${BLUB_LIBRARIES_TO_BUILD} math)
endif (BLUB_BUILD_MATH)
if (BLUB_BUILD_NETWORK)
set( BLUB_LIBRARIES_TO_BUILD ${BLUB_LIBRARIES_TO_BUILD} network)
endif (BLUB_BUILD_NETWORK)
if (BLUB_BUILD_PROCEDURAL)
set( BLUB_LIBRARIES_TO_BUILD ${BLUB_LIBRARIES_TO_BUILD} procedural)
endif (BLUB_BUILD_PROCEDURAL)
#if (BLUB_BUILD_SERIALIZATION)
# set( BLUB_LIBRARIES_TO_BUILD ${BLUB_LIBRARIES_TO_BUILD} serialization)
#endif (BLUB_BUILD_SERIALIZATION)
if (BLUB_BUILD_SIGNALS)
set( BLUB_LIBRARIES_TO_BUILD ${BLUB_LIBRARIES_TO_BUILD} signals)
endif (BLUB_BUILD_SIGNALS)
if (BLUB_BUILD_SYNC)
set( BLUB_LIBRARIES_TO_BUILD ${BLUB_LIBRARIES_TO_BUILD} sync)
endif (BLUB_BUILD_SYNC)
if (BLUB_BUILD_WEB)
set( BLUB_LIBRARIES_TO_BUILD ${BLUB_LIBRARIES_TO_BUILD} web)
endif (BLUB_BUILD_WEB)
set( BLUB_LIBRARIES_TO_BUILD ${BLUB_LIBRARIES_TO_BUILD}
core
log
serialization
)
# create config files
# globals.hpp
# config includes created at the documents end
set (INCLUDES ${INCLUDES}
"${PROJECT_BINARY_DIR}/config_files/"
"${PROJECT_BINARY_DIR}/config_files/blub/core"
)
configure_file (
"${PROJECT_SOURCE_DIR}/modules/core/source/blub/core/globals.hpp.in"
"${PROJECT_BINARY_DIR}/config_files/blub/core/globals.hpp"
)
# for the "export.hpp"s
include (GenerateExportHeader)
#ADD_COMPILER_EXPORT_FLAGS()
# a macro to prefix list of strings
macro (prefix_list prefix list result)
foreach(to_prefix ${${list}})
set(${result} ${${result}} "${prefix}${to_prefix}")
endforeach(to_prefix)
endmacro (prefix_list)
# add all includes - every module shall know about each header
foreach(LIB_TO_BUILD ${BLUB_LIBRARIES_TO_BUILD})
set (INCLUDES ${INCLUDES}
${PROJECT_SOURCE_DIR}/modules/${LIB_TO_BUILD}/source
)
endforeach(LIB_TO_BUILD)
# add modules
add_subdirectory(modules)
# do examples
if (BLUB_BUILD_EXAMPLES)
add_subdirectory(examples)
endif(BLUB_BUILD_EXAMPLES)
# do tests
if (BLUB_BUILD_TESTS)
add_subdirectory(tests)
endif(BLUB_BUILD_TESTS)
install (DIRECTORY "${PROJECT_BINARY_DIR}/config_files/"
DESTINATION include
FILES_MATCHING PATTERN "*.hpp")