-
Notifications
You must be signed in to change notification settings - Fork 0
/
CMakeLists.txt
282 lines (236 loc) · 11.4 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
272
273
274
275
276
277
278
279
280
281
282
# Copyright (c) 2010-2013, Delft University of Technology
# All rights reserved.
#
# Redistribution and use in source and binary forms, with or without modification, are
# permitted provided that the following conditions are met:
# - Redistributions of source code must retain the above copyright notice, this list of
# conditions and the following disclaimer.
# - Redistributions in binary form must reproduce the above copyright notice, this list of
# conditions and the following disclaimer in the documentation and/or other materials
# provided with the distribution.
# - Neither the name of the Delft University of Technology nor the names of its contributors
# may be used to endorse or promote products derived from this software without specific
# prior written permission.
#
# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS
# OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
# MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
# COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
# EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE
# GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
# AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
# NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED
# OF THE POSSIBILITY OF SUCH DAMAGE.
#
# Changelog
# YYMMDD Author Comment
# 110820 S.M. Persson File created.
# 120202 K. Kumar Adapted to work with Earth orbiting satellite example.
# 120427 A. Ronse Added option for using UserSettings.txt.
# 120522 A. Ronse Adapted for automatically finding TudatCoreEnvironment.cmake
# at standard location relative to project source.
# 130222 K. Kumar Updated directory definitions.
# 130225 K. Kumar Updated set-function calls to check if variables have been set
# already.
# 130326 K. Kumar Added BUILD_DOCUMENTATION option for Doxygen html output
# generation; removed -O3 flag since it is set by "Release"
# build type if selected; updated install steps; re-organized
# file to isolate user-specified section.
#
# References
#
# Notes
#
# Specify minimum CMake version required.
cmake_minimum_required(VERSION 2.6)
# Specify project name.
project(Thesis_tudatversion)
# Load UserSettings.txt
if(${CMAKE_SOURCE_DIR} STREQUAL ${CMAKE_CURRENT_SOURCE_DIR})
message(STATUS "Building ${PROJECT_NAME} standalone.")
include("${CMAKE_CURRENT_SOURCE_DIR}/UserSettings.txt" OPTIONAL)
else()
message(STATUS "Building ${PROJECT_NAME} from within ${CMAKE_PROJECT_NAME}.")
include("${CMAKE_CURRENT_SOURCE_DIR}/UserSettings.txt" OPTIONAL)
include("${CMAKE_SOURCE_DIR}/UserSettings.txt" OPTIONAL)
STRING(REGEX REPLACE ${CMAKE_SOURCE_DIR} "" RELATIVE_PROJECT_PATH ${CMAKE_CURRENT_SOURCE_DIR})
set(RELATIVE_PROJECT_PATH "${RELATIVE_PROJECT_PATH}" CACHE STRING "Relative path wrt to project for function")
message(STATUS "Relative path (wrt to project): ${RELATIVE_PROJECT_PATH}")
endif()
# Set CMake build-type. If it not supplied by the user (either directly as an argument of through
# the "UserSettings.txt" file, the default built type is "Release".
if((NOT CMAKE_BUILD_TYPE) OR (CMAKE_BUILD_TYPE STREQUAL "Release"))
message(STATUS "WARNING: building release version!")
set(CMAKE_BUILD_TYPE Release)
elseif(CMAKE_BUILD_TYPE STREQUAL "Debug")
message(STATUS "WARNING: building debug version!")
set(CMAKE_BUILD_TYPE Debug)
endif()
# Set module path to local CMake scripts.
set(CMAKE_MODULE_PATH ${PROJECT_SOURCE_DIR}/CMakeModules)
# Set compiler based on preferences (e.g. USE_CLANG) and system.
include(${CMAKE_MODULE_PATH}/compiler.cmake)
# Define the directory with the source code.
set(SRCROOT "${CMAKE_CURRENT_SOURCE_DIR}")
# Define the code root directory.
set(CODEROOT "${CMAKE_CURRENT_SOURCE_DIR}/..")
# Set testing options based on platform.
enable_testing()
# Set lib and bin directories where static libraries and unit tests are built.
if(NOT LIB_ROOT)
set(LIB_ROOT "${CODEROOT}/lib")
endif()
if(NOT BIN_ROOT)
set(BIN_ROOT "${CODEROOT}/bin")
endif()
# Set the global macros for setting up targets.
macro(setup_executable_target target_name CUSTOM_OUTPUT_PATH)
set_property(TARGET ${target_name} PROPERTY RUNTIME_OUTPUT_DIRECTORY "${BIN_ROOT}/applications")
install(TARGETS ${target_name} RUNTIME DESTINATION "${BIN_ROOT}/applications")
endmacro(setup_executable_target)
macro(setup_library_target target_name CUSTOM_OUTPUT_PATH)
set_property(TARGET ${target_name} PROPERTY LIBRARY_OUTPUT_DIRECTORY "${LIB_ROOT}")
set_property(TARGET ${target_name} PROPERTY ARCHIVE_OUTPUT_DIRECTORY "${LIB_ROOT}")
endmacro(setup_library_target)
macro(setup_unit_test_target target_name CUSTOM_OUTPUT_PATH)
set_property(TARGET ${target_name} PROPERTY RUNTIME_OUTPUT_DIRECTORY "${BIN_ROOT}/unit_tests")
get_property(CUSTOM_TEST_PROGRAM_NAME TARGET ${target_name} PROPERTY OUTPUT_NAME)
add_test("${target_name}" "${BIN_ROOT}/unit_tests/${target_name}")
endmacro(setup_unit_test_target)
# Define the install targets to create a distribution.
if(NOT TUDAT_BUNDLE_DISTRIBUTION_PATH)
set(TUDAT_BUNDLE_DISTRIBUTION_PATH "${CODEROOT}")
endif(NOT TUDAT_BUNDLE_DISTRIBUTION_PATH)
#if(NOT TEMPLATE_APPLICATION_DISTRIBUTION_PATH)
# set(TEMPLATE_APPLICATION_DISTRIBUTION_PATH
# "${TUDAT_BUNDLE_DISTRIBUTION_PATH}/Thesis_tudatversion/Thesis_tudatversion")
#endif(NOT TEMPLATE_APPLICATION_DISTRIBUTION_PATH)
# Install Template Application files.
install(DIRECTORY "${SRCROOT}/"
DESTINATION "${TEMPLATE_APPLICATION_DISTRIBUTION_PATH}/Thesis_tudatversion"
PATTERN ".DS_STORE" EXCLUDE
PATTERN "CMakeLists.txt.user" EXCLUDE
PATTERN ".svn" EXCLUDE
PATTERN ".git" EXCLUDE
PATTERN ".bzr" EXCLUDE
)
#message(STATUS "path test: " ${SRCROOT} )
# Include the top-level directories.
include_directories(AFTER
"${CODEROOT}"
)
# Find Eigen3 library on local system.
find_package(Eigen3 REQUIRED)
# Include Eigen3 directories.
# Set CMake flag to suppress Eigen warnings (platform-dependent solution).
if(NOT APPLE)
include_directories(SYSTEM AFTER "${EIGEN3_INCLUDE_DIR}")
else()
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -isystem \"${EIGEN3_INCLUDE_DIR}\"")
endif()
# Configure Boost libraries.
if(NOT Boost_USE_STATIC_LIBS)
set(Boost_USE_STATIC_LIBS ON)
endif()
if(NOT Boost_USE_MULTITHREADED)
set(Boost_USE_MULTITHREADED ON)
endif()
if(NOT Boost_USE_STATIC_RUNTIME)
set(Boost_USE_STATIC_RUNTIME ON)
endif()
# Find Boost libraries on local system.
find_package(Boost 1.45.0
COMPONENTS thread date_time system unit_test_framework filesystem regex serialization chrono atomic REQUIRED)
# Include Boost directories.
# Set CMake flag to suppress Boost warnings (platform-dependent solution).
if(NOT APPLE)
include_directories(SYSTEM AFTER "${Boost_INCLUDE_DIRS}")
else()
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -isystem \"${Boost_INCLUDE_DIRS}\"")
endif()
# Find Tudat library on local system.
find_package(Tudat 2.0 REQUIRED)
# Include Tudat directories.
# Set CMake flag to suppress Tudat warnings (platform-dependent solution).
if(NOT APPLE)
include_directories(SYSTEM AFTER "${TUDAT_INCLUDE_DIR}")
else()
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -isystem \"${TUDAT_INCLUDE_DIR}\"")
endif()
# Find CSPICE library on local system.
find_package(Spice)
# Include CSpice directories.
if(NOT APPLE)
include_directories(SYSTEM AFTER "${SPICE_INCLUDE_DIR}")
else( )
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -isystem \"${SPICE_INCLUDE_DIR}\"")
endif( )
if(USE_CSPICE)
list(APPEND TUDAT_APPLICATION_EXTERNAL_LIBRARIES tudat_spice_interface cspice)
endif()
find_package(JSONCPP)
if(USE_JSONCPP)
list(APPEND TUDAT_APPLICATION_EXTERNAL_LIBRARIES jsoncpp)
endif()
if(USE_NRLMSISE00)
list(APPEND TUDAT_APPLICATION_EXTERNAL_LIBRARIES nrlmsise00)
endif()
list(APPEND TUDAT_APPLICATION_PROPAGATION_LIBRARIES tudat_simulation_setup tudat_propagators
tudat_aerodynamics tudat_geometric_shapes tudat_relativity tudat_gravitation tudat_mission_segments
tudat_electro_magnetism tudat_propulsion tudat_ephemerides tudat_numerical_integrators tudat_reference_frames
tudat_basic_astrodynamics tudat_input_output tudat_basic_mathematics tudat_propagators ${TUDAT_APPLICATION_EXTERNAL_LIBRARIES})
# Find PaGMO library on local system.
#find_package(PaGMO)
# Include PaGMO directories.
#if(NOT APPLE)
# include_directories(SYSTEM AFTER "${PAGMO_INCLUDE_DIR}")
#else( )
# set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -isystem \"${PAGMO_INCLUDE_DIR}\"")
#endif( )
# If documentation should be built, find Doxygen package and setup config file.
if(BUILD_DOCUMENTATION)
find_package(Doxygen)
if(NOT DOXYGEN_FOUND)
message(FATAL_ERROR
"Doxygen is needed to build the documentation. Please install it correctly.")
endif()
# Configure the Template Doxyfile for our specific project.
configure_file(${CODEROOT}/Doxyfile.in ${PROJECT_BINARY_DIR}/Doxyfile @ONLY IMMEDIATE)
# Add a custom target to run Doxygen when ever the project is built.
# IF you do NOT want the documentation to be generated EVERY time you build the project
# then leave out the 'ALL' keyword from the above command.
add_custom_target (docs ALL COMMAND ${DOXYGEN_EXECUTABLE}
${PROJECT_BINARY_DIR}/Doxyfile
SOURCES ${PROJECT_BINARY_DIR}/Doxyfile)
# Install documentation.
install(DIRECTORY "${CODEROOT}/Documentation"
DESTINATION "${TEMPLATE_APPLICATION_DISTRIBUTION_PATH}")
endif()
# Add library.
add_library(thesis_tudatversion STATIC
body.h
spacecraft.h spacecraft.cpp
constants.h
integrationSettings.h integrationSettings.cpp
recurrenceRelations.h recurrenceRelations.cpp
frameTransformation.h frameTransformation.cpp
taylorSeriesIntegratorGenMap.h taylorSeriesIntegratorGenMap.cpp
problemRecurrenceRelationsGen.h problemRecurrenceRelationsGen.cpp
stepSizeControlTSI.h stepSizeControlTSI.cpp
lagrangeInterpolator.h lagrangeInterpolator.cpp
discreteForceModelGen.h discreteForceModelGen.cpp
USMstateDerivativeModel.h USMstateDerivativeModel.cpp
spacecraftGen.h spacecraftGen.cpp
)
setup_library_target(thesis_tudatversion "${SRCROOT}")
add_subdirectory( "${SRCROOT}/unitTests/" )
# Add mainTSI_tudatversion application.
add_executable(application_mainTSI_tudatversion "${SRCROOT}/mainTSI_tudatversion.cpp")
setup_executable_target(application_mainTSI_tudatversion "${SRCROOT}")
target_link_libraries(application_mainTSI_tudatversion thesis_application ${TUDAT_APPLICATION_PROPAGATION_LIBRARIES}
${TUDAT_APPLICATION_EXTERNAL_LIBRARIES} ${Boost_LIBRARIES} )
# Add mainRKusm_tudatversion application.
add_executable(application_mainRKusm_tudatversion "${SRCROOT}/mainRKusm_tudatversion.cpp")
setup_executable_target(application_mainRKusm_tudatversion "${SRCROOT}")
target_link_libraries(application_mainRKusm_tudatversion thesis_application ${TUDAT_APPLICATION_PROPAGATION_LIBRARIES}
${TUDAT_APPLICATION_EXTERNAL_LIBRARIES} ${Boost_LIBRARIES} )