-
Notifications
You must be signed in to change notification settings - Fork 128
/
CMakeLists.txt
167 lines (140 loc) · 5.53 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
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
cmake_minimum_required(VERSION 3.5)
project(rosidl_runtime_c C)
# Default to C11
if(NOT CMAKE_C_STANDARD)
set(CMAKE_C_STANDARD 11)
endif()
# Default to C++17
if(NOT CMAKE_CXX_STANDARD)
set(CMAKE_CXX_STANDARD 17)
set(CMAKE_CXX_STANDARD_REQUIRED ON)
endif()
if(CMAKE_COMPILER_IS_GNUCC OR CMAKE_C_COMPILER_ID MATCHES "Clang")
add_compile_options(-Wall -Wextra -Wpedantic)
endif()
find_package(ament_cmake_ros REQUIRED)
find_package(rcutils REQUIRED)
find_package(rosidl_typesupport_interface REQUIRED)
file(GLOB type_description_sources "src/type_description/*.c")
file(GLOB type_description_includes "include/rosidl_runtime_c/type_description/*.h")
add_library(${PROJECT_NAME}
"src/message_type_support.c"
"src/primitives_sequence_functions.c"
"src/sequence_bound.c"
"src/service_type_support.c"
"src/string_functions.c"
"src/type_hash.c"
"src/u16string_functions.c"
"src/type_description_utils.c"
${type_description_sources}
)
target_include_directories(${PROJECT_NAME} PUBLIC
"$<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/include>"
"$<INSTALL_INTERFACE:include/${PROJECT_NAME}>")
target_link_libraries(${PROJECT_NAME} PUBLIC
rcutils::rcutils
rosidl_typesupport_interface::rosidl_typesupport_interface
)
if(CMAKE_COMPILER_IS_GNUCC OR CMAKE_C_COMPILER_ID MATCHES "Clang")
set_target_properties(${PROJECT_NAME} PROPERTIES
COMPILE_OPTIONS -Wall -Wextra -Wpedantic)
endif()
if(WIN32)
target_compile_definitions(${PROJECT_NAME}
PRIVATE "ROSIDL_GENERATOR_C_BUILDING_DLL")
endif()
if(BUILD_TESTING AND NOT RCUTILS_DISABLE_FAULT_INJECTION)
target_compile_definitions(${PROJECT_NAME} PUBLIC RCUTILS_ENABLE_FAULT_INJECTION)
endif()
ament_export_dependencies(rcutils rosidl_typesupport_interface)
# Export old-style CMake variables
ament_export_include_directories("include/${PROJECT_NAME}")
ament_export_libraries(${PROJECT_NAME})
# Export modern CMake targets
ament_export_targets(${PROJECT_NAME})
ament_index_register_resource("rosidl_runtime_packages")
if(BUILD_TESTING)
find_package(ament_lint_auto REQUIRED)
find_package(performance_test_fixture REQUIRED)
# Give cppcheck hints about macro definitions coming from outside this package
get_target_property(ament_cmake_cppcheck_ADDITIONAL_INCLUDE_DIRS performance_test_fixture::performance_test_fixture
INTERFACE_INCLUDE_DIRECTORIES)
set(AMENT_LINT_AUTO_FILE_EXCLUDE ${type_description_includes} ${type_description_sources})
ament_lint_auto_find_test_dependencies()
# Run specific linters on copied generated code
if(ament_cmake_cppcheck_FOUND)
ament_cppcheck(
TESTNAME "cppcheck_copied_type_description_interfaces"
${type_description_includes} ${type_description_sources})
endif()
if(ament_cmake_cpplint_FOUND)
ament_cpplint(
TESTNAME "cpplint_copied_type_description_interfaces"
# the generated code might contain longer lines for templated types
MAX_LINE_LENGTH 999
${type_description_includes} ${type_description_sources})
endif()
if(ament_cmake_uncrustify_FOUND)
ament_uncrustify(
TESTNAME "uncrustify_copied_type_description_interfaces"
# the generated code might contain longer lines for templated types
MAX_LINE_LENGTH 0
${type_description_includes} ${type_description_sources})
endif()
# For gtest
enable_language(CXX)
# Default to C++17
if(NOT CMAKE_CXX_STANDARD)
set(CMAKE_CXX_STANDARD 17)
endif()
find_package(ament_cmake_gtest REQUIRED)
ament_add_gtest(test_message_type_support test/test_message_type_support.cpp)
if(TARGET test_message_type_support)
target_link_libraries(test_message_type_support ${PROJECT_NAME})
endif()
ament_add_gtest(test_primitives_sequence_functions test/test_primitives_sequence_functions.cpp)
if(TARGET test_primitives_sequence_functions)
target_link_libraries(test_primitives_sequence_functions ${PROJECT_NAME})
endif()
ament_add_gtest(test_sequence_bound test/test_sequence_bound.cpp)
if(TARGET test_sequence_bound)
target_link_libraries(test_sequence_bound ${PROJECT_NAME})
endif()
ament_add_gtest(test_service_type_support test/test_service_type_support.cpp)
if(TARGET test_service_type_support)
target_link_libraries(test_service_type_support ${PROJECT_NAME})
endif()
ament_add_gtest(test_string_functions test/test_string_functions.cpp)
if(TARGET test_string_functions)
target_link_libraries(test_string_functions ${PROJECT_NAME})
target_compile_definitions(test_string_functions PUBLIC RCUTILS_ENABLE_FAULT_INJECTION)
endif()
ament_add_gtest(test_type_hash test/test_type_hash.cpp)
if(TARGET test_type_hash)
target_link_libraries(test_type_hash ${PROJECT_NAME})
endif()
ament_add_gtest(test_u16string_functions test/test_u16string_functions.cpp)
if(TARGET test_u16string_functions)
target_link_libraries(test_u16string_functions ${PROJECT_NAME})
target_compile_definitions(test_u16string_functions PUBLIC RCUTILS_ENABLE_FAULT_INJECTION)
endif()
ament_add_gtest(test_type_description_utils test/test_type_description_utils.cpp)
if(TARGET test_type_description_utils)
target_link_libraries(test_type_description_utils ${PROJECT_NAME})
endif()
add_performance_test(benchmark_string_conversion test/benchmark/benchmark_string_conversion.cpp)
if(TARGET benchmark_string_conversion)
target_link_libraries(benchmark_string_conversion ${PROJECT_NAME})
endif()
endif()
install(
DIRECTORY include/
DESTINATION include/${PROJECT_NAME}
)
install(
TARGETS ${PROJECT_NAME} EXPORT ${PROJECT_NAME}
ARCHIVE DESTINATION lib
LIBRARY DESTINATION lib
RUNTIME DESTINATION bin
)
ament_package()