forked from SGL-UT/GPSTk
-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathCMakeLists.txt
More file actions
251 lines (196 loc) · 9.24 KB
/
Copy pathCMakeLists.txt
File metadata and controls
251 lines (196 loc) · 9.24 KB
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
#============================================================
# Name = $GPSTK/CMakeLists.txt
# Purpose = Generator of build framework (e.g. Makefiles) for GPSTk
# Notes = This is the top-level CMake input file
# Depends on $GPSTK/BuildSetup.cmake
# Is dependend on by $GPSTK/build.sh
#============================================================
cmake_minimum_required( VERSION 3.5 )
project( GPSTK )
set( GPSTK_VERSION_MAJOR "2" )
set( GPSTK_VERSION_MINOR "10" )
set( GPSTK_VERSION_PATCH "6" )
set( GPSTK_VERSION "${GPSTK_VERSION_MAJOR}.${GPSTK_VERSION_MINOR}.${GPSTK_VERSION_PATCH}" )
# Test data file source directory
set( GPSTK_TEST_DATA_DIR ${PROJECT_SOURCE_DIR}/data )
# Test output directory
set( GPSTK_TEST_OUTPUT_DIR ${PROJECT_BINARY_DIR}/Testing/Temporary )
# This sets up variables contining GNU standard installation locations.
include( GNUInstallDirs )
# Set a filename for collecting exported targets.
set( EXPORT_TARGETS_FILENAME "GPSTKTargets" )
option( DEBUG_SWITCH "HELP: DEBUG_SWITCH: Default = OFF, print some CMake variable values to stdout." OFF )
option( DEBUG_VERBOSE "HELP: DEBUG_VERBOSE: Default = OFF, print all CMake variable values." OFF )
option( BUILD_EXT "HELP: BUILD_EXT: SWITCH, Default = OFF, Build the ext library, in addition to the core library." OFF )
option( TEST_SWITCH "HELP: TEST_SWITCH: SWITCH, Default = OFF, Turn on test mode." OFF )
option( COVERAGE_SWITCH "HELP: COVERAGE_SWITCH: SWITCH, Default = OFF, Turn on coverage instrumentation." OFF )
option( BUILD_PYTHON "HELP: BUILD_PYTHON: SWITCH, Default = OFF, Turn on processing of python extension package." OFF )
option( USE_RPATH "HELP: USE_RPATH: SWITCH, Default= ON, Set RPATH in libraries and binaries." ON )
#build my project
option( BUILD_MY "HELP: BUILD_MY: SWITCH, Default = OFF, Build the my project, in addition to the core library." OFF )
# set BUILD_MY TRUE by def.
set( BUILD_MY TRUE )
message( WARNING "Setting BUILD_MY = TRUE" )
if( BUILD_PYTHON AND !BUILD_EXT )
message( WARNING "Combination of BUILD_PYTHON=ON and BUILD_EXT=OFF is not allowed. Python swig bindings depend on gpstk/ext." )
message( WARNING "Setting BUILD_EXT = TRUE" )
else()
message( WARNING "Setting BUILD_EXT = FALSE" )
set( BUILD_EXT TRUE )
endif()
include( BuildSetup.cmake )
#============================================================
# Core Library Target Files
#============================================================
#----------------------------------------
# Define $GPSTK/core/ library source files
#----------------------------------------
file( GLOB_RECURSE CORE_SRC_FILES "core/lib/*.cpp" "core/lib/*.c" )
file( GLOB_RECURSE CORE_INC_FILES "core/lib/*.h" "core/lib/*.hpp" )
#----------------------------------------
# Define /core library include directories
#----------------------------------------
# initialize list of include directories
set( CORE_INC_DIRS "" )
foreach( _headerFile ${CORE_INC_FILES} )
get_filename_component( _dir ${_headerFile} PATH )
list( APPEND CORE_INC_DIRS ${_dir} )
endforeach()
list( REMOVE_DUPLICATES CORE_INC_DIRS )
# Add every directory containing a header file
# to the project(gpstk) include_directories
include_directories( ${CORE_INC_DIRS} )
# define src and include files needed to build library target
set( GPSTK_SRC_FILES "" )
set( GPSTK_INC_FILES "" )
list( APPEND GPSTK_SRC_FILES ${CORE_SRC_FILES} )
list( APPEND GPSTK_INC_FILES ${CORE_INC_FILES} )
# Remove getopt.h from non-Windows installs
if( NOT WIN32 )
foreach( _headerFile ${GPSTK_INC_FILES} )
get_filename_component( _name ${_headerFile} NAME )
if( ${_name} MATCHES "getopt.h" )
list( REMOVE_ITEM GPSTK_INC_FILES ${_headerFile} )
endif()
endforeach()
endif()
#============================================================
# Define $GPSTK/ext/ additions to Library Target Files
#============================================================
if( BUILD_EXT )
set( BOOST_ROOT "$ENV{Boost_ROOT}" CACHE PATH "Boost root directory" )
if( EXISTS "${BOOST_ROOT}/boost/version.hpp" )
message( STATUS "Boost found at: ${BOOST_ROOT}" )
include_directories( "${BOOST_ROOT}" )
else()
message( FATAL_ERROR "Boost not found. Set Boost_ROOT environment variable to Boost source directory." )
endif()
file( GLOB_RECURSE EXT_SRC_FILES "ext/lib/*.cpp" "ext/lib/*.c" )
file( GLOB_RECURSE EXT_INC_FILES "ext/lib/*.h" "ext/lib/*.hpp" )
# Define ext library include directories
set( EXT_INC_DIRS "" )
foreach( _headerFile ${EXT_INC_FILES} )
get_filename_component( _dir ${_headerFile} PATH )
get_filename_component( _name ${_headerFile} NAME )
list( APPEND EXT_INC_DIRS ${_dir} )
endforeach()
list( REMOVE_DUPLICATES EXT_INC_DIRS )
# Add every directory containing a header file
# to the project(gpstk) include_directories
include_directories( ${EXT_INC_DIRS} )
# append ext include files needed to build library target
list( APPEND GPSTK_SRC_FILES ${EXT_SRC_FILES} )
list( APPEND GPSTK_INC_FILES ${EXT_INC_FILES} )
# Exclude SolverGeneral from the build
list( FILTER EXT_SRC_FILES EXCLUDE REGEX ".*SolverGeneral\\.cpp$" )
list( FILTER EXT_INC_FILES EXCLUDE REGEX ".*SolverGeneral\\.hpp$" )
list( FILTER GPSTK_SRC_FILES EXCLUDE REGEX ".*SolverGeneral\\.cpp$" )
list( FILTER GPSTK_INC_FILES EXCLUDE REGEX ".*SolverGeneral\\.hpp$" )
list( FILTER GPSTK_SRC_FILES EXCLUDE REGEX ".*GeneralConstraint\\.cpp$" )
list( FILTER GPSTK_INC_FILES EXCLUDE REGEX ".*GeneralConstraint\\.hpp$" )
list( FILTER GPSTK_SRC_FILES EXCLUDE REGEX ".*EquationSystem\\.cpp$" )
list( FILTER GPSTK_INC_FILES EXCLUDE REGEX ".*EquationSystem\\.hpp$" )
list( FILTER GPSTK_SRC_FILES EXCLUDE REGEX ".*NetworkObsStreams\\.cpp$" )
list( FILTER GPSTK_INC_FILES EXCLUDE REGEX ".*NetworkObsStreams\\.hpp$" )
endif()
#============================================================
# GPSTK Library, Build and Install Targets
#============================================================
# GPSTk shared-object library (e.g. libgpstk.so) build target
add_library( gpstk ${STADYN} ${GPSTK_SRC_FILES} ${GPSTK_INC_FILES} )
# GPSTk library install target
install( TARGETS gpstk DESTINATION "${CMAKE_INSTALL_LIBDIR}" EXPORT "${EXPORT_TARGETS_FILENAME}" )
# GPSTk header file install target
install( FILES ${GPSTK_INC_FILES} DESTINATION "${CMAKE_INSTALL_INCLUDEDIR}/gpstk" )
#============================================================
# GPSTK Library parameters
#============================================================
# GPSTk doesn't yet follow semantic versioning. Binary compatibility is only within a specific MAJOR.MINOR version, so
# SOVERSION has both MAJOR and MINOR for now.
set_target_properties(gpstk PROPERTIES VERSION "${GPSTK_VERSION_MAJOR}.${GPSTK_VERSION_MINOR}.${GPSTK_VERSION_PATCH}"
SOVERSION "${GPSTK_VERSION_MAJOR}.${GPSTK_VERSION_MINOR}")
#============================================================
# Testing
#============================================================
if( TEST_SWITCH )
enable_testing()
endif( )
#============================================================
# Coverage
#============================================================
if( COVERAGE_SWITCH )
if (${CMAKE_CXX_COMPILER_ID} MATCHES "Clang"
OR ((${CMAKE_CXX_COMPILER_VERSION} VERSION_GREATER "4.9.0" ) AND CMAKE_COMPILER_IS_GNUCXX))
message(STATUS "Enabling address sanitizer for debug build")
set( CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fprofile-arcs -ftest-coverage" )
endif()
endif( )
#----------------------------------------
# Add sub-directories
#----------------------------------------
add_subdirectory( core )
if( BUILD_EXT )
add_subdirectory( ext )
add_subdirectory( examples )
if( BUILD_PYTHON )
add_subdirectory( swig )
endif()
endif()
if( BUILD_MY )
include_directories(third_party/SOFA)
add_subdirectory(third_party/SOFA )
include_directories(third_party/sqlite)
add_subdirectory(third_party/sqlite)
file( GLOB_RECURSE POD_INC_FILES "POD/src/*.h" "POD/src/*.hpp" )
# initialize list of include directories
set( POD_INC_DIRS "" )
#
# include POD directories
foreach( _headerFile ${POD_INC_FILES} )
get_filename_component( _dir ${_headerFile} PATH )
list( APPEND POD_INC_DIRS ${_dir} )
endforeach()
list( REMOVE_DUPLICATES POD_INC_DIRS )
include_directories(${POD_INC_DIRS})
add_subdirectory( POD )
add_subdirectory( swig_wrapper )
add_subdirectory( test_app )
endif()
#----------------------------------------
# Export the project import cmake files.
#----------------------------------------
include( CMakePackageConfigHelpers )
set( INSTALL_CONFIG_DIR ${CMAKE_INSTALL_DATADIR}/cmake/GPSTK)
configure_package_config_file( ${CMAKE_CURRENT_SOURCE_DIR}/GPSTKConfig.cmake.in
${CMAKE_CURRENT_BINARY_DIR}/GPSTKConfig.cmake
INSTALL_DESTINATION ${INSTALL_CONFIG_DIR}
PATH_VARS CMAKE_INSTALL_LIBDIR CMAKE_INSTALL_INCLUDEDIR CMAKE_INSTALL_BINDIR CMAKE_INSTALL_PREFIX INSTALL_CONFIG_DIR )
write_basic_package_version_file( ${CMAKE_CURRENT_BINARY_DIR}/GPSTKConfigVersion.cmake
VERSION ${GPSTK_VERSION}
COMPATIBILITY ExactVersion )
install( FILES
${CMAKE_CURRENT_BINARY_DIR}/GPSTKConfig.cmake
${CMAKE_CURRENT_BINARY_DIR}/GPSTKConfigVersion.cmake
DESTINATION
${INSTALL_CONFIG_DIR} )
install( EXPORT ${EXPORT_TARGETS_FILENAME} DESTINATION ${INSTALL_CONFIG_DIR} )