-
Notifications
You must be signed in to change notification settings - Fork 1
/
CMakeLists.txt
258 lines (199 loc) · 8.87 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
cmake_minimum_required(VERSION 2.8)
#pre-project options
#change compiler setting here
#set(CMAKE_C_COMPILER "/opt/gcc-4.7.2/bin/gcc")
#set(CMAKE_CXX_COMPILER "/opt/gcc-4.7.2/bin/g++")
#set(BOOST_ROOT "")
set(PYTHON_INCLUDE_DIR "/usr/include/python2.6")
set(PYTHON_LIBRARY "/usr/lib64/libpython2.6.so")
#set(JAVA_INCLUDE_PATH)
#set(JNI_INCLUDE_DIRS)
#-Options-----------------------------------------------------------------------------------------
project(mscds)
set(VERSION 0.2.1)
set (CMAKE_VERBOSE_MAKEFILE OFF)
if (NOT CMAKE_BUILD_TYPE)
set (CMAKE_BUILD_TYPE RELEASE CACHE STRING
"Choose the type of build, options are: None Debug Release." FORCE)
endif (NOT CMAKE_BUILD_TYPE)
### Build PYTHON and JAVA API extension settings
option(BUILD_EXT_API "Build Python and Java API" OFF)
SET(USE_SSL OFF CACHE BOOL "Use OpenSSL library" FORCE)
if (WIN32)
set(BUILD_EXT_API OFF)
endif()
MESSAGE(STATUS "C Compiler version: ${CMAKE_C_COMPILER_VERSION}")
MESSAGE(STATUS "C++ Compiler version: ${CMAKE_CXX_COMPILER_VERSION}")
if(CMAKE_COMPILER_IS_GNUCC OR ${CMAKE_CXX_COMPILER_ID} STREQUAL "Clang" OR ${CMAKE_CXX_COMPILER_ID} STREQUAL "Intel")
set(GCC_COMPATIBLE_COMPILER ON)
MESSAGE(STATUS "Found GCC compatible compiler")
else()
set(GCC_COMPATIBLE_COMPILER OFF)
endif()
if (BUILD_EXT_API)
set(BUILD_DYNAMIC_CODE ON) # for dynamic library in Linux
set(LINK_STATIC_LIBS OFF)
elseif(NOT (DEFINED BUILD_DYNAMIC_CODE))
set(BUILD_DYNAMIC_CODE OFF)
set(LINK_STATIC_LIBS ON)
endif()
if (BUILD_DYNAMIC_CODE AND GCC_COMPATIBLE_COMPILER)
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fPIC")
MESSAGE(STATUS "Added flags: -fPIC")
endif()
if (GCC_COMPATIBLE_COMPILER AND (LINK_STATIC_LIBS))
set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} -static-libgcc -static-libstdc++")
# prefer static libraries,
# alternatively can specify the name exactly. e.g. find_library(OPENSSL_LIBRARY NAMES libssl.a ssl)
set(CMAKE_FIND_LIBRARY_SUFFIXES .a .so ${CMAKE_FIND_LIBRARY_SUFFIXES})
MESSAGE(STATUS "Added linker flags: -static-libgcc -static-libstdc++")
endif()
#-------------------------------------------------------------------------------------------------
### Common compiler flags
LIST(APPEND CMAKE_MODULE_PATH ${PROJECT_SOURCE_DIR}/cmake)
include(cmake/function.cmake)
fix_compiler_flags() #defined inside function.cmake
if(GCC_COMPATIBLE_COMPILER)
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++0x -O3 -march=native -g ") #-flto
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wall -Wno-sign-compare -Wno-reorder -Wno-unused-variable -Wno-unused-but-set-variable -Wno-unused-local-typedefs")
elseif(MSVC)
add_definitions(-D_SCL_SECURE_NO_WARNINGS -D_CRT_SECURE_NO_WARNINGS)
# 'expression': unreferenced local variable
#add_definitions(/wd4101)
# 'conversion' conversion from 'type1' to 'type2', possible loss of data
add_definitions(/wd4244)
add_definitions(/wd4267)
# 'expression' : signed/unsigned mismatch
add_definitions(/wd4018)
add_definitions(/D_VARIADIC_MAX=10)
add_definitions(-D_WIN32_WINNT=0x0501)
#add_definitions(/arch:SSE)
endif()
MESSAGE(STATUS "CMAKE_CXX_FLAGS: ${CMAKE_CXX_FLAGS}")
IF(CMAKE_VERSION VERSION_EQUAL "3.0.0" OR
CMAKE_VERSION VERSION_GREATER "3.0.0")
CMAKE_POLICY(SET CMP0026 OLD)
CMAKE_POLICY(SET CMP0045 OLD)
ENDIF()
include(cmake/MergeStaticLibraries.cmake)
### setup directories-------------------------------------------
set (CMAKE_RUNTIME_OUTPUT_DIRECTORY ${PROJECT_BINARY_DIR}/bin
CACHE PATH "Single Directory for all Executables.")
set(TEST_OUTPUT_DIRECTORY ${PROJECT_BINARY_DIR}/tests
CACHE PATH "Directory for testings executables")
set(MODULE_OUTPUT_DIRECTORY ${PROJECT_BINARY_DIR}/modules
CACHE PATH "Directory for python modules")
# .exe = runtime
# .dll = runtime
# .lib = archive (either import lib or static lib)
# .a = archive
# .so = library
SET_PROPERTY(GLOBAL PROPERTY USE_FOLDERS ON)
#---Find BOOST------------------------------------------------------------------------------
set(Boost_USE_MULTI_THREADED ON)
set(Boost_NO_BOOST_CMAKE ON)
set(Boost_NO_SYSTEM_PATHS ON)
if(MSVC)
set(Boost_USE_STATIC_LIBS ON)
endif()
#set(Boost_USE_STATIC_RUNTIME OFF)
if (BUILD_DYNAMIC_CODE)
set(Boost_USE_STATIC_LIBS OFF)
else()
set(Boost_USE_STATIC_RUNTIME ON)
set(Boost_USE_STATIC_LIBS ON)
endif()
find_package(Boost)
if(NOT Boost_FOUND)
set(Boost_NO_BOOST_CMAKE OFF)
set(Boost_NO_SYSTEM_PATHS OFF)
find_package(Boost REQUIRED)
endif()
include_directories(${Boost_INCLUDE_DIRS})
MESSAGE(STATUS "** Boost Include: ${Boost_INCLUDE_DIR}")
MESSAGE(STATUS "** Boost Libraries: ${Boost_LIBRARIES}")
#------------------------------------------------------------------------------------------------
add_subdirectory(${PROJECT_SOURCE_DIR}/ext_libs/gtest) #${PROJECT_BINARY_DIR}/ext_libs/gtest
set(GTEST_INCLUDE_DIRS ${PROJECT_SOURCE_DIR}/ext_libs/gtest/include)
set(GTEST_LIBRARY gtest)
add_subdirectory(${PROJECT_SOURCE_DIR}/ext_libs/snappy)
set(SNAPPY_INCLUDE_DIRS ${PROJECT_SOURCE_DIR}/ext_libs/snappy)
set(SNAPPY_LIBRARY snappy)
add_subdirectory(${PROJECT_SOURCE_DIR}/ext_libs/zlib)
set(ZLIB_INCLUDE_DIRS ${PROJECT_SOURCE_DIR}/ext_libs/zlib)
set(ZLIB_LIBRARY zlibstatic)
add_subdirectory(${PROJECT_SOURCE_DIR}/ext_libs/netlib)
set(NETLIB_INCLUDE_DIRS ${PROJECT_SOURCE_DIR}/ext_libs/netlib)
set(NETLIB_LIBRARIES cppnetlib-uri cppnetlib-client-connections)
include_directories(${GTEST_INCLUDE_DIRS})
#---Interal Utilities-----------------------------------------------------------------------------
configure_file(${CMAKE_CURRENT_SOURCE_DIR}/cmake/runtests.py ${TEST_OUTPUT_DIRECTORY}/runtests.py COPYONLY)
include_directories(${PROJECT_SOURCE_DIR})
#include_directories(${PROJECT_SOURCE_DIR}/framework)
add_subdirectory(${PROJECT_SOURCE_DIR}/mem)
add_subdirectory(${PROJECT_SOURCE_DIR}/utils)
set(COMMON_LIBS mem utils)
########################################################
add_subdirectory(${PROJECT_SOURCE_DIR}/extcodec)
add_subdirectory(${PROJECT_SOURCE_DIR}/bitarray)
add_subdirectory(${PROJECT_SOURCE_DIR}/codec)
add_subdirectory(${PROJECT_SOURCE_DIR}/intarray)
add_subdirectory(${PROJECT_SOURCE_DIR}/fusion)
add_subdirectory(${PROJECT_SOURCE_DIR}/wavarray)
add_subdirectory(${PROJECT_SOURCE_DIR}/tree)
add_subdirectory(${PROJECT_SOURCE_DIR}/string)
set(CORE_LIBS utils mem codec bitarray intarray wavarray tree string fusionarray)
set (CMAKE_LIBRARY_OUTPUT_DIRECTORY ${PROJECT_BINARY_DIR}/lib
CACHE PATH "Single Directory for all Libraries")
set (CMAKE_ARCHIVE_OUTPUT_DIRECTORY ${PROJECT_BINARY_DIR}/lib
CACHE PATH "Single Directory for all static libraries.")
set(MSCDS_VERSION_MAJOR 0)
set(MSCDS_VERSION_MINOR 1)
set(MSCDS_VERSION_PATCH 0)
set(MSCDS_VERSION_STRING ${MSCDS_VERSION_MAJOR}.${MSCDS_VERSION_MINOR}.${MSCDS_VERSION_PATCH})
MERGE_STATIC_LIBRARIES(extcodeca "extcodec;${SNAPPY_LIBRARY};${ZLIB_LIBRARY}")
MERGE_STATIC_LIBRARIES(mscdsa "${CORE_LIBS}" extcodeca)
#set_target_properties(mscdsa PROPERTIES
# LIBRARY_OUTPUT_DIRECTORY ${PROJECT_BINARY_DIR}/lib)
#set_target_properties(mscdsa PROPERTIES
# ARCHIVE_OUTPUT_DIRECTORY ${PROJECT_BINARY_DIR}/lib)
#get_property(mscdsa_location TARGET mscdsa PROPERTY LOCATION)
#MESSAGE(" Location =" ${mscdsa_location})
#get_property(mscdsa_SRCS GLOBAL PROPERTY mscdsa_SRCS)
#add_library(mscdsa STATIC ${mscdsa_SRCS})
#add_library(mscdsa STATIC common/mscdsa.h common/mscdsa.cpp)
set(MSCDS_VERSION 0.1)
file(GLOB_RECURSE MSCDS_HEADERS
"${PROJECT_SOURCE_DIR}/" "*.h" "*.hpp")
set_target_properties(mscdsa
PROPERTIES VERSION ${MSCDS_VERSION_STRING}
SOVERSION ${MSCDS_VERSION_MAJOR}
PUBLIC_HEADER "${MSCDS_HEADERS}")
add_subdirectory(${PROJECT_SOURCE_DIR}/unittests)
add_subdirectory(${PROJECT_SOURCE_DIR}/remote_file)
MERGE_STATIC_LIBRARIES(remote_access "remote_file;cppnetlib-client-connections;cppnetlib-uri;cppnetlib-server-parsers")
########################################################
include(GNUInstallDirs)
INSTALL(DIRECTORY "${PROJECT_SOURCE_DIR}"
DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}
FILES_MATCHING PATTERN "*.h" PATTERN "*.hpp" PATTERN "*.hxx"
PATTERN "*/ext_libs/*" EXCLUDE
)
#INSTALL(TARGETS mscdsa
# PUBLIC_HEADER DESTINATION ${CMAKE_INSTALL_FULL_INCLUDEDIR}
# RUNTIME DESTINATION ${CMAKE_INSTALL_FULL_BINDIR}
# LIBRARY DESTINATION ${CMAKE_INSTALL_FULL_LIBDIR}
# ARCHIVE DESTINATION ${CMAKE_INSTALL_FULL_LIBDIR})
########################################################
add_subdirectory(${PROJECT_SOURCE_DIR}/export_lib)
add_subdirectory(${PROJECT_SOURCE_DIR}/cwig)
add_subdirectory(${PROJECT_SOURCE_DIR}/cwig2)
add_subdirectory(${PROJECT_SOURCE_DIR}/cbed)
#add_subdirectory(${PROJECT_SOURCE_DIR}/mfm)
#add_subdirectory(${PROJECT_SOURCE_DIR}/gtags)
#add_subdirectory(${PROJECT_SOURCE_DIR}/stdio_stream)
##========================================================
export(TARGETS mscdsa FILE "${PROJECT_BINARY_DIR}/mscdsaTargets.cmake")
export(PACKAGE mscdsa)
# Create the FooBarConfig.cmake and FooBarConfigVersion files
#file(RELATIVE_PATH REL_INCLUDE_DIR "${INSTALL_CMAKE_DIR}" "${INSTALL_INCLUDE_DIR}")