-
Notifications
You must be signed in to change notification settings - Fork 4
/
Copy pathCMakeLists.txt
293 lines (258 loc) · 8.47 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
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
# Copyright (c) 2019 Pilz GmbH & Co. KG
#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU Lesser General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU Lesser General Public License for more details.
#
# You should have received a copy of the GNU Lesser General Public License
# along with this program. If not, see <https://www.gnu.org/licenses/>.
cmake_minimum_required(VERSION 2.8.12)
project(psen_scan)
add_compile_options(-std=c++11)
add_compile_options(-Wall)
add_compile_options(-Wextra)
add_compile_options(-Wno-unused-parameter)
add_compile_options(-Werror)
find_package(catkin REQUIRED COMPONENTS
roscpp
sensor_msgs
)
## System dependencies are found with CMake's conventions
find_package(Boost REQUIRED COMPONENTS system)
catkin_package(
CATKIN_DEPENDS roscpp sensor_msgs
)
###############
## Sanitizer ##
###############
# to run (only one sanitizer at a time):
# 1. Set environment variables for log_path in your shell
# export ASAN_OPTIONS="log_path=/path/to/asan-logs"
# export TSAN_OPTIONS="log_path=/path/to/tsan-logs"
# export UBSAN_OPTIONS="log_path=/path/to/ubsan-logs"
# 2. Compile
# catkin_make -DCATKIN_SANITIZER=address|thread|undefined
# 3. Run the node
# 4. Check log_path folder for contents
# build and devel folders have to be deleted before run
if(CATKIN_SANITIZER)
set(SANITIZER_OPTIONS "address|thread|undefined")
if(CATKIN_SANITIZER MATCHES ${SANITIZER_OPTIONS})
message(STATUS "${CATKIN_SANITIZER}-sanitizer activated.")
add_compile_options(-fsanitize=${CATKIN_SANITIZER} -g)
else()
message(FATAL_ERROR "${CATKIN_SANITIZER} is not a valid sanitizer. Valid options are: [${SANITIZER_OPTIONS}]")
endif()
endif()
################
## Clang tidy ##
################
# to run: catkin_make -DCATKIN_ENABLE_CLANG_TIDY=true
# build and devel folders have to be deleted before run
if(CATKIN_ENABLE_CLANG_TIDY)
find_program(
CLANG_TIDY_EXE
NAMES "clang-tidy"
DOC "Path to clang-tidy executable"
)
if(NOT CLANG_TIDY_EXE)
message(FATAL_ERROR "clang-tidy not found.")
else()
message(STATUS "clang-tidy found: ${CLANG_TIDY_EXE}")
set(CMAKE_CXX_CLANG_TIDY "${CLANG_TIDY_EXE}")
endif()
endif()
###########
## Build ##
###########
include_directories(
include
${catkin_INCLUDE_DIRS}
)
set(${PROJECT_NAME}_sources
src/scanner.cpp
src/scanner_frames.cpp
src/laserscan.cpp
src/psen_scan_internal_angle.cpp
src/psen_scan_udp_interface.cpp
)
set(${PROJECT_NAME}_node_sources
src/psen_scan_driver.cpp
src/ros_parameter_handler.cpp
src/ros_scanner_node.cpp
)
add_library(${PROJECT_NAME} ${${PROJECT_NAME}_sources})
target_link_libraries(${PROJECT_NAME}
${catkin_LIBRARIES}
)
add_executable(${PROJECT_NAME}_node ${${PROJECT_NAME}_node_sources})
target_link_libraries(${PROJECT_NAME}_node
${catkin_LIBRARIES}
${PROJECT_NAME}
)
#############
## Install ##
#############
install(DIRECTORY launch DESTINATION ${CATKIN_PACKAGE_SHARE_DESTINATION})
install(DIRECTORY config DESTINATION ${CATKIN_PACKAGE_SHARE_DESTINATION})
install(DIRECTORY include/${PROJECT_NAME}/
DESTINATION ${CATKIN_PACKAGE_INCLUDE_DESTINATION}
FILES_MATCHING PATTERN "*.h"
PATTERN ".svn" EXCLUDE
)
install(TARGETS
${PROJECT_NAME}
${PROJECT_NAME}_node
ARCHIVE DESTINATION ${CATKIN_PACKAGE_LIB_DESTINATION}
LIBRARY DESTINATION ${CATKIN_PACKAGE_LIB_DESTINATION}
RUNTIME DESTINATION ${CATKIN_PACKAGE_BIN_DESTINATION}
)
############
## Test ##
############
if(CATKIN_ENABLE_TESTING)
find_package(rostest REQUIRED)
find_package(roslaunch REQUIRED)
find_package(pilz_testutils REQUIRED)
if(ENABLE_COVERAGE_TESTING)
find_package(code_coverage REQUIRED)
APPEND_COVERAGE_COMPILER_FLAGS()
endif()
roslaunch_add_file_check(launch DEPENDENCIES ${PROJECT_NAME}_node)
include_directories(include
test/include
${pilz_testutils_INCLUDE_DIRS}
${catkin_INCLUDE_DIR}
)
##################
## Unit-Tests ##
##################
catkin_add_gmock(unittest_scanner
test/unit_tests/unittest_scanner.cpp
src/scanner.cpp
src/scanner_frames.cpp
src/laserscan.cpp
src/psen_scan_internal_angle.cpp
src/psen_scan_udp_interface.cpp
)
target_link_libraries(unittest_scanner
${catkin_LIBRARIES}
gtest_main
)
catkin_add_gtest(unittest_psen_scan_internal_angle
test/unit_tests/unittest_psen_scan_internal_angle.cpp
src/psen_scan_internal_angle.cpp
)
target_link_libraries(unittest_psen_scan_internal_angle
${catkin_LIBRARIES}
gtest_main
)
catkin_add_gtest(unittest_decrypt_password
test/unit_tests/unittest_decrypt_password.cpp
src/ros_parameter_handler.cpp
src/psen_scan_internal_angle.cpp
)
target_link_libraries(unittest_decrypt_password
${catkin_LIBRARIES}
gtest_main
)
catkin_add_gtest(unittest_build_new_exceptions
test/unit_tests/unittest_new_build_ros_message_exception.cpp
test/unit_tests/unittest_new_coherent_monitoring_frames_exception.cpp
test/unit_tests/unittest_new_decrypt_password_exception.cpp
test/unit_tests/unittest_new_diagnostic_information_exception.cpp
test/unit_tests/unittest_new_fetch_monitoring_frame_exception.cpp
test/unit_tests/unittest_new_get_ros_parameter_exception.cpp
test/unit_tests/unittest_new_parse_monitoring_frame_exception.cpp
test/unit_tests/unittest_new_psen_scan_fatal_exception.cpp
test/unit_tests/unittest_new_udp_read_timeout_exception.cpp
)
target_link_libraries(unittest_build_new_exceptions
${catkin_LIBRARIES}
gtest_main
)
catkin_add_gtest(unittest_timeout_adjust_func
test/unit_tests/unittest_timeout_adjust_func.cpp
)
target_link_libraries(unittest_timeout_adjust_func
${catkin_LIBRARIES}
gtest_main
)
catkin_add_gtest(unittest_scanner_communication_interface
test/unit_tests/unittest_scanner_communication_interface.cpp
src/psen_scan_udp_interface.cpp
src/psen_scan_internal_angle.cpp
)
target_link_libraries(unittest_scanner_communication_interface
${catkin_LIBRARIES}
gtest_main
)
#########################
## Integration-Tests ##
#########################
catkin_add_gmock(integrationtest_psen_scan_udp_interface
test/integration_tests/integrationtest_psen_scan_udp_interface.cpp
src/psen_scan_internal_angle.cpp
src/psen_scan_udp_interface.cpp
)
target_link_libraries(integrationtest_psen_scan_udp_interface
${catkin_LIBRARIES}
${pilz_testutils_LIBRARIES}
gtest_main
)
catkin_add_executable_with_gmock(${PROJECT_NAME}_integrationtest_scan_topic_node
test/integration_tests/integrationtest_scan_topic_node.cpp
src/laserscan.cpp
src/psen_scan_internal_angle.cpp
src/ros_scanner_node.cpp
)
target_link_libraries(${PROJECT_NAME}_integrationtest_scan_topic_node
${catkin_LIBRARIES}
)
add_rostest(
test/integration_tests/integrationtest_scan_topic.test DEPENDENCIES ${PROJECT_NAME}_integrationtest_scan_topic_node
)
add_rostest_gtest(integrationtest_ros_parameter_handler
test/integration_tests/integrationtest_ros_parameter_handler.test
test/integration_tests/integrationtest_ros_parameter_handler.cpp
src/ros_parameter_handler.cpp
src/psen_scan_internal_angle.cpp
)
target_link_libraries(integrationtest_ros_parameter_handler
${catkin_LIBRARIES}
)
add_rostest_gmock(integrationtest_ros_scanner_node
test/integration_tests/integrationtest_ros_scanner_node.test
test/integration_tests/integrationtest_ros_scanner_node.cpp
src/ros_scanner_node.cpp
src/laserscan.cpp
src/psen_scan_internal_angle.cpp
)
target_link_libraries(integrationtest_ros_scanner_node
${catkin_LIBRARIES}
)
########################
## Acceptance-Tests ##
########################
add_executable(acceptancetest_publish_test
test/acceptance_tests/acceptancetest_publish_test.cpp
)
target_link_libraries(acceptancetest_publish_test
${catkin_LIBRARIES}
)
# to run: catkin_make -DENABLE_COVERAGE_TESTING=ON -DCMAKE_BUILD_TYPE=Debug psen_scan_coverage (adding -j1 recommended)
if(ENABLE_COVERAGE_TESTING)
set(COVERAGE_EXCLUDES "*/${PROJECT_NAME}/test*"
"*/${PROJECT_NAME}/src/psen_scan_driver.cpp")
add_code_coverage(
NAME ${PROJECT_NAME}_coverage
DEPENDS tests
)
endif()
endif()