-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathCMakeLists.txt
139 lines (109 loc) · 2.75 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
#
# Copyright (c) 2019, New York University and Max Planck Gesellschaft.
#
# License BSD-3 clause
#
#
# set up the project
#
cmake_minimum_required(VERSION 3.10.2)
project(slider_box)
# Using C++17
if(NOT CMAKE_C_STANDARD)
set(CMAKE_C_STANDARD 99)
endif()
if(NOT CMAKE_CXX_STANDARD)
set(CMAKE_CXX_STANDARD 17)
endif()
#
# Dependencies
#
# Depend on ament macros.
find_package(ament_cmake REQUIRED)
# Usual dependencies.
find_package(mpi_cmake_modules REQUIRED)
find_package(real_time_tools REQUIRED)
find_package(rt REQUIRED)
find_package(Threads REQUIRED)
find_package(fmt REQUIRED)
find_package(spdlog REQUIRED)
# Export de dependencies.
ament_export_dependencies(
real_time_tools
spdlog
fmt
)
# Prepare the final export.
set(all_targets)
set(all_target_exports)
#
# Define the include directory of all ${CATKIN_PKGS}.
#
if(Xenomai_FOUND)
add_definitions(${Xenomai_DEFINITIONS})
endif()
#
# Manage the creation of the library.
#
set(${PROJECT_NAME}_src
src/serial_reader.cpp
)
# Create the library.
add_library(${PROJECT_NAME} SHARED ${slider_box_src})
# Add the include dependencies.
target_include_directories(
${PROJECT_NAME} PUBLIC $<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/include>
$<INSTALL_INTERFACE:include>)
if(Xenomai_FOUND)
target_include_directories(${PROJECT_NAME} PUBLIC ${Xenomai_INCLUDE_DIR})
endif()
# Link the catkin dependencies.
ament_target_dependencies(${PROJECT_NAME} rt)
target_link_libraries(${PROJECT_NAME}
real_time_tools::real_time_tools
Threads::Threads
fmt::fmt
spdlog::spdlog
)
# If on xenomai we need to link to the real time os librairies.
if(Xenomai_FOUND)
target_link_libraries(${PROJECT_NAME} ${Xenomai_LIBRARY_XENOMAI}
${Xenomai_LIBRARY_NATIVE} ${Xenomai_LIBRARY_RTDM})
endif()
# Export the target.
ament_export_interfaces(export_${PROJECT_NAME} HAS_LIBRARY_TARGET)
# For the installation
list(APPEND all_targets ${PROJECT_NAME})
list(APPEND all_target_exports export_${PROJECT_NAME})
#
# Demos
#
add_executable(demo_basic demos/basic.cpp)
# dependencies
target_include_directories(
demo_basic PUBLIC $<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/include>
$<INSTALL_INTERFACE:include>)
target_link_libraries(demo_basic ${PROJECT_NAME})
# Save the name for installation
set(all_targets ${all_targets} demo_basic)
#
# Install the package.
#
# Install the script to initialize the can bus
install(DIRECTORY include/ DESTINATION include)
install(
TARGETS ${all_targets}
EXPORT ${all_target_exports}
LIBRARY DESTINATION lib
ARCHIVE DESTINATION lib
RUNTIME DESTINATION lib/${PROJECT_NAME}
INCLUDES
DESTINATION include)
#
# Building documentation.
#
add_documentation()
#
# Export as an ament_package.
#
ament_package()