forked from solidoss/solidframe
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathCMakeLists.txt
378 lines (314 loc) · 13.3 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
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
cmake_minimum_required(VERSION 2.6)
#-----------------------------------------------------------------
# The project
#-----------------------------------------------------------------
project (SolidFrame)
#-----------------------------------------------------------------
#-----------------------------------------------------------------
# Project version
#-----------------------------------------------------------------
file (READ "${CMAKE_SOURCE_DIR}/VERSION" VERSION)
string (REPLACE "\n" "" VERSION ${VERSION})
string (REPLACE "\r" "" VERSION ${VERSION})
string (REGEX REPLACE "^([0-9]*)\\.([0-9]*)\\.([0-9]*)" "\\1" VERSION_MAJOR ${VERSION})
string (REGEX REPLACE "^([0-9]*)\\.([0-9]*)\\.([0-9]*)" "\\2" VERSION_MINOR ${VERSION})
string (REGEX REPLACE "^([0-9]*)\\.([0-9]*)\\.([0-9]*)" "\\3" VERSION_PATCH ${VERSION})
exec_program(
"git"
${CMAKE_CURRENT_SOURCE_DIR}
ARGS "rev-parse HEAD"
OUTPUT_VARIABLE GIT_VERSION )
#string( REGEX MATCH "-g.*$" VERSION_SHA1 ${GIT_VERSION} )
#string( REGEX REPLACE "[-g]" "" VERSION_SHA1 "${VERSION_SHA1}" )
set(VERSION_PATCH "${GIT_VERSION}")
#-----------------------------------------------------------------
#-----------------------------------------------------------------
# Extra user definitions
#-----------------------------------------------------------------
set(EXTRA_DEFINITIONS "${UDEFS}" CACHE STRING "Extra compiler definitions")
add_definitions(${EXTRA_DEFINITIONS})
#-----------------------------------------------------------------
#-----------------------------------------------------------------
# Prepare the extern path
#-----------------------------------------------------------------
string(LENGTH "${UEXTERN}" ExtLen)
set(EXTERN_PATH "${UEXTERN}/" CACHE STRING "Extern prerequisites path")
message("Using prerequisites from: \"${EXTERN_PATH}\"")
#-----------------------------------------------------------------
# Find libraries
#-----------------------------------------------------------------
include(cmake/find_boost.cmake)
include(cmake/find_openssl.cmake)
include(cmake/find_leveldb.cmake)
include(cmake/find_snappy.cmake)
#-----------------------------------------------------------------
# Prepare the definitions for build types
#-----------------------------------------------------------------
string(TOLOWER "${CMAKE_BUILD_TYPE}" CMAKE_BUILD_TYPE)
if(CMAKE_BUILD_TYPE STREQUAL "maintain")
set(CMAKE_VERBOSE_MAKEFILE ON)
set(SOLID_HAS_DEBUG TRUE)
set(SOLID_HAS_STATISTICS TRUE)
set(SOLID_HAS_ASSERT TRUE)
endif(CMAKE_BUILD_TYPE STREQUAL "maintain")
if(CMAKE_BUILD_TYPE STREQUAL "debug")
set(CMAKE_VERBOSE_MAKEFILE ON)
set(SOLID_HAS_DEBUG TRUE)
set(SOLID_HAS_NO_INLINES TRUE)
set(SOLID_HAS_STATISTICS TRUE)
set(SOLID_HAS_ASSERT TRUE)
endif(CMAKE_BUILD_TYPE STREQUAL "debug")
if(CMAKE_BUILD_TYPE STREQUAL "nolog")
set(CMAKE_VERBOSE_MAKEFILE ON)
set(SOLID_HAS_NO_INLINES TRUE)
set(SOLID_HAS_ASSERT TRUE)
endif(CMAKE_BUILD_TYPE STREQUAL "nolog")
set(SOLID_VERSION_MAJOR ${VERSION_MAJOR})
set(SOLID_VERSION_MINOR ${VERSION_MINOR})
set(SOLID_VERSION_PATCH ${VERSION_PATCH})
set(SYS_DEBUG_FLAGS "")
set(SYS_MAINTAIN_FLAGS "")
set(SYS_OPTIMIZED_FLAGS "")
set(SYS_NOLOG_FLAGS "")
set(SYS_RELEASE_FLAGS "")
set(SYS_DEBUG_LINKER_FLAGS "")
set(SYS_MAINTAIN_LINKER_FLAGS "")
set(SYS_OPTIMIZED_LINKER_FLAGS "")
set(SYS_NOLOG_LINKER_FLAGS "")
set(SYS_RELEASE_LINKER_FLAGS "")
set(SYS_BASIC_LIBS "")
set(SYS_DYNAMIC_LOAD_LIB "")
message("")
message("CMake's system: ${CMAKE_SYSTEM}")
message("")
set(ON_FOUND FALSE)
set(SOLID_ON_FREEBSD FALSE)
set(SOLID_ON_DARWIN FALSE)
set(SOLID_ON_LINUX FALSE)
set(SOLID_ON_POSIX FALSE)
set(SOLID_ON_SOLARIS FALSE)
set(SOLID_ON_WINDOWS FALSE)
if(CMAKE_SYSTEM MATCHES "SunOS*")
message("Detected system ON_SOLARIS")
set(ON_FOUND TRUE)
set(SOLID_ON_SOLARIS TRUE)
set(SOLID_ON_POSIX TRUE)
set(SYS_DEBUG_FLAGS "-features=extensions -library=stlport4 -mt -g")
set(SYS_MAINTAIN_FLAGS "-features=extensions -library=stlport4 -mt")
set(SYS_OPTIMIZED_FLAGS "-features=extensions -library=stlport4 -mt")
set(SYS_NOLOG_FLAGS "-features=extensions -library=stlport4 -mt")
set(SYS_RELEASE_FLAGS "-features=extensions -library=stlport4 -mt")
set(SYS_BASIC_LIBS pthread socket nsl)
endif(CMAKE_SYSTEM MATCHES "SunOS*")
if(CMAKE_SYSTEM MATCHES "FreeBSD*")
message("Detected system ON_FREEBSD")
set(ON_FOUND TRUE)
set(SOLID_ON_FREEBSD TRUE)
set(SOLID_ON_POSIX TRUE)
set(SYS_DEBUG_FLAGS "-Wreorder -Wreturn-type -Wunused-variable -Winline -g3")
set(SYS_MAINTAIN_FLAGS "-Wall -Wabi -O3 -g3")
set(SYS_OPTIMIZED_FLAGS "-O3 -g3")
set(SYS_NOLOG_FLAGS "-g3")
set(SYS_RELEASE_FLAGS "-O3")
set(SYS_DEBUG_LINKER_FLAGS "")
set(SYS_MAINTAIN_LINKER_FLAGS "-Wl,--warn-unresolved-symbols,--warn-once")
set(SYS_OPTIMIZED_LINKER_FLAGS "")
set(SYS_NOLOG_LINKER_FLAGS "")
set(SYS_RELEASE_LINKER_FLAGS "")
set(SYS_BASIC_LIBS pmc pthread rt)
endif(CMAKE_SYSTEM MATCHES "FreeBSD*")
if(CMAKE_SYSTEM MATCHES "Darwin*")
message("Detected system ON_DARWIN")
set(ON_FOUND TRUE)
set(SOLID_ON_DARWIN TRUE)
set(SOLID_ON_POSIX TRUE)
set(SYS_DEBUG_FLAGS "-Wreorder -Wreturn-type -Wunused-variable -Winline -g3")
set(SYS_MAINTAIN_FLAGS "-Wall -Wabi -O3 -g3")
set(SYS_OPTIMIZED_FLAGS "-O3 -g3")
set(SYS_NOLOG_FLAGS "-g3")
set(SYS_RELEASE_FLAGS "-O3")
set(SYS_DEBUG_LINKER_FLAGS "-framework ApplicationServices -framework CoreFoundation")
set(SYS_MAINTAIN_LINKER_FLAGS "-framework ApplicationServices -framework CoreFoundation")
set(SYS_OPTIMIZED_LINKER_FLAGS "-framework ApplicationServices -framework CoreFoundation")
set(SYS_NOLOG_LINKER_FLAGS "-framework ApplicationServices -framework CoreFoundation")
set(SYS_RELEASE_LINKER_FLAGS "-framework ApplicationServices -framework CoreFoundation")
set(SYS_BASIC_LIBS pthread)
endif(CMAKE_SYSTEM MATCHES "Darwin*")
if(CMAKE_SYSTEM MATCHES "Linux*")
message("Detected system ON_LINUX")
set(ON_FOUND TRUE)
set(SOLID_ON_LINUX TRUE)
set(SOLID_ON_POSIX TRUE)
set(SYS_DEBUG_FLAGS "-Wreorder -Wreturn-type -Wunused-variable -Winline -g3")# -D_GLIBCXX_DEBUG
set(SYS_MAINTAIN_FLAGS "-Wall -Wabi -O3 -g3")
set(SYS_OPTIMIZED_FLAGS "-O3 -g3")
set(SYS_NOLOG_FLAGS "-g3")
set(SYS_RELEASE_FLAGS "-O3")
set(SYS_DEBUG_LINKER_FLAGS "")# -D_GLIBCXX_DEBUG
set(SYS_MAINTAIN_LINKER_FLAGS "-Wl,--warn-unresolved-symbols,--warn-once")
set(SYS_OPTIMIZED_LINKER_FLAGS "")
set(SYS_NOLOG_LINKER_FLAGS "")
set(SYS_RELEASE_LINKER_FLAGS "-O3")
set(SYS_BASIC_LIBS pthread rt)
set(SYS_DYNAMIC_LOAD_LIB dl)
endif(CMAKE_SYSTEM MATCHES "Linux*")
if(CMAKE_SYSTEM MATCHES "Windows*")
message("Detected system ON_WINDOWS")
set(ON_FOUND TRUE)
set(SOLID_ON_WINDOWS TRUE)
set(SYS_DEBUG_FLAGS "-DSOLID_ON_WINDOWS -D_CRT_SECURE_NO_WARNINGS -D_WIN32_WINNT=0x0600 /Zi /Od")
set(SYS_MAINTAIN_FLAGS "-DSOLID_ON_WINDOWS -D_CRT_SECURE_NO_WARNINGS -D_WIN32_WINNT=0x0600 /Zi /Od")
set(SYS_OPTIMIZED_FLAGS "-DSOLID_ON_WINDOWS -D_CRT_SECURE_NO_WARNINGS -D_WIN32_WINNT=0x0600 /Ox /Zi")
set(SYS_NOLOG_FLAGS "-DSOLID_ON_WINDOWS -D_CRT_SECURE_NO_WARNINGS -D_WIN32_WINNT=0x0600 /Zi /Od")
set(SYS_RELEASE_FLAGS "-DSOLID_ON_WINDOWS -D_CRT_SECURE_NO_WARNINGS -D_WIN32_WINNT=0x0600 /Ox")
set(SYS_DEBUG_LINKER_FLAGS "")
set(SYS_MAINTAIN_LINKER_FLAGS "")
set(SYS_OPTIMIZED_LINKER_FLAGS "")
set(SYS_NOLOG_LINKER_FLAGS "")
set(SYS_RELEASE_LINKER_FLAGS "")
set(SYS_BASIC_LIBS Ws2_32 ${BOOST_THREAD_LIB} ${BOOST_SYSTEM_LIB})
endif(CMAKE_SYSTEM MATCHES "Windows*")
message("")
if(NOT ON_FOUND)
message("\r\n === Sorry unsupported system - please contact project owner ===\r\n")
exit()#only to raise an exception
return()
endif(NOT ON_FOUND)
#-----------------------------------------------------------------
# install prefix
#-----------------------------------------------------------------
if(NOT (UINSTALL_PREFIX STREQUAL ""))
set(CMAKE_INSTALL_PREFIX "${UINSTALL_PREFIX}")
message("Using install prefix: ${CMAKE_INSTALL_PREFIX}")
endif(NOT (UINSTALL_PREFIX STREQUAL ""))
#-----------------------------------------------------------------
# config.h support
#-----------------------------------------------------------------
include(cmake/check.config.cmake)
configure_file(${CMAKE_CURRENT_SOURCE_DIR}/cmake/config.h.in ${CMAKE_CURRENT_BINARY_DIR}/solid/solid_config.hpp)
install (FILES ${CMAKE_CURRENT_BINARY_DIR}/solid/solid_config.hpp DESTINATION include/solid)
if(SOLID_USE_CPP11FLAG AND SOLID_USE_CPP11)
set(SYS_DEBUG_FLAGS "${SYS_DEBUG_FLAGS} -std=c++11")
set(SYS_MAINTAIN_FLAGS "${SYS_MAINTAIN_FLAGS} -std=c++11")
set(SYS_OPTIMIZED_FLAGS "${SYS_OPTIMIZED_FLAGS} -std=c++11")
set(SYS_NOLOG_FLAGS "${SYS_NOLOG_FLAGS} -std=c++11")
set(SYS_RELEASE_FLAGS "${SYS_RELEASE_FLAGS} -std=c++11")
endif(SOLID_USE_CPP11FLAG AND SOLID_USE_CPP11)
if(NOT SOLID_USE_CPP11)
set(SYS_BASIC_LIBS ${SYS_BASIC_LIBS} ${BOOST_SYSTEM_LIB})
endif(NOT SOLID_USE_CPP11)
#-----------------------------------------------------------------
#-----------------------------------------------------------------
# Debug build
#-----------------------------------------------------------------
set(CMAKE_CXX_FLAGS_DEBUG
"${SYS_DEBUG_FLAGS}"
CACHE STRING "Flags used by the C++ compiler during debug builds."
FORCE
)
#-----------------------------------------------------------------
#-----------------------------------------------------------------
# Maintain build
#-----------------------------------------------------------------
set(CMAKE_CXX_FLAGS_MAINTAIN
"${SYS_MAINTAIN_FLAGS}"
CACHE STRING "Flags used by the C++ compiler during maintain builds."
FORCE
)
set(CMAKE_EXE_LINKER_FLAGS_MAINTAIN
"${SYS_MAINTAIN_LINKER_FLAGS}"
CACHE STRING "Flags used for linking binaries during maintain builds."
FORCE
)
set(CMAKE_SHARED_LINKER_FLAGS_MAINTAIN
"${SYS_MAINTAIN_LINKER_FLAGS}"
CACHE STRING "Flags used by the shared libraries linker during maintain builds."
FORCE
)
#-----------------------------------------------------------------
#-----------------------------------------------------------------
# Optimized build
#-----------------------------------------------------------------
set(CMAKE_CXX_FLAGS_OPTIMIZED
"${SYS_OPTIMIZED_FLAGS}"
CACHE STRING "Flags used by the C++ compiler during optimized builds."
FORCE
)
#-----------------------------------------------------------------
#-----------------------------------------------------------------
# Release build
#-----------------------------------------------------------------
set(CMAKE_CXX_FLAGS_RELEASE
"${SYS_RELEASE_FLAGS}"
CACHE STRING "Flags used by the C++ compiler during release builds."
FORCE
)
#-----------------------------------------------------------------
#-----------------------------------------------------------------
# Nolog build
#-----------------------------------------------------------------
set(CMAKE_CXX_FLAGS_NOLOG
"${SYS_NOLOG_FLAGS}"
CACHE STRING "Flags used by the C++ compiler during nolog builds."
FORCE
)
#-----------------------------------------------------------------
#-----------------------------------------------------------------
mark_as_advanced(
CMAKE_CXX_FLAGS_NOLOG
CMAKE_C_FLAGS_NOLOG
CMAKE_EXE_LINKER_FLAGS_NOLOG
CMAKE_SHARED_LINKER_FLAGS_NOLOG
)
#-----------------------------------------------------------------
mark_as_advanced(
CMAKE_CXX_FLAGS_MAINTAIN
CMAKE_C_FLAGS_MAINTAIN
CMAKE_EXE_LINKER_FLAGS_MAINTAIN
CMAKE_SHARED_LINKER_FLAGS_MAINTAIN
)
#-----------------------------------------------------------------
mark_as_advanced(
CMAKE_CXX_FLAGS_OPTIMIZED
CMAKE_C_FLAGS_OPTIMIZED
CMAKE_EXE_LINKER_FLAGS_OPTIMIZED
CMAKE_SHARED_LINKER_FLAGS_OPTIMIZED
)
#-----------------------------------------------------------------
#-----------------------------------------------------------------
# Update the documentation string of CMAKE_BUILD_TYPE for GUIs
#-----------------------------------------------------------------
set(CMAKE_BUILD_TYPE
"${CMAKE_BUILD_TYPE}"
CACHE STRING "Choose the type of build, options are: None Debug Release RelWithDebInfo MinSizeRel nolog maintain optimized:"
FORCE
)
#-----------------------------------------------------------------
#-----------------------------------------------------------------
# Global include directories
#-----------------------------------------------------------------
include_directories(
${SolidFrame_SOURCE_DIR}
${CMAKE_CURRENT_BINARY_DIR}
${EXTERN_PATH}/include/
)
#-----------------------------------------------------------------
#-----------------------------------------------------------------
# Global link directories
#-----------------------------------------------------------------
link_directories(
${CMAKE_CURRENT_SOURCE_DIR}
${EXTERN_PATH}/lib
)
#-----------------------------------------------------------------
# Testing support (CTest & CDash)
#-----------------------------------------------------------------
ENABLE_TESTING()
INCLUDE(CTest)
#-----------------------------------------------------------------
# Project subdirectories
#-----------------------------------------------------------------
add_subdirectory (solid)
add_subdirectory (examples)
add_subdirectory (tutorials)
#-----------------------------------------------------------------