-
Notifications
You must be signed in to change notification settings - Fork 1
/
CMakeLists.txt
195 lines (162 loc) · 6.84 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
cmake_minimum_required(VERSION 2.8.3)
project(TudatPy)
# Load UserSettings.txt
if(${CMAKE_SOURCE_DIR} STREQUAL ${CMAKE_CURRENT_SOURCE_DIR})
set(BUILD_STYLE "standalone")
include("${CMAKE_CURRENT_SOURCE_DIR}/UserSettings.txt" OPTIONAL)
else()
set(BUILD_STYLE "part of ${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"))
set(CMAKE_BUILD_TYPE Release)
elseif(CMAKE_BUILD_TYPE STREQUAL "Debug")
set(CMAKE_BUILD_TYPE Debug)
endif()
message(STATUS "<< ${PROJECT_NAME} (${CMAKE_BUILD_TYPE} - ${BUILD_STYLE}) >>")
# Add local module path
list(APPEND CMAKE_MODULE_PATH "${PROJECT_SOURCE_DIR}/CMakeModules")
message(STATUS "CMake Module path(s): ${CMAKE_MODULE_PATH}")
# Set compiler based on preferences (e.g. USE_CLANG) and system.
include(compiler)
# 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 LIBROOT)
set(LIBROOT "${CODEROOT}/lib")
endif()
if(NOT BINROOT)
set(BINROOT "${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 "${BINROOT}/applications")
install(TARGETS ${target_name} RUNTIME DESTINATION "${BINROOT}/applications")
endmacro(setup_executable_target)
macro(setup_library_target target_name CUSTOM_OUTPUT_PATH)
set_property(TARGET ${target_name} PROPERTY LIBRARY_OUTPUT_DIRECTORY "${LIBROOT}")
set_property(TARGET ${target_name} PROPERTY ARCHIVE_OUTPUT_DIRECTORY "${LIBROOT}")
endmacro(setup_library_target)
macro(setup_unit_test_target target_name CUSTOM_OUTPUT_PATH)
set_property(TARGET ${target_name} PROPERTY RUNTIME_OUTPUT_DIRECTORY "${BINROOT}/unit_tests")
get_property(CUSTOM_TEST_PROGRAM_NAME TARGET ${target_name} PROPERTY OUTPUT_NAME)
add_test("${target_name}" "${BINROOT}/unit_tests/${target_name}")
endmacro(setup_unit_test_target)
# 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 OR APPLE_INCLUDE_FORCE)
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.55.0
COMPONENTS thread date_time system unit_test_framework filesystem regex python3 REQUIRED)
# Include Boost directories.
# Set CMake flag to suppress Boost warnings (platform-dependent solution).
if(NOT APPLE OR APPLE_INCLUDE_FORCE)
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 OR APPLE_INCLUDE_FORCE)
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 OR APPLE_INCLUDE_FORCE)
include_directories(SYSTEM AFTER "${SPICE_INCLUDE_DIR}")
else( )
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -isystem \"${SPICE_INCLUDE_DIR}\"")
endif( )
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 OR APPLE_INCLUDE_FORCE)
include_directories(SYSTEM AFTER "${NRLMSISE00_INCLUDE_DIR}")
else( )
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -isystem \"${NRLMSISE00_INCLUDE_DIR}\"")
endif( )
endif( )
# Set compiler based on preferences (e.g. USE_CLANG) and system.
include(tudatLinkLibraries)
## TODO: Allow for choice between python 3.6 and python 2.7 for compilation.
FIND_PACKAGE(PythonInterp 3.5 REQUIRED)
# TODO: Boost component for python must only contain major. Modify and push
# suggestion on github.
if (PYTHONINTERP_FOUND)
if (UNIX AND NOT APPLE)
if (PYTHON_VERSION_MAJOR EQUAL 3)
# NOTE: As far as is known, building boost.python3 provides the lib files
# in the form of python3 and not python3.6 as is suggested by original
# code.
# FIND_PACKAGE(Boost COMPONENTS python${PYTHON_VERSION_MAJOR})
FIND_PACKAGE(PythonInterp 3)
FIND_PACKAGE(PythonLibs 3 REQUIRED)
else()
# FIND_PACKAGE(Boost COMPONENTS python)
FIND_PACKAGE(PythonInterp)
FIND_PACKAGE(PythonLibs REQUIRED)
endif()
else()
if (PYTHON_VERSION_MAJOR EQUAL 3)
#FIND_PACKAGE(Boost COMPONENTS python${PYTHON_VERSION_MAJOR}${PYTHON_VERSION_MINOR})
FIND_PACKAGE(PythonInterp 3)
FIND_PACKAGE(PythonLibs 3 REQUIRED)
else()
#FIND_PACKAGE(Boost COMPONENTS python${PYTHON_VERSION_MAJOR}${PYTHON_VERSION_MINOR})
FIND_PACKAGE(PythonInterp)
FIND_PACKAGE(PythonLibs REQUIRED)
endif()
endif()
else()
message("Python not found")
endif()
message(STATUS "PYTHON_LIBRARIES = ${PYTHON_LIBRARIES}")
message(STATUS "PYTHON_EXECUTABLE = ${PYTHON_EXECUTABLE}")
message(STATUS "PYTHON_INCLUDE_DIRS = ${PYTHON_INCLUDE_DIRS}")
message(STATUS "Boost_LIBRARIES = ${Boost_LIBRARIES}")
ENABLE_TESTING()
INCLUDE_DIRECTORIES(${Boost_INCLUDE_DIRS} ${PYTHON_INCLUDE_DIRS})
LINK_LIBRARIES(${Boost_LIBRARIES} ${PYTHON_LIBRARIES}) # Deprecated but so convenient!
ADD_SUBDIRECTORY(src/constants)
ADD_SUBDIRECTORY(src/simulation)