Repository navigation
Expand file tree
/
Copy pathCMakeLists.txt
More file actions
127 lines (108 loc) · 3.1 KB
/
Copy pathCMakeLists.txt
File metadata and controls
127 lines (108 loc) · 3.1 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
cmake_minimum_required(VERSION 3.11)
project(
orbit_integrator
VERSION 1.1.0
DESCRIPTION "Satellite Orbit Integrators for POD"
LANGUAGES CXX
)
# Ensure required libraries are available
find_package(datetime REQUIRED)
find_package(iers REQUIRED)
find_package(geodesy REQUIRED)
find_package(sysnsats REQUIRED)
find_package(rwatmo REQUIRED)
find_package(yaml-cpp REQUIRED)
# Try to find Boost
find_package(Boost)
# Conditionally handle Boost if found
if(Boost_FOUND)
message(STATUS "Boost found: ${Boost_INCLUDE_DIRS}")
include_directories(${Boost_INCLUDE_DIRS})
# Define macro USE_BOOST
add_compile_definitions(USE_BOOSTDD)
else()
message(STATUS "Boost NOT found; proceeding without it.")
endif()
# Pass the library dependencies to subdirectories
set(PROJECT_DEPENDENCIES rwatmo sysnsats iers geodesy datetime)
# Define an option for building binaries (defaults to ON)
option(BUILD_PROGS "Enable building of binaries" ON)
if(BUILD_PROGS)
find_package(sp3 REQUIRED)
find_library(CSPICE_LIB cspice REQUIRED)
endif()
# option for tests
option(BUILD_TESTS "Enable building of tests" ON)
# compiler flags
set(CMAKE_CXX_STANDARD 17)
set(CMAKE_CXX_STANDARD_REQUIRED On)
set(CMAKE_CXX_EXTENSIONS Off)
add_compile_options(-Wall
-Wextra
-Werror
-pedantic
-W
-Wshadow
$<$<CONFIG:Release>:-O2>
$<$<CONFIG:Release>:-march=native>
$<$<CONFIG:Debug>:-g>
$<$<CONFIG:Debug>:-pg>
$<$<CONFIG:Debug>:-Wdisabled-optimization>
)
add_compile_definitions(
$<$<CONFIG:Debug>:DEBUG>
)
# the library and includes
add_library(integrator)
target_include_directories(integrator
PUBLIC
# Public headers during build time
$<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/include/>
# Public headers during install time
$<INSTALL_INTERFACE:include/orbit_integrator>
PRIVATE
# Private/internal headers only during build time (src/core)
$<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/src>
# Internal/private headers during install time (from
# include/orbit_integrator/core)
# $<INSTALL_INTERFACE:include/orbit_integrator/core>
)
# library source code
add_subdirectory(src)
if(BUILD_PROGS)
add_subdirectory(bin)
endif()
if(BUILD_TESTS)
include(CTest)
add_subdirectory(test)
enable_testing()
endif()
# install library
install(TARGETS integrator
EXPORT integratorTargets
ARCHIVE DESTINATION lib
LIBRARY DESTINATION lib
RUNTIME DESTINATION bin
)
# Install public headers at: $PREFIX/orbit_integrator/...
install(DIRECTORY ${CMAKE_SOURCE_DIR}/include/
DESTINATION include/orbit_integrator
)
# Install private headers to a separate directory $PREFIX/datetime/core
# install(DIRECTORY ${CMAKE_SOURCE_DIR}/src/core/
# DESTINATION include/datetime/core
# )
install(EXPORT integratorTargets
FILE integratorTargets.cmake
NAMESPACE dso::
DESTINATION lib/cmake
)
include(CMakePackageConfigHelpers)
write_basic_package_version_file(
"integratorConfigVersion.cmake"
VERSION ${integrator_version}
COMPATIBILITY AnyNewerVersion
)
install(FILES "integratorConfig.cmake" "${CMAKE_CURRENT_BINARY_DIR}/integratorConfigVersion.cmake"
DESTINATION lib/cmake
)