-
Notifications
You must be signed in to change notification settings - Fork 3
/
CMakeLists.txt
239 lines (201 loc) · 9.02 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
# Copyright (c) 2010-2017, Delft University of Technology
# All rigths reserved
#
# This file is part of the Tudat. Redistribution and use in source and
# binary forms, with or without modification, are permitted exclusively
# under the terms of the Modified BSD license. You should have received
# a copy of the license with this file. If not, please or visit:
# http://tudat.tudelft.nl/LICENSE.
#
# Specify minimum CMake version required.
cmake_minimum_required(VERSION 2.6)
# Specify project name.
project(thesisProject)
# 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}/cmake)
# 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}/thesisProject/lib")
endif()
if(NOT BIN_ROOT)
set(BIN_ROOT "${CODEROOT}/thesisProject/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}")
install(TARGETS ${target_name} RUNTIME DESTINATION "${BIN_ROOT}")
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}/tudatApplications/templateApplication")
endif(NOT TEMPLATE_APPLICATION_DISTRIBUTION_PATH)
# Install Template Application files.
install(DIRECTORY "${SRCROOT}/"
DESTINATION "${TEMPLATE_APPLICATION_DISTRIBUTION_PATH}/TemplateApplication"
PATTERN ".DS_STORE" EXCLUDE
PATTERN "CMakeLists.txt.user" EXCLUDE
PATTERN ".svn" EXCLUDE
PATTERN ".git" EXCLUDE
PATTERN ".bzr" EXCLUDE
)
# 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 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( )
option(USE_NRLMSISE00 "build Tudat with NRLMSISE-00 enabled" ON)
if(NOT USE_NRLMSISE00)
message(STATUS "NRLMSISE-00 disabled!")
add_definitions(-DUSE_NRLMSISE00=0)
else()
message(STATUS "NRLMSISE-00 enabled!")
add_definitions(-DUSE_NRLMSISE00=1)
# Find USE_NRLMSISE00 library on local system.
find_package(NRLMSISE00)
# Include NRLMSISE00 directories.
if(NOT APPLE)
include_directories(SYSTEM AFTER "${NRLMSISE00_INCLUDE_DIR}")
else( )
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -isystem \"${NRLMSISE00_INCLUDE_DIR}\"")
endif( )
endif( )
if(USE_CSPICE)
list(APPEND TUDAT_APPLICATION_EXTERNAL_LIBRARIES tudat_spice_interface cspice)
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_basics ${TUDAT_APPLICATION_EXTERNAL_LIBRARIES})
find_package(OpenMP)
if (OPENMP_FOUND)
set (CMAKE_C_FLAGS "${CMAKE_C_FLAGS} ${OpenMP_C_FLAGS}")
set (CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${OpenMP_CXX_FLAGS}")
endif()
set(CR3BP_SOURCES
"${SRCROOT}/src/applyDifferentialCorrection.cpp"
"${SRCROOT}/src/checkEigenvalues.cpp"
"${SRCROOT}/src/completeInitialConditionsHaloFamily.cpp"
"${SRCROOT}/src/computeDifferentialCorrection.cpp"
"${SRCROOT}/src/computeManifolds.cpp"
"${SRCROOT}/src/connectManifoldsAtTheta.cpp"
"${SRCROOT}/src/createInitialConditions.cpp"
"${SRCROOT}/src/createInitialConditionsAxialFamily.cpp"
"${SRCROOT}/src/propagateOrbit.cpp"
"${SRCROOT}/src/richardsonThirdOrderApproximation.cpp"
"${SRCROOT}/src/stateDerivativeModel.cpp"
"${SRCROOT}/src/writePeriodicOrbitToFile.cpp"
)
# Set the header files.
set(CR3BP_HEADERS
"${SRCROOT}/src/applyDifferentialCorrection.h"
"${SRCROOT}/src/checkEigenvalues.h"
"${SRCROOT}/src/completeInitialConditionsHaloFamily.h"
"${SRCROOT}/src/computeDifferentialCorrection.h"
"${SRCROOT}/src/computeManifolds.h"
"${SRCROOT}/src/connectManifoldsAtTheta.h"
"${SRCROOT}/src/createInitialConditions.h"
"${SRCROOT}/src/createInitialConditionsAxialFamily.h"
"${SRCROOT}/src/propagateOrbit.h"
"${SRCROOT}/src/richardsonThirdOrderApproximation.h"
"${SRCROOT}/src/stateDerivativeModel.h"
"${SRCROOT}/src/writePeriodicOrbitToFile.h"
)
# Add static libraries.
add_library(tudat_cr3bp STATIC ${CR3BP_SOURCES} ${CR3BP_HEADERS})
setup_library_target(tudat_cr3bp "${SRCROOT}/src/")
add_executable(main "${SRCROOT}/src/main.cpp")
setup_executable_target(main "${SRCROOT}")
target_link_libraries(main tudat_cr3bp tudat_gravitation tudat_basic_astrodynamics tudat_numerical_integrators ${TUDAT_CORE_LIBRARIES} ${Eigen_LIBRARIES} ${Boost_LIBRARIES})
#add_executable(main "${SRCROOT}/src/main.cpp")
#setup_executable_target(main "${SRCROOT}")
#target_link_libraries(main tudat_gravitation tudat_basic_astrodynamics tudat_numerical_integrators ${TUDAT_CORE_LIBRARIES} ${Eigen_LIBRARIES} ${Boost_LIBRARIES})