forked from F2I-Consulting/fesapi
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathCMakeLists.txt
192 lines (159 loc) · 7.41 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
cmake_minimum_required (VERSION 3.12)
project (Fesapi)
set(CMAKE_DEBUG_POSTFIX "d" CACHE STRING "DEBUG_POSTFIX property is initialized when the target is created to the value of this variable except for executable targets")
set (FESAPI_ROOT_DIR ${CMAKE_SOURCE_DIR})
# Allow to have all executables generated in the same binary directory. Otherwise there would be in a directory different for each add_subdirectory cmake commande.
set (FESAPI_BINARY_DIR ${CMAKE_CURRENT_BINARY_DIR})
# version mechanism
set (Fesapi_VERSION_MAJOR 2)
set (Fesapi_VERSION_MINOR 8)
set (Fesapi_VERSION_PATCH 0)
set (Fesapi_VERSION_TWEAK 0)
set (Fesapi_VERSION ${Fesapi_VERSION_MAJOR}.${Fesapi_VERSION_MINOR}.${Fesapi_VERSION_PATCH}.${Fesapi_VERSION_TWEAK})
set (CPP_LIBRARY_NAME FesapiCpp)
if(NOT CMAKE_BUILD_TYPE)
set(CMAKE_BUILD_TYPE "Release")
endif()
set (BUILD_SHARED_LIBS ON CACHE BOOL "Build shared lib")
IF (CMAKE_INSTALL_PREFIX_INITIALIZED_TO_DEFAULT)
set (CMAKE_INSTALL_PREFIX ${FESAPI_BINARY_DIR}/install CACHE PATH "FesapiCpp install prefix" FORCE)
ENDIF (CMAKE_INSTALL_PREFIX_INITIALIZED_TO_DEFAULT)
set(CMAKE_CXX_STANDARD 11)
set(CMAKE_CXX_STANDARD_REQUIRED ON)
set(CMAKE_CXX_EXTENSIONS OFF)
set(CMAKE_POSITION_INDEPENDENT_CODE TRUE)
# ============================================================================
# checking for required dependencies
# ============================================================================
# path to custom find_package modules
list(APPEND CMAKE_MODULE_PATH "${CMAKE_SOURCE_DIR}/cmake/modules/")
# hdf5
set (WITH_LOCAL_HDF5 OFF CACHE BOOL "Also builds and installs an example executable which allows to serialize and deserialize a basic EPC document.")
IF(WITH_LOCAL_HDF5)
set (HDF5_INCLUDE_DIRS HDF5_INCLUDE_DIRS-NOTFOUND CACHE PATH "Path to the directory which contains the hdf5 header files")
IF (NOT IS_DIRECTORY ${HDF5_INCLUDE_DIRS})
MESSAGE(WARNING "The HDF5 include dir (HDF5_INCLUDE_DIRS variable) does not look to be a valid directory. Please modify it.")
ENDIF ()
set (HDF5_LIBRARIES HDF5_LIBRARIES-NOTFOUND CACHE FILEPATH "Path to the file which contains the hdf5 library")
IF (NOT EXISTS ${HDF5_LIBRARIES})
MESSAGE(WARNING "The HDF5 library (HDF5_LIBRARIES variable) does not look to be a valid file. Please modify it.")
ENDIF ()
set(HDF5_VERSION "99.99")
ELSE()
find_package(HDF5 1.8.18 REQUIRED COMPONENTS C)
IF(HDF5_PREFER_PARALLEL)
if(NOT HDF5_IS_PARALLEL)
message(FATAL_ERROR
"Parallel HDF5 required but only serial version found!"
)
ENDIF()
ELSE()
IF(HDF5_IS_PARALLEL)
message(FATAL_ERROR
"Serial HDF5 required but only parallel version found!"
)
ENDIF()
ENDIF()
ENDIF()
# Zlib
FIND_PACKAGE (ZLIB)
MARK_AS_ADVANCED(CLEAR ZLIB_INCLUDE_DIR)
IF (NOT EXISTS ${ZLIB_INCLUDE_DIR})
MESSAGE(WARNING "The zlib include dir (ZLIB_INCLUDE_DIR variable) does not look to be a valid directory. Please modify it.")
ENDIF ()
MARK_AS_ADVANCED(CLEAR ZLIB_LIBRARY_RELEASE)
IF (NOT EXISTS ${ZLIB_LIBRARY_RELEASE})
MESSAGE(WARNING "The zlib library (ZLIB_LIBRARY_RELEASE variable) does not look to be a valid file. Please modify it.")
ENDIF ()
MARK_AS_ADVANCED(CLEAR ZLIB_LIBRARY_DEBUG)
IF (NOT EXISTS ${ZLIB_LIBRARY_DEBUG})
MESSAGE(WARNING "The zlib library (ZLIB_LIBRARY_DEBUG variable) does not look to be a valid file. Please modify it.")
ENDIF ()
# Minizip
set (MINIZIP_INCLUDE_DIR MINIZIP_INCLUDE_DIR-NOTFOUND CACHE PATH "Path to the directory which contains the minizip header files")
IF (NOT IS_DIRECTORY ${MINIZIP_INCLUDE_DIR})
MESSAGE(WARNING "The Minizip include dir (MINIZIP_INCLUDE_DIR variable) does not look to be a valid directory. Please modify it.")
ENDIF ()
set (MINIZIP_LIBRARY_RELEASE MINIZIP_LIBRARY_RELEASE-NOTFOUND CACHE FILEPATH "Path to the file which contains the minizip library release")
IF (NOT EXISTS ${MINIZIP_LIBRARY_RELEASE})
MESSAGE(WARNING "The Minizip library (MINIZIP_LIBRARY_RELEASE variable) does not look to be a valid file. Please modify it.")
ENDIF ()
set (MINIZIP_LIBRARY_DEBUG MINIZIP_LIBRARY_DEBUG-NOTFOUND CACHE FILEPATH "Path to the file which contains the minizip library DEBUG")
IF (NOT EXISTS ${MINIZIP_LIBRARY_DEBUG})
MESSAGE(WARNING "The Minizip library (MINIZIP_LIBRARY_DEBUG variable) does not look to be a valid file. Please modify it.")
ENDIF ()
# Szip (only useful when using static linking to HDF5)
set (SZIP_LIBRARY_RELEASE SZIP_LIBRARY_RELEASE-NOTFOUND CACHE FILEPATH "Path to the file which contains the szip library release")
IF (NOT EXISTS ${SZIP_LIBRARY_RELEASE} AND WIN32 AND NOT ${HDF5_BUILT_AS_DYNAMIC_LIB})
MESSAGE(WARNING "The Szip library (SZIP_LIBRARY_RELEASE variable) does not look to be a valid file. Please modify it.")
ENDIF ()
set (SZIP_LIBRARY_DEBUG SZIP_LIBRARY_DEBUG-NOTFOUND CACHE FILEPATH "Path to the file which contains the szip library DEBUG")
IF (NOT EXISTS ${SZIP_LIBRARY_DEBUG} AND WIN32 AND NOT ${HDF5_BUILT_AS_DYNAMIC_LIB})
MESSAGE(WARNING "The Szip library (SZIP_LIBRARY_DEBUG variable) does not look to be a valid file. Please modify it.")
ENDIF ()
# Boost DEPENDENCY : Uuid (and potentially regex)
unset(CAN_USE_STD_REGEX CACHE)
include(CheckCXXSourceCompiles)
check_cxx_source_compiles(
"#include <iostream>
//https://gcc.gnu.org/develop.html#timeline
int a =
#if !defined(__GLIBCXX__) || __GLIBCXX__ > 20150623 || __GLIBCXX__ == 20140422 || __GLIBCXX__ == 20140716 || __GLIBCXX__ == 20141030
1;
#else
fgsfds;
#endif
int main ()
{
return 0;
}"
CAN_USE_STD_REGEX
)
if (NOT CAN_USE_STD_REGEX)
find_package(Boost 1.44.0 REQUIRED regex) # 1.44 because we want boost::uuids::to_string method
else ()
find_package(Boost 1.44.0 REQUIRED) # 1.44 because we want boost::uuids::to_string method
endif()
# ============================================================================
# some useful variables
# ============================================================================
if (BUILD_SHARED_LIBS)
set (LIB_TYPE SHARED)
else (BUILD_SHARED_LIBS)
set (LIB_TYPE STATIC)
endif (BUILD_SHARED_LIBS)
set (WITH_RESQML2_2 OFF CACHE BOOL "Compile RESQML2.2 experimental support. Don't use it in production.")
# ============================================================================
# Gsoap proxies source
# ============================================================================
list(APPEND FESAPI_PROXIES_SOURCES
${FESAPI_ROOT_DIR}/src/proxies/envC.cpp
${FESAPI_ROOT_DIR}/src/proxies/gsoap_resqml2_0_1C.cpp
${FESAPI_ROOT_DIR}/src/proxies/gsoap_eml2_3C.cpp
${FESAPI_ROOT_DIR}/src/proxies/namespace.cpp
${FESAPI_ROOT_DIR}/src/proxies/stdsoap2.cpp
${FESAPI_ROOT_DIR}/src/proxies/struct_tm.cpp
)
list(APPEND FESAPI_PROXIES_HEADERS
${FESAPI_ROOT_DIR}/src/proxies/envH.h
${FESAPI_ROOT_DIR}/src/proxies/envStub.h
${FESAPI_ROOT_DIR}/src/proxies/gsoap_resqml2_0_1H.h
${FESAPI_ROOT_DIR}/src/proxies/gsoap_resqml2_0_1Stub.h
${FESAPI_ROOT_DIR}/src/proxies/gsoap_eml2_3H.h
${FESAPI_ROOT_DIR}/src/proxies/gsoap_eml2_3Stub.h
${FESAPI_ROOT_DIR}/src/proxies/stdsoap2.h
)
# ============================================================================
# including subdirectories
# ============================================================================
add_subdirectory(src)
add_subdirectory(doc)
set (WITH_EXAMPLE OFF CACHE BOOL "Also builds and installs an example executable which allows to serialize and deserialize a basic EPC document.")
if (WITH_EXAMPLE)
add_subdirectory(example)
endif (WITH_EXAMPLE)
set (WITH_TEST OFF CACHE BOOL "Also build the unit tests.")
if (WITH_TEST)
enable_testing()
add_subdirectory(test)
endif (WITH_TEST)