-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathCMakeLists.txt
147 lines (122 loc) · 4.09 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
cmake_minimum_required(VERSION 3.8)
project(catch_ros2)
if(CMAKE_COMPILER_IS_GNUCXX OR CMAKE_CXX_COMPILER_ID MATCHES "Clang")
add_compile_options(-Wall -Wextra -Wpedantic)
endif()
##################
## DEPENDENCIES ##
##################
find_package(ament_cmake REQUIRED)
find_package(ament_cmake_python REQUIRED)
find_package(rclcpp REQUIRED)
###########
## Build ##
###########
# Base Library
add_library(catch_ros2 SHARED
src/arguments.cpp src/catch_amalgamated.cpp
)
add_library(catch_ros2::catch_ros2 ALIAS catch_ros2)
target_include_directories(catch_ros2
PUBLIC
$<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/include>
$<INSTALL_INTERFACE:include>
)
target_link_libraries(catch_ros2 PUBLIC
rclcpp::rclcpp
)
target_compile_definitions(catch_ros2
PUBLIC CATCH_AMALGAMATED_CUSTOM_MAIN
)
# Library with Catch2 default main
add_library(catch_ros2_with_main SHARED
src/default_main.cpp
)
add_library(catch_ros2::catch_ros2_with_main ALIAS catch_ros2_with_main)
target_link_libraries(catch_ros2_with_main PUBLIC
catch_ros2
)
set_target_properties(catch_ros2_with_main
PROPERTIES
OUTPUT_NAME "catch_ros2_with_main"
)
# Library with custom main for running nodes
add_library(catch_ros2_with_node_main
src/node_main.cpp
)
add_library(catch_ros2::catch_ros2_with_node_main ALIAS catch_ros2_with_node_main)
target_link_libraries(catch_ros2_with_node_main PUBLIC
catch_ros2
)
set_target_properties(catch_ros2_with_node_main
PROPERTIES
OUTPUT_NAME "catch_ros2_with_node_main"
)
#############
## Install ##
#############
# install targets
install(TARGETS catch_ros2 catch_ros2_with_main catch_ros2_with_node_main
EXPORT export_catch_ros2
ARCHIVE DESTINATION lib
LIBRARY DESTINATION lib
RUNTIME DESTINATION bin
)
# install include directories
install(DIRECTORY include/ DESTINATION include/)
# Install launch utilities
ament_python_install_package(launch_catch_ros2
PACKAGE_DIR launch_catch_ros2
SETUP_CFG setup.cfg
)
# Install custom test runner
install(DIRECTORY scripts DESTINATION share/${PROJECT_NAME})
if(BUILD_TESTING)
find_package(ament_lint_auto REQUIRED)
# the following line skips the linter which checks for copyrights
# comment the line when a copyright and license is added to all source files
# set(ament_cmake_copyright_FOUND TRUE)
# the following line skips cpplint (only works in a git repo)
# comment the line when this package is in a git repo and when
# a copyright and license is added to all source files
# set(ament_cmake_cpplint_FOUND TRUE)
# Exclude Catch2 files from linting
list(APPEND CATCH2_LINT_EXCLUDE_FILES
${CMAKE_CURRENT_SOURCE_DIR}/src/default_main.cpp
${CMAKE_CURRENT_SOURCE_DIR}/src/catch_amalgamated.cpp
${CMAKE_CURRENT_SOURCE_DIR}/include/catch_amalgamated.hpp
)
list(APPEND ament_cmake_cpplint_ADDITIONAL_EXCLUDE ${CATCH2_LINT_EXCLUDE_FILES})
set(ament_cmake_uncrustify_ADDITIONAL_ARGS "--exclude")
list(APPEND ament_cmake_uncrustify_ADDITIONAL_ARGS ${CATCH2_LINT_EXCLUDE_FILES})
# Manually run copyright test, excluding Catch2 files since ROS 2 Humble does not have
# any way to exclude files from an auto copyright test
list(APPEND AMENT_LINT_AUTO_EXCLUDE ament_cmake_copyright)
find_package(ament_cmake_copyright)
ament_copyright(
TESTNAME manual_copyright
EXCLUDE ${CATCH2_LINT_EXCLUDE_FILES}
)
ament_lint_auto_find_test_dependencies()
# Set directories and include CMake function for use in examples
set(catch_ros2_DIR ${CMAKE_INSTALL_PREFIX}/share/${PROJECT_NAME}/cmake)
include(${CMAKE_CURRENT_SOURCE_DIR}/cmake/catch_ros2_add_integration_test.cmake)
include(examples/integration_test/CMakeLists.txt)
include(examples/unit_test/CMakeLists.txt)
include(examples/custom_main/CMakeLists.txt)
endif()
# Export old-style CMake variables
ament_export_include_directories("include")
ament_export_libraries(catch_ros2 catch_ros2_with_main catch_ros2_with_node_main)
# Export modern CMake targets
ament_export_targets(export_catch_ros2)
ament_export_dependencies(
rclcpp
)
ament_package(CONFIG_EXTRAS
cmake/catch_ros2_add_integration_test.cmake
)
install(
DIRECTORY cmake
DESTINATION share/${PROJECT_NAME}
)