-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathCMakeLists.txt
115 lines (92 loc) · 3.46 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
cmake_minimum_required(VERSION 3.25)
project(rpl-sim)
set(CMAKE_CXX_STANDARD 14)
set(CMAKE_EXPORT_COMPILE_COMMANDS ON)
include(FetchContent)
if(NOT CMAKE_BUILD_TYPE)
set(CMAKE_BUILD_TYPE Release)
endif()
set(CMAKE_CXX_FLAGS "-Wall -Wextra")
set(CMAKE_CXX_FLAGS_DEBUG "-g")
set(CMAKE_CXX_FLAGS_RELEASE "-O3")
##############################################################################
# PROJECT FILES
##############################################################################
set(RPLSIM_FILES src/PhoenixPositionProvider.cpp src/PhoenixPositionProviderUtility.cpp src/Vector3.cpp)
##############################################################################
# CATCH2 AND EIGEN -- REMOTE SOURCE
##############################################################################
FetchContent_Declare(
Catch2
GIT_REPOSITORY https://github.com/catchorg/Catch2.git
GIT_TAG v3.4.0
)
FetchContent_Declare(
Eigen3
GIT_REPOSITORY "https://gitlab.com/libeigen/eigen.git"
GIT_TAG "3.4.0"
)
FetchContent_MakeAvailable(Catch2)
FetchContent_MakeAvailable(Eigen3)
##############################################################################
# BOOST
##############################################################################
# Fetch Boost from included source
# TODO: Possibly use an installed Boost rather than Boost included in the source.
set(BOOST_ENABLE_CMAKE ON)
#set(BOOST_INCLUDEDIR "./lib/boost_1_82_0/")
find_package(Boost 1.74 REQUIRED COMPONENTS program_options) # Expects environmental variable BOOST_INCLUDEDIR
##############################################################################
# LINK LIBRARIES
##############################################################################
include_directories(src)
link_directories(src)
include_directories(lib/spline)
include_directories(lib/json)
include_directories(lib/optparse)
##############################################################################
# PROGRAM BUILD INFRASTRUCTURE
##############################################################################
add_executable(
main_exe
src/main.cpp
${RPLSIM_FILES}
)
target_link_libraries(main_exe LINK_PUBLIC Boost::boost Boost::program_options)
target_link_libraries(main_exe PRIVATE Eigen3::Eigen)
##############################################################################
# INCLUDE CSVS WITH BUILD INFRASTRUCTURE
##############################################################################
add_custom_command(
TARGET main_exe PRE_BUILD
COMMAND ${CMAKE_COMMAND} -E copy
${CMAKE_SOURCE_DIR}/data/atmosisa.csv
$<TARGET_FILE_DIR:main_exe>/atmosisa.csv
)
add_custom_command(
TARGET main_exe PRE_BUILD
COMMAND ${CMAKE_COMMAND} -E copy
${CMAKE_SOURCE_DIR}/data/mach_vs_cd.csv
$<TARGET_FILE_DIR:main_exe>/mach_vs_cd.csv
)
add_custom_command(
TARGET main_exe PRE_BUILD
COMMAND ${CMAKE_COMMAND} -E copy
${CMAKE_SOURCE_DIR}/data/thrust_curve.csv
$<TARGET_FILE_DIR:main_exe>/thrust_curve.csv
)
##############################################################################
# TEST INFRASTRUCTURE
##############################################################################
add_executable(
tests
test/tests.cpp
${RPLSIM_FILES}
)
target_link_libraries(tests LINK_PUBLIC Boost::boost Boost::program_options)
target_link_libraries(tests PRIVATE Catch2::Catch2WithMain Eigen3::Eigen)
# https://github.com/catchorg/Catch2/blob/devel/docs/cmake-integration.md
list(APPEND CMAKE_MODULE_PATH ${catch2_SOURCE_DIR}/extras)
include(CTest)
include(Catch)
catch_discover_tests(tests)