This repository has been archived by the owner on May 29, 2022. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 185
/
CMakeLists.txt
233 lines (181 loc) · 9.2 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
#============================================================
# 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 2.8.5 )
project( GPSTK )
set( GPSTK_VERSION_MAJOR "8" )
set( GPSTK_VERSION_MINOR "0" )
set( GPSTK_VERSION_PATCH "0" )
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 )
option( PIP_WHEEL_SWITCH "HELP: PIP_WHEEL_SWITCH: SWITCH, Default= OFF, Build a PIP installable wheel." OFF )
option( BUILD_FOR_PACKAGE_SWITCH "HELP: BUILD_FOR_PACKAGE_SWITCH: SWITCH, Default= OFF, Modify python install paths assuming creation of deb/rpm." OFF )
option( PYTHON_USER_INSTALL "HELP: PYTHON_USER_INSTALL: SWITCH, Default= OFF, Install python in user mode." OFF )
option( VERSIONED_HEADER_INSTALL "HELP: VERSIONED_HEADER_INSTALL: SWITCH, Default= OFF, Install header files into maj/min versioned directory." OFF )
if( PYTHON_USER_INSTALL AND !BUILD_PYTHON )
message( WARNING "Combination of PYTHON_USER_INSTALL=ON and BUILD_PYTHON=OFF is not allowed. " )
message( WARNING "Setting BUILD_PYTHON = TRUE" )
set( BUILD_PYTHON TRUE )
endif()
if( PIP_WHEEL_SWITCH AND !BUILD_PYTHON )
message( WARNING "Combination of PIP_WHEEL_SWITCH=ON and BUILD_PYTHON=OFF is not allowed. Wheels depend on python module." )
message( WARNING "Setting BUILD_PYTHON = TRUE" )
set( BUILD_PYTHON TRUE )
endif()
if( BUILD_FOR_PACKAGE_SWITCH AND !BUILD_PYTHON )
message( WARNING "Combination of BUILD_FOR_PACKAGE_SWITCH=ON and BUILD_PYTHON=OFF is not allowed. Packages depend on python module." )
message( WARNING "Setting BUILD_PYTHON = TRUE" )
set( BUILD_PYTHON TRUE )
endif()
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" )
set( BUILD_EXT TRUE )
endif()
# GPSTk header file install target (whether it is version dependent changes based on user flag)
if( VERSIONED_HEADER_INSTALL )
set( GPSTK_INCLUDE_WRAPPER_DIR "gpstk_${GPSTK_VERSION_MAJOR}_${GPSTK_VERSION_MINOR}" )
set( GPSTK_INCLUDE_TGT "${GPSTK_INCLUDE_WRAPPER_DIR}/gpstk" )
set( GPSTK_INCLUDE_PARENT "${CMAKE_INSTALL_INCLUDEDIR}/${GPSTK_INCLUDE_WRAPPER_DIR}" )
set( CMAKE_INSTALL_INCLUDEDIR "${CMAKE_INSTALL_INCLUDEDIR}/${GPSTK_INCLUDE_TGT}" )
message( WARNING "Setting GPSTK_INCLUDE_TGT_DIR = ${CMAKE_INSTALL_INCLUDEDIR}" )
else()
set( GPSTK_INCLUDE_PARENT "${CMAKE_INSTALL_INCLUDEDIR}" )
set( CMAKE_INSTALL_INCLUDEDIR "${CMAKE_INSTALL_INCLUDEDIR}/gpstk" )
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 )
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} )
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 (whether it is version dependent changes based on user flag)
install( FILES ${GPSTK_INC_FILES} DESTINATION ${CMAKE_INSTALL_INCLUDEDIR} )
#============================================================
# 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()
#----------------------------------------
# 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} )