-
Notifications
You must be signed in to change notification settings - Fork 6
/
CMakeLists.txt
271 lines (224 loc) · 7.98 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
CMAKE_MINIMUM_REQUIRED(VERSION 2.6)
##################################################
# Find extra cmake modules dirs
#
# You can clone all modules from https://ssl.izenesoft.cn/projects/cmake
#
# Clone it and set environment variable EXTRA_CMAKE_MODULES_DIRS point to it.
#
SET(ENV_EXTRA_CMAKE_MODULES_DIRS $ENV{EXTRA_CMAKE_MODULES_DIRS})
IF(ENV_EXTRA_CMAKE_MODULES_DIRS)
SET(EXTRA_CMAKE_MODULES_DIRS ${EXTRA_CMAKE_MODULES_DIRS} ${ENV_EXTRA_CMAKE_MODULES_DIRS})
ENDIF(ENV_EXTRA_CMAKE_MODULES_DIRS)
IF(NOT EXTRA_CMAKE_MODULES_DIRS)
MESSAGE(FATAL_ERROR
"Cannot find EXTRA_CMAKE_MODULES_DIRS.
1. Please clone it from https://ssl.izenesoft.cn/cmake.
2. Then set EXTRA_CMAKE_MODULES_DIRS through environment variable
export EXTRA_CMAKE_MODULES_DIRS=/path/to/cmake
You can put it in your .bashrc so it is loaded automatically.
or cmake options
cmake -DEXTRA_CMAKE_MODULES_DIRS=/path/to/cmake (other options)
")
ENDIF(NOT EXTRA_CMAKE_MODULES_DIRS)
SET(CMAKE_MODULE_PATH ${EXTRA_CMAKE_MODULES_DIRS})
# force out-of-source build
IF (CMAKE_BINARY_DIR STREQUAL CMAKE_SOURCE_DIR)
MESSAGE(FATAL_ERROR "In source build is not allowed")
ENDIF (CMAKE_BINARY_DIR STREQUAL CMAKE_SOURCE_DIR)
##################################################
# Project and some options
#####
PROJECT(IDMLIB)
OPTION(VERBOSE "print detailed configure messages" ON)
OPTION(ENABLE_TEST "build test applications?" ON)
##################################################
# BUILD TYPE & OPTIONS
#
# Put this section just under PROJECT
#####
# Use BUILD_FLAGS_HAS_BEEN_CUSTOMIZED as guard.
#
# The options are only customized in first run. User can edit cache to
# set their own options. If it's required to customized these in cmake
# command line options, please also add
# "-DBUILD_FLAGS_HAS_BEEN_CUSTOMIZED".
IF (CMAKE_COMPILER_IS_GNUCXX)
INCLUDE(MacroSetBuildTypes)
MACRO_SET_BUILD_TYPES(
RelWithDebInfo
"-march=native -mtune=native -O2 -g -DNDEBUG -Wno-deprecated -std=c++11 "
"Flags used by the compiler during Release with Debug Info builds."
Release
"-march=native -mtune=native -O3 -DNDEBUG -Wno-deprecated -std=c++11 "
"Flags used by the compiler during release builds"
MinSizeRel
"-march=native -mtune=native -Os -DNDEBUG -Wno-deprecated -std=c++11 "
"Flags used by the compiler during release minsize builds."
Debug
"-march=native -mtune=native -g -O0 -fno-reorder-blocks -fno-schedule-insns -fno-inline -Wno-deprecated -std=c++11 "
"Flags used by the compiler during debug builds."
DebugFull
"-march=native -mtune=native -g3 -fno-inline -Wno-deprecated -std=c++11 "
"Debugfull build type"
Profile
"-march=native -mtune=native -g -O0 -fno-inline -ftest-coverage -fprofile-arcs -Wno-deprecated -std=c++11 "
"Profile build type"
)
ENDIF (CMAKE_COMPILER_IS_GNUCXX)
INCLUDE(MacroSetDefaultBuildType)
MACRO_SET_DEFAULT_BUILD_TYPE(RelWithDebInfo)
INCLUDE(SetCompilerWarningAll)
# Write to cache
SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS}" CACHE STRING
"Flags used by the compiler during all build types." FORCE)
SET(CMAKE_C_FLAGS "${CMAKE_C_FLAGS}" CACHE STRING
"Flags used by the compiler during all build types." FORCE)
# build shared libs by default
OPTION(BUILD_SHARED_LIBS "Build shared libraries?" ON)
##################################################
# Check Dependencies
####
INCLUDE(SetPkgConfigPath)
INCLUDE(ConfigureChecks.cmake)
##################################################
# Install Headers
#####
# trailing / is required, otherwise dectory name is appended to
# install directory.
INSTALL(
DIRECTORY include/
DESTINATION include
COMPONENT "iDMlib_headers"
)
##################################################
# Config File
#####
##################################################
# Sub Directories
#####
# macros
INCLUDE(MacroCheckShouldBuild)
# all headers
include_directories(
${IDMLIB_SOURCE_DIR}/include
${Boost_INCLUDE_DIRS}
${izenelib_INCLUDE_DIRS}
${izenecma_INCLUDE_DIRS}
${izenejma_INCLUDE_DIRS}
${ilplib_INCLUDE_DIRS}
${XML2_INCLUDE_DIRS}
${Glog_INCLUDE_DIRS}
${LibCURL_INCLUDE_DIRS}
${OpenSSL_INCLUDE_DIRS}
#${ImageMagick_INCLUDE_DIRS}
)
SET(libs
${izenelib_LIBRARIES}
${ilplib_LIBRARIES}
${XML2_LIBRARIES}
${Boost_LIBRARIES}
${Glog_LIBRARIES}
${LibCURL_LIBRARIES}
${OpenSSL_LIBRARIES}
# ${ImageMagick_LIBRARIES}
)
MESSAGE(STATUS "include path: ${include_directories}")
# User can decide which to build using:
# USER_BUILD_LIST, USER_IGNORE_LIST
SET_PROPERTY(GLOBAL PROPERTY BUILD_COMPONENTS)
SET_PROPERTY(GLOBAL PROPERTY NON_BUILD_COMPONENTS)
MARK_AS_ADVANCED(BUILD_COMPONENTS NON_BUILD_COMPONENTS)
SET(LIBRARY_OUTPUT_PATH "${IDMLIB_SOURCE_DIR}/lib")
SET(EXECUTABLE_OUTPUT_PATH ${IDMLIB_SOURCE_DIR}/testbin)
ADD_SUBDIRECTORY(source)
GET_PROPERTY(REAL_BUILD_COMPONENTS GLOBAL PROPERTY BUILD_COMPONENTS)
GET_PROPERTY(REAL_NON_BUILD_COMPONENTS GLOBAL PROPERTY NON_BUILD_COMPONENTS)
# Test cases and applications
IF(ENABLE_TEST)
ADD_SUBDIRECTORY(test)
ENDIF(ENABLE_TEST)
##################################################
# Messages
#####
IF(VERBOSE)
MESSAGE(STATUS "========================================")
MESSAGE(STATUS "CMAKE_INSTALL_PREFIX: ${CMAKE_INSTALL_PREFIX}")
MESSAGE(STATUS "CMAKE_BUILD_TYPE: ${CMAKE_BUILD_TYPE}")
STRING(TOUPPER "${CMAKE_BUILD_TYPE}" CMAKE_BUILD_TYPE_UPPER)
MESSAGE(STATUS " corresponding flags: ${CMAKE_CXX_FLAGS_${CMAKE_BUILD_TYPE_UPPER}}")
MESSAGE(STATUS "CMAKE_CXX_FLAGS: ${CMAKE_CXX_FLAGS}")
MESSAGE(STATUS "CMAKE_EXE_LINKER_FLAGS: ${CMAKE_EXE_LINKER_FLAGS}")
MESSAGE(STATUS "----------------------------------------")
MESSAGE(STATUS "${izenecma_INCLUDE_DIRS}")
IF(Boost_FOUND)
MESSAGE(STATUS "BOOST:")
MESSAGE(STATUS " header: ${Boost_INCLUDE_DIR}")
MESSAGE(STATUS " version: ${Boost_MAJOR_VERSION}.${Boost_MINOR_VERSION}.${Boost_SUBMINOR_VERSION}")
ELSE(Boost_FOUND)
MESSAGE(STATUS "BOOST: not found")
ENDIF(Boost_FOUND)
IF(ilplib_FOUND)
MESSAGE(STATUS "ilplib library:")
MESSAGE(STATUS " header: ${ilplib_INCLUDE_DIRS}")
MESSAGE(STATUS " lib: ${ilplib_LIBRARIES}")
ELSE(ilplib_FOUND)
MESSAGE(STATUS "ilplib library: not found")
ENDIF(ilplib_FOUND)
IF(XML2_FOUND)
MESSAGE(STATUS "LIBXML2:")
MESSAGE(STATUS " header: ${XML2_INCLUDE_DIR}")
MESSAGE(STATUS " lib: ${XML2_LIBRARIES}")
ELSE(XML2_FOUND)
MESSAGE(STATUS "LIBXML2: not found")
ENDIF(XML2_FOUND)
IF(Threads_FOUND)
MESSAGE(STATUS "Threads Library: ${CMAKE_THREAD_LIBS_INIT}")
ELSE(Threads_FOUND)
MESSAGE(STATUS "Threads Library: none")
ENDIF(Threads_FOUND)
IF(Glog_FOUND)
MESSAGE(STATUS "Google Glog:")
MESSAGE(STATUS " header: ${Glog_INCLUDE_DIRS}")
MESSAGE(STATUS " libs: ${Glog_LIBRARIES}")
ELSE(Glog_FOUND)
MESSAGE(STATUS "Google Glog: not found")
ENDIF(Glog_FOUND)
IF(LibCURL_FOUND)
MESSAGE(STATUS "libcurl:")
MESSAGE(STATUS " header: ${LibCURL_INCLUDE_DIRS}")
MESSAGE(STATUS " lib: ${LibCURL_LIBRARIES}")
ELSE(LibCURL_FOUND)
MESSAGE(STATUS "libcurl: not found!")
ENDIF(LibCURL_FOUND)
IF(OpenSSL_FOUND)
MESSAGE(STATUS "openssl:")
MESSAGE(STATUS " header: ${OpenSSL_INCLUDE_DIRS}")
MESSAGE(STATUS " lib: ${OpenSSL_LIBRARIES}")
ELSE(OpenSSL_FOUND)
MESSAGE(STATUS "openssl: not found!")
ENDIF(OpenSSL_FOUND)
MESSAGE(STATUS "----------------------------------------")
MESSAGE(STATUS "COMPONENTS BUILD:")
FOREACH(c ${REAL_BUILD_COMPONENTS})
MESSAGE(STATUS " ${c}")
ENDFOREACH(c ${REAL_BUILD_COMPONENTS})
IF(REAL_NON_BUILD_COMPONENTS)
MESSAGE(STATUS "COMPONENTS NOT BUILD:")
FOREACH(c ${REAL_NON_BUILD_COMPONENTS})
MESSAGE(STATUS " ${c}")
ENDFOREACH(c ${REAL_NON_BUILD_COMPONENTS})
ENDIF(REAL_NON_BUILD_COMPONENTS)
MESSAGE(STATUS "========================================")
ENDIF(VERBOSE)
##################################################
# CPack
#####
INCLUDE(UseCPack)
CONFIGURE_FILE(
"idmlib-version.h.cmake"
"${CMAKE_SOURCE_DIR}/include/idmlib-version.h"
@ONLY
)
SET(CPACK_DEBIAN_PACKAGE_DEPENDS
"libboost-dev, libc6-dev, libxml2-dev, izenelib, ilplib, icma")