-
Notifications
You must be signed in to change notification settings - Fork 73
/
CMakeLists.txt
97 lines (81 loc) · 3.42 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
cmake_minimum_required(VERSION 3.16)
project(realtime_tools LANGUAGES CXX)
if(CMAKE_CXX_COMPILER_ID MATCHES "(GNU|Clang)")
add_compile_options(-Wall -Wextra)
endif()
set(THIS_PACKAGE_INCLUDE_DEPENDS
rclcpp
rclcpp_action
Threads
rcpputils
)
find_package(ament_cmake REQUIRED)
foreach(Dependency IN ITEMS ${THIS_PACKAGE_INCLUDE_DEPENDS})
find_package(${Dependency} REQUIRED)
endforeach()
add_library(realtime_tools SHARED
src/realtime_clock.cpp
)
target_compile_features(realtime_tools PUBLIC cxx_std_17)
target_include_directories(realtime_tools PUBLIC
$<BUILD_INTERFACE:${PROJECT_SOURCE_DIR}/include>
$<INSTALL_INTERFACE:include/realtime_tools>
)
ament_target_dependencies(realtime_tools PUBLIC ${THIS_PACKAGE_INCLUDE_DEPENDS})
# A library to detect a realtime kernel and set thread priority, if one is found
add_library(thread_priority SHARED
src/thread_priority.cpp
)
target_compile_features(thread_priority PUBLIC cxx_std_17)
target_include_directories(thread_priority PUBLIC
$<BUILD_INTERFACE:${PROJECT_SOURCE_DIR}/include>
$<INSTALL_INTERFACE:include/realtime_tools>
)
ament_target_dependencies(thread_priority PUBLIC ${THIS_PACKAGE_INCLUDE_DEPENDS})
# Unit Tests
if(BUILD_TESTING)
find_package(ament_cmake_gmock REQUIRED)
find_package(lifecycle_msgs REQUIRED)
find_package(rclcpp_lifecycle REQUIRED)
find_package(test_msgs REQUIRED)
ament_add_gmock(realtime_box_tests test/realtime_box_tests.cpp)
target_link_libraries(realtime_box_tests realtime_tools)
ament_add_gmock(realtime_box_best_effort_tests test/realtime_box_best_effort_tests.cpp)
target_link_libraries(realtime_box_best_effort_tests realtime_tools)
ament_add_gmock(realtime_buffer_tests test/realtime_buffer_tests.cpp)
target_link_libraries(realtime_buffer_tests realtime_tools)
ament_add_gmock(realtime_clock_tests test/realtime_clock_tests.cpp)
target_link_libraries(realtime_clock_tests realtime_tools)
ament_add_gmock(realtime_publisher_tests_non_polling
test/realtime_publisher_non_polling.test
test/realtime_publisher_tests_non_polling.cpp)
target_link_libraries(realtime_publisher_tests_non_polling realtime_tools)
ament_target_dependencies(realtime_publisher_tests_non_polling test_msgs)
ament_add_gmock(realtime_publisher_tests
test/realtime_publisher.test
test/realtime_publisher_tests.cpp)
target_link_libraries(realtime_publisher_tests realtime_tools)
ament_target_dependencies(realtime_publisher_tests test_msgs)
ament_add_gmock(realtime_server_goal_handle_tests
test/realtime_server_goal_handle.test
test/realtime_server_goal_handle_tests.cpp)
target_link_libraries(realtime_server_goal_handle_tests realtime_tools)
ament_target_dependencies(realtime_server_goal_handle_tests test_msgs)
ament_add_gmock(test_async_function_handler test/test_async_function_handler.cpp)
target_link_libraries(test_async_function_handler realtime_tools thread_priority)
ament_target_dependencies(test_async_function_handler lifecycle_msgs rclcpp_lifecycle)
endif()
# Install
install(
DIRECTORY include/
DESTINATION include/realtime_tools
)
install(TARGETS realtime_tools thread_priority
EXPORT export_realtime_tools
ARCHIVE DESTINATION lib
LIBRARY DESTINATION lib
RUNTIME DESTINATION bin
)
ament_export_targets(export_realtime_tools HAS_LIBRARY_TARGET)
ament_export_dependencies(${THIS_PACKAGE_INCLUDE_DEPENDS})
ament_package()