From 861d97731534f2a44f4a78d6d5f4501ab1dabe39 Mon Sep 17 00:00:00 2001 From: Nahuel Espinosa Date: Thu, 6 Jul 2023 18:46:18 -0300 Subject: [PATCH] Add cmake-lint to pre-commit hooks Signed-off-by: Nahuel Espinosa --- .cmake-format | 15 +++++ .pre-commit-config.yaml | 8 ++- beluga/CMakeLists.txt | 73 ++++++++++++++-------- beluga/docs/CMakeLists.txt | 25 ++++++-- beluga/test/CMakeLists.txt | 41 +++++++++--- beluga/test/beluga/CMakeLists.txt | 20 +++++- beluga/test/benchmark/CMakeLists.txt | 30 ++++++--- beluga_amcl/CMakeLists.txt | 25 +++++++- beluga_amcl/cmake/ament.cmake | 45 ++++++++------ beluga_amcl/cmake/catkin.cmake | 83 +++++++++++++------------ beluga_amcl/cmake/lib/nodelets.cmake | 14 ++++- beluga_amcl/package.xml | 1 - beluga_amcl/test/CMakeLists.txt | 14 +++++ beluga_amcl/test/cmake/ament.cmake | 16 ++--- beluga_amcl/test/cmake/catkin.cmake | 33 +++++++--- beluga_benchmark/CMakeLists.txt | 21 +++++-- beluga_example/CMakeLists.txt | 14 +++++ beluga_example/cmake/ament.cmake | 19 +++--- beluga_example/cmake/catkin.cmake | 15 +++-- beluga_example/package.xml | 1 - beluga_system_tests/CMakeLists.txt | 25 +++++++- beluga_system_tests/test/CMakeLists.txt | 27 +++++--- 22 files changed, 403 insertions(+), 162 deletions(-) create mode 100644 .cmake-format diff --git a/.cmake-format b/.cmake-format new file mode 100644 index 000000000..4d470d93a --- /dev/null +++ b/.cmake-format @@ -0,0 +1,15 @@ +# ----------------------------- +# Options affecting formatting. +# ----------------------------- +with section("format"): + # Force vertical layout if an argument group contains more than this many sub-groups. + max_subgroups_hwrap = 2 + # Force vertical layout if a positional argument group contains more than this many arguments. + max_pargs_hwrap = 3 + +# ------------------------------------------------ +# Options affecting comment reflow and formatting. +# ------------------------------------------------ +with section("markup"): + # Disable comment markup parsing and reflow. + enable_markup = False diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index fef3d3b26..2c8d34d78 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -19,7 +19,7 @@ repos: name: fix copyright description: Check that files have a copyright notice. entry: tools/check_copyright.py --fix - types_or: [c++, python] + types_or: [c++, python, cmake] language: python language_version: python3 @@ -44,3 +44,9 @@ repos: - id: black name: "fix python format" entry: black --skip-string-normalization + + - repo: https://github.com/cheshirekow/cmake-format-precommit + rev: v0.6.13 + hooks: + - id: cmake-lint + - id: cmake-format diff --git a/beluga/CMakeLists.txt b/beluga/CMakeLists.txt index 9bb69f1ef..9949806e6 100644 --- a/beluga/CMakeLists.txt +++ b/beluga/CMakeLists.txt @@ -1,3 +1,17 @@ +# Copyright 2023 Ekumen, Inc. +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + cmake_minimum_required(VERSION 3.16) project(beluga VERSION 1.0) @@ -6,12 +20,21 @@ set(CMAKE_EXPORT_COMPILE_COMMANDS ON) if(NOT CMAKE_BUILD_TYPE) message(STATUS "Setting build type to 'Release' as none was specified.") - set(CMAKE_BUILD_TYPE "Release" CACHE STRING "Build type" FORCE) + set(CMAKE_BUILD_TYPE + "Release" + CACHE STRING "Build type" FORCE) endif() add_library(beluga_compile_options INTERFACE) if(CMAKE_COMPILER_IS_GNUCXX OR CMAKE_CXX_COMPILER_ID MATCHES "Clang") - target_compile_options(beluga_compile_options INTERFACE -Wall -Wconversion -Werror -Wextra -Wpedantic -Wno-gnu-zero-variadic-macro-arguments) + target_compile_options( + beluga_compile_options + INTERFACE -Wall + -Wconversion + -Werror + -Wextra + -Wpedantic + -Wno-gnu-zero-variadic-macro-arguments) endif() find_package(Eigen3 REQUIRED NO_MODULE) @@ -20,17 +43,24 @@ find_package(Sophus REQUIRED) find_package(TBB REQUIRED) add_library(${PROJECT_NAME} INTERFACE) -target_include_directories(${PROJECT_NAME} INTERFACE - "$" - "$") -target_link_libraries(${PROJECT_NAME} - INTERFACE Eigen3::Eigen Sophus::Sophus TBB::tbb range-v3::range-v3) +target_include_directories( + ${PROJECT_NAME} + INTERFACE "$" + "$") +target_link_libraries( + ${PROJECT_NAME} + INTERFACE Eigen3::Eigen + Sophus::Sophus + TBB::tbb + range-v3::range-v3) target_compile_features(${PROJECT_NAME} INTERFACE cxx_std_17) -target_compile_definitions(${PROJECT_NAME} INTERFACE EIGEN_NO_DEBUG SOPHUS_USE_BASIC_LOGGING) +target_compile_definitions(${PROJECT_NAME} INTERFACE EIGEN_NO_DEBUG + SOPHUS_USE_BASIC_LOGGING) add_executable(clang_tidy_findable) target_sources(clang_tidy_findable PRIVATE src/clang_tidy_findable.cpp) -target_link_libraries(clang_tidy_findable PRIVATE ${PROJECT_NAME} beluga_compile_options) +target_link_libraries(clang_tidy_findable PRIVATE ${PROJECT_NAME} + beluga_compile_options) option(BUILD_TESTING "Build the testing tree." ON) if(BUILD_TESTING) @@ -47,39 +77,30 @@ endif() set(INSTALL_CMAKEDIR ${CMAKE_INSTALL_PREFIX}/share/${PROJECT_NAME}/cmake) -install( - DIRECTORY include/ - DESTINATION include/${PROJECT_NAME} -) +install(DIRECTORY include/ DESTINATION include/${PROJECT_NAME}) install( TARGETS ${PROJECT_NAME} EXPORT ${PROJECT_NAME}Targets ARCHIVE DESTINATION lib LIBRARY DESTINATION lib - RUNTIME DESTINATION bin -) + RUNTIME DESTINATION bin) install( EXPORT ${PROJECT_NAME}Targets FILE ${PROJECT_NAME}Targets.cmake NAMESPACE ${PROJECT_NAME}:: - DESTINATION ${INSTALL_CMAKEDIR} -) + DESTINATION ${INSTALL_CMAKEDIR}) include(CMakePackageConfigHelpers) configure_package_config_file( ${CMAKE_CURRENT_SOURCE_DIR}/cmake/Config.cmake.in "${CMAKE_CURRENT_BINARY_DIR}/${PROJECT_NAME}Config.cmake" - INSTALL_DESTINATION ${INSTALL_CMAKEDIR} -) + INSTALL_DESTINATION ${INSTALL_CMAKEDIR}) write_basic_package_version_file( ${CMAKE_CURRENT_BINARY_DIR}/${PROJECT_NAME}ConfigVersion.cmake - COMPATIBILITY SameMajorVersion ) + COMPATIBILITY SameMajorVersion) -install( - FILES - "${CMAKE_CURRENT_BINARY_DIR}/${PROJECT_NAME}Config.cmake" - "${CMAKE_CURRENT_BINARY_DIR}/${PROJECT_NAME}ConfigVersion.cmake" - DESTINATION ${INSTALL_CMAKEDIR} -) +install(FILES "${CMAKE_CURRENT_BINARY_DIR}/${PROJECT_NAME}Config.cmake" + "${CMAKE_CURRENT_BINARY_DIR}/${PROJECT_NAME}ConfigVersion.cmake" + DESTINATION ${INSTALL_CMAKEDIR}) diff --git a/beluga/docs/CMakeLists.txt b/beluga/docs/CMakeLists.txt index 6c3bbc6fc..6dc73e026 100644 --- a/beluga/docs/CMakeLists.txt +++ b/beluga/docs/CMakeLists.txt @@ -1,3 +1,17 @@ +# Copyright 2023 Ekumen, Inc. +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + find_package(Doxygen) if(DOXYGEN_FOUND) @@ -6,14 +20,15 @@ if(DOXYGEN_FOUND) FetchContent_Declare( doxygen-awesome-css GIT_REPOSITORY https://github.com/jothepro/doxygen-awesome-css - GIT_TAG v2.2.0 - SOURCE_DIR ${CMAKE_CURRENT_BINARY_DIR}/doxygen-awesome - ) + GIT_TAG v2.2.0 + SOURCE_DIR ${CMAKE_CURRENT_BINARY_DIR}/doxygen-awesome) FetchContent_MakeAvailable(doxygen-awesome-css) - add_custom_target(beluga_docs - ALL + # cmake-lint: disable=C0301 + # Line too long + add_custom_target( + beluga_docs ALL COMMAND DOXYGEN_OUTPUT_DIRECTORY=${CMAKE_CURRENT_BINARY_DIR} DOXYGEN_HTML_STYLESHEET=${CMAKE_CURRENT_BINARY_DIR}/doxygen-awesome/doxygen-awesome.css diff --git a/beluga/test/CMakeLists.txt b/beluga/test/CMakeLists.txt index 69c31e422..95abc6119 100644 --- a/beluga/test/CMakeLists.txt +++ b/beluga/test/CMakeLists.txt @@ -1,25 +1,48 @@ +# Copyright 2023 Ekumen, Inc. +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + find_package(GTest MODULE) if(NOT TARGET GTest::gmock_main) include(FetchContent) FetchContent_Declare( googletest - URL https://github.com/google/googletest/archive/03597a01ee50ed33e9dfd640b249b4be3799d395.zip - ) - # For Windows: Prevent overriding the parent project's compiler/linker settings - set(gtest_force_shared_crt ON CACHE BOOL "" FORCE) + GIT_REPOSITORY https://github.com/google/googletest.git + GIT_TAG 03597a01ee50ed33e9dfd640b249b4be3799d395) + # For Windows: Prevent overriding the parent project's compiler/linker + # settings + set(GTEST_FORCE_SHARED_CRT + ON + CACHE BOOL "" FORCE) FetchContent_MakeAvailable(googletest) endif() find_package(benchmark REQUIRED) if(NOT TARGET benchmark::benchmark_main) include(FetchContent) - set(BENCHMARK_ENABLE_GTEST_TESTS OFF CACHE INTERNAL "") + # cmake-lint: disable=C0103 + # Invalid INTERNAL variable name doesn't match `_[A-Z][0-9A-Z_]+` + set(BENCHMARK_ENABLE_GTEST_TESTS + OFF + CACHE INTERNAL "") FetchContent_Declare( benchmark - URL https://github.com/google/benchmark/archive/refs/tags/v1.7.1.zip - ) - # For Windows: Prevent overriding the parent project's compiler/linker settings - set(gtest_force_shared_crt ON CACHE BOOL "" FORCE) + URL https://github.com/google/benchmark/archive/refs/tags/v1.7.1.zip) + # For Windows: Prevent overriding the parent project's compiler/linker + # settings + set(GTEST_FORCE_SHARED_CRT + ON + CACHE BOOL "" FORCE) FetchContent_MakeAvailable(benchmark) endif() diff --git a/beluga/test/beluga/CMakeLists.txt b/beluga/test/beluga/CMakeLists.txt index f1d9d57e0..199d51a84 100644 --- a/beluga/test/beluga/CMakeLists.txt +++ b/beluga/test/beluga/CMakeLists.txt @@ -1,4 +1,19 @@ -add_executable(test_beluga +# Copyright 2023 Ekumen, Inc. +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +add_executable( + test_beluga algorithm/raycasting/test_bresenham.cpp algorithm/test_distance_map.cpp algorithm/test_estimation.cpp @@ -23,7 +38,8 @@ add_executable(test_beluga test_storage.cpp type_traits/test_strongly_typed_numeric.cpp) -target_link_libraries(test_beluga PRIVATE ${PROJECT_NAME} beluga_compile_options GTest::gmock_main) +target_link_libraries( + test_beluga PRIVATE ${PROJECT_NAME} beluga_compile_options GTest::gmock_main) target_include_directories(test_beluga PRIVATE include) target_compile_options(test_beluga PRIVATE -Wno-sign-compare) diff --git a/beluga/test/benchmark/CMakeLists.txt b/beluga/test/benchmark/CMakeLists.txt index 9012bbc84..f59e94f60 100644 --- a/beluga/test/benchmark/CMakeLists.txt +++ b/beluga/test/benchmark/CMakeLists.txt @@ -1,7 +1,22 @@ +# Copyright 2023 Ekumen, Inc. +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + option(BELUGA_RUN_PERFORMANCE_TESTS - "Enable performance tests instead of unconditionally skipping them" OFF) + "Enable performance tests instead of unconditionally skipping them" OFF) -add_executable(benchmark_beluga +add_executable( + benchmark_beluga benchmark_likelihood_field_model.cpp benchmark_raycasting.cpp benchmark_sampling.cpp @@ -9,15 +24,16 @@ add_executable(benchmark_beluga benchmark_tuple_vector.cpp benchmark_main.cpp) target_include_directories(benchmark_beluga PRIVATE ../beluga/include) -target_link_libraries(benchmark_beluga +target_link_libraries( + benchmark_beluga PUBLIC benchmark::benchmark PRIVATE ${PROJECT_NAME} beluga_compile_options) set(TEST_RESULTS_DIR "${CMAKE_BINARY_DIR}/test_results/${PROJECT_NAME}") file(MAKE_DIRECTORY ${TEST_RESULTS_DIR}) -set(benchmark_out "${TEST_RESULTS_DIR}/benchmark_beluga.google_benchmark.json") +set(BENCHMARK_OUT "${TEST_RESULTS_DIR}/benchmark_beluga.google_benchmark.json") if(BELUGA_RUN_PERFORMANCE_TESTS) - add_test( - NAME benchmark_beluga - COMMAND benchmark_beluga "--benchmark_out_format=json" "--benchmark_out=${benchmark_out}") + add_test(NAME benchmark_beluga + COMMAND benchmark_beluga "--benchmark_out_format=json" + "--benchmark_out=${BENCHMARK_OUT}") endif() diff --git a/beluga_amcl/CMakeLists.txt b/beluga_amcl/CMakeLists.txt index a18629254..e8ca90bb5 100644 --- a/beluga_amcl/CMakeLists.txt +++ b/beluga_amcl/CMakeLists.txt @@ -1,3 +1,17 @@ +# Copyright 2023 Ekumen, Inc. +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + cmake_minimum_required(VERSION 3.16) project(beluga_amcl) @@ -6,11 +20,18 @@ set(CMAKE_EXPORT_COMPILE_COMMANDS ON) if(NOT CMAKE_BUILD_TYPE) message(STATUS "Setting build type to 'Release' as none was specified.") - set(CMAKE_BUILD_TYPE "Release" CACHE STRING "Build type" FORCE) + set(CMAKE_BUILD_TYPE + "Release" + CACHE STRING "Build type" FORCE) endif() if(CMAKE_COMPILER_IS_GNUCXX OR CMAKE_CXX_COMPILER_ID MATCHES "Clang") - add_compile_options(-Wall -Wconversion -Wextra -Werror -Wpedantic) + add_compile_options( + -Wall + -Wconversion + -Wextra + -Werror + -Wpedantic) endif() set(ROS_VERSION $ENV{ROS_VERSION}) diff --git a/beluga_amcl/cmake/ament.cmake b/beluga_amcl/cmake/ament.cmake index 1bc16d9eb..744ec2f19 100644 --- a/beluga_amcl/cmake/ament.cmake +++ b/beluga_amcl/cmake/ament.cmake @@ -27,14 +27,15 @@ find_package(tf2_eigen REQUIRED) find_package(tf2_geometry_msgs REQUIRED) add_library(amcl_node_utils SHARED) -target_sources(amcl_node_utils PRIVATE - src/amcl_node_utils.cpp - src/particle_filtering.cpp) -target_include_directories(amcl_node_utils PUBLIC - $ - $) +target_sources(amcl_node_utils PRIVATE src/amcl_node_utils.cpp + src/particle_filtering.cpp) +target_include_directories( + amcl_node_utils PUBLIC $ + $) target_link_libraries(amcl_node_utils PUBLIC beluga::beluga) -ament_target_dependencies(amcl_node_utils PUBLIC +ament_target_dependencies( + amcl_node_utils + PUBLIC geometry_msgs nav_msgs sensor_msgs @@ -45,12 +46,13 @@ target_compile_definitions(amcl_node_utils PUBLIC BELUGA_AMCL_ROS_VERSION=2) target_compile_features(amcl_node_utils PUBLIC cxx_std_17) add_library(amcl_node_component SHARED) -target_sources(amcl_node_component PRIVATE - src/amcl_node.cpp - src/amcl_node_utils.cpp) +target_sources(amcl_node_component PRIVATE src/amcl_node.cpp + src/amcl_node_utils.cpp) target_compile_features(amcl_node_component PUBLIC cxx_std_17) target_link_libraries(amcl_node_component PUBLIC beluga::beluga amcl_node_utils) -ament_target_dependencies(amcl_node_component PUBLIC +ament_target_dependencies( + amcl_node_component + PUBLIC bondcpp nav_msgs nav2_msgs @@ -59,8 +61,12 @@ ament_target_dependencies(amcl_node_component PUBLIC rclcpp_lifecycle sensor_msgs std_srvs) -rclcpp_components_register_node(amcl_node_component - PLUGIN "beluga_amcl::AmclNode" EXECUTABLE amcl_node) +rclcpp_components_register_node( + amcl_node_component + PLUGIN + "beluga_amcl::AmclNode" + EXECUTABLE + amcl_node) ament_export_dependencies( beluga @@ -72,14 +78,13 @@ ament_export_dependencies( sensor_msgs tf2 tf2_eigen - tf2_geometry_msgs -) + tf2_geometry_msgs) ament_export_include_directories("include/${PROJECT_NAME}") ament_export_definitions(BELUGA_AMCL_ROS_VERSION=2) ament_export_targets(amcl_node_utils HAS_LIBRARY_TARGET) -install(TARGETS - amcl_node_component +install( + TARGETS amcl_node_component ARCHIVE DESTINATION lib LIBRARY DESTINATION lib RUNTIME DESTINATION bin) @@ -91,10 +96,10 @@ install( LIBRARY DESTINATION lib RUNTIME DESTINATION bin) -install(TARGETS amcl_node - DESTINATION lib/${PROJECT_NAME}) +install(TARGETS amcl_node DESTINATION lib/${PROJECT_NAME}) -install(DIRECTORY include/ +install( + DIRECTORY include/ DESTINATION include/${PROJECT_NAME} PATTERN "beluga_amcl/private" EXCLUDE) diff --git a/beluga_amcl/cmake/catkin.cmake b/beluga_amcl/cmake/catkin.cmake index 231f609ed..051545080 100644 --- a/beluga_amcl/cmake/catkin.cmake +++ b/beluga_amcl/cmake/catkin.cmake @@ -15,50 +15,51 @@ include(cmake/lib/nodelets.cmake) find_package(beluga REQUIRED) -find_package(catkin REQUIRED - COMPONENTS - bondcpp - diagnostic_updater - dynamic_reconfigure - message_filters - nav_msgs - nodelet - roscpp - sensor_msgs - std_srvs - tf2 - tf2_geometry_msgs - tf2_msgs - tf2_ros -) +find_package( + catkin REQUIRED + COMPONENTS bondcpp + diagnostic_updater + dynamic_reconfigure + message_filters + nav_msgs + nodelet + roscpp + sensor_msgs + std_srvs + tf2 + tf2_geometry_msgs + tf2_msgs + tf2_ros) generate_dynamic_reconfigure_options(config/Amcl.cfg) catkin_package( CATKIN_DEPENDS - bondcpp - nav_msgs - roscpp - sensor_msgs - tf2 - tf2_eigen - tf2_geometry_msgs - DEPENDS beluga - INCLUDE_DIRS include - LIBRARIES ${PROJECT_NAME} - CFG_EXTRAS ${PROJECT_NAME}-extras.cmake -) + bondcpp + nav_msgs + roscpp + sensor_msgs + tf2 + tf2_eigen + tf2_geometry_msgs + DEPENDS + beluga + INCLUDE_DIRS + include + LIBRARIES + ${PROJECT_NAME} + CFG_EXTRAS + ${PROJECT_NAME}-extras.cmake) add_compile_definitions(BELUGA_AMCL_ROS_VERSION=1) include_directories(include ${catkin_INCLUDE_DIRS}) add_library(${PROJECT_NAME} SHARED) -target_sources(${PROJECT_NAME} PRIVATE - src/amcl_node_utils.cpp - src/particle_filtering.cpp) -target_include_directories(${PROJECT_NAME} PUBLIC - $ - $) +target_sources(${PROJECT_NAME} PRIVATE src/amcl_node_utils.cpp + src/particle_filtering.cpp) +target_include_directories( + ${PROJECT_NAME} PUBLIC $ + $) target_link_libraries(${PROJECT_NAME} beluga::beluga ${catkin_LIBRARIES}) add_library(${PROJECT_NAME}_nodelet SHARED) @@ -70,21 +71,21 @@ add_dependencies(${PROJECT_NAME}_nodelet ${PROJECT_NAME}_gencfg) add_nodelet_executable(amcl_node "beluga_amcl/AmclNodelet") target_compile_features(amcl_node PUBLIC cxx_std_17) -install(TARGETS ${PROJECT_NAME} ${PROJECT_NAME}_nodelet +install( + TARGETS ${PROJECT_NAME} ${PROJECT_NAME}_nodelet ARCHIVE DESTINATION ${CATKIN_PACKAGE_LIB_DESTINATION} LIBRARY DESTINATION ${CATKIN_PACKAGE_LIB_DESTINATION} RUNTIME DESTINATION ${CATKIN_PACKAGE_BIN_DESTINATION}) -install(TARGETS amcl_node - RUNTIME DESTINATION ${CATKIN_PACKAGE_BIN_DESTINATION}) +install(TARGETS amcl_node RUNTIME DESTINATION ${CATKIN_PACKAGE_BIN_DESTINATION}) -install(DIRECTORY include/${PROJECT_NAME}/ +install( + DIRECTORY include/${PROJECT_NAME}/ DESTINATION ${CATKIN_PACKAGE_INCLUDE_DESTINATION} PATTERN "beluga_amcl/private" EXCLUDE) -install( - FILES nodelet_plugins.xml - DESTINATION ${CATKIN_PACKAGE_SHARE_DESTINATION}/) +install(FILES nodelet_plugins.xml + DESTINATION ${CATKIN_PACKAGE_SHARE_DESTINATION}/) if(CATKIN_ENABLE_TESTING OR BUILD_TESTING) enable_testing() diff --git a/beluga_amcl/cmake/lib/nodelets.cmake b/beluga_amcl/cmake/lib/nodelets.cmake index dc6ea3298..d9b8b1a41 100644 --- a/beluga_amcl/cmake/lib/nodelets.cmake +++ b/beluga_amcl/cmake/lib/nodelets.cmake @@ -12,19 +12,29 @@ # See the License for the specific language governing permissions and # limitations under the License. +# cmake-lint: disable=C0111,C0103 +# Missing docstring on function or macro declaration +# Invalid local variable name "EXECUTABLE" doesn't match `[a-z][a-z0-9_]+` +# Invalid local variable name "NODELETS" doesn't match `[a-z][a-z0-9_]+` function(add_nodelet_executable target) set(EXECUTABLE ${target}) if(ARGC LESS 2) message(FATAL_ERROR "No nodelets specified for ${target} executable.") endif() - string(REPLACE ";" "\",\"" NODELETS "${ARGN}") + + string( + REPLACE ";" + "\",\"" + NODELETS + "${ARGN}") set(NODELETS "\"${NODELETS}\"") configure_file( ${PROJECT_SOURCE_DIR}/cmake/lib/templates/nodelet_executable_main.cpp.in ${PROJECT_BINARY_DIR}/${target}_main.cpp.in @ONLY) file( - GENERATE OUTPUT ${PROJECT_BINARY_DIR}/${target}_main.cpp + GENERATE + OUTPUT ${PROJECT_BINARY_DIR}/${target}_main.cpp INPUT ${PROJECT_BINARY_DIR}/${target}_main.cpp.in) add_executable(${target} ${PROJECT_BINARY_DIR}/${target}_main.cpp) target_link_libraries(${target} ${catkin_LIBRARIES}) diff --git a/beluga_amcl/package.xml b/beluga_amcl/package.xml index d2ed00458..868416cc6 100644 --- a/beluga_amcl/package.xml +++ b/beluga_amcl/package.xml @@ -40,7 +40,6 @@ rostest ament_cmake_gmock ament_cmake_gtest - ament_cmake_lint_cmake ament_lint_auto diff --git a/beluga_amcl/test/CMakeLists.txt b/beluga_amcl/test/CMakeLists.txt index 480263c08..acaeda1e0 100644 --- a/beluga_amcl/test/CMakeLists.txt +++ b/beluga_amcl/test/CMakeLists.txt @@ -1,3 +1,17 @@ +# Copyright 2023 Ekumen, Inc. +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + if(ROS_VERSION EQUAL 1) include(cmake/catkin.cmake) elseif(ROS_VERSION EQUAL 2) diff --git a/beluga_amcl/test/cmake/ament.cmake b/beluga_amcl/test/cmake/ament.cmake index 00a967f7c..b8e709551 100644 --- a/beluga_amcl/test/cmake/ament.cmake +++ b/beluga_amcl/test/cmake/ament.cmake @@ -22,11 +22,13 @@ ament_add_gmock(test_amcl_node_utils test_amcl_node_utils.cpp) target_compile_options(test_amcl_node_utils PRIVATE -Wno-deprecated-copy) target_link_libraries(test_amcl_node_utils amcl_node_component) -ament_add_gmock(test_amcl_node_resampling_policies - filter_update_control/test_filter_update_control_mixin.cpp - filter_update_control/test_resample_interval_policy.cpp - filter_update_control/test_selective_resampling_policy.cpp - filter_update_control/test_update_filter_when_moving_policy.cpp -) -target_compile_options(test_amcl_node_resampling_policies PRIVATE -Wno-deprecated-copy -Wno-gnu-zero-variadic-macro-arguments) +ament_add_gmock( + test_amcl_node_resampling_policies + filter_update_control/test_filter_update_control_mixin.cpp + filter_update_control/test_resample_interval_policy.cpp + filter_update_control/test_selective_resampling_policy.cpp + filter_update_control/test_update_filter_when_moving_policy.cpp) +target_compile_options( + test_amcl_node_resampling_policies + PRIVATE -Wno-deprecated-copy -Wno-gnu-zero-variadic-macro-arguments) target_link_libraries(test_amcl_node_resampling_policies amcl_node_component) diff --git a/beluga_amcl/test/cmake/catkin.cmake b/beluga_amcl/test/cmake/catkin.cmake index fc6c208ce..81908c0ec 100644 --- a/beluga_amcl/test/cmake/catkin.cmake +++ b/beluga_amcl/test/cmake/catkin.cmake @@ -15,16 +15,29 @@ find_package(rostest REQUIRED) catkin_add_gmock(test_amcl_node_utils test_amcl_node_utils.cpp) -target_link_libraries(test_amcl_node_utils ${PROJECT_NAME} ${catkin_LIBRARIES} gmock_main) +target_link_libraries( + test_amcl_node_utils + ${PROJECT_NAME} + ${catkin_LIBRARIES} + gmock_main) add_rostest_gtest(test_amcl_nodelet amcl_nodelet.test test_amcl_nodelet.cpp) -target_link_libraries(test_amcl_nodelet ${PROJECT_NAME}_nodelet ${catkin_LIBRARIES} gtest_main) +target_link_libraries( + test_amcl_nodelet + ${PROJECT_NAME}_nodelet + ${catkin_LIBRARIES} + gtest_main) -catkin_add_gmock(test_amcl_node_resampling_policies - filter_update_control/test_filter_update_control_mixin.cpp - filter_update_control/test_resample_interval_policy.cpp - filter_update_control/test_selective_resampling_policy.cpp - filter_update_control/test_update_filter_when_moving_policy.cpp -) -target_compile_options(test_amcl_node_resampling_policies PRIVATE -Wno-gnu-zero-variadic-macro-arguments) -target_link_libraries(test_amcl_node_resampling_policies ${PROJECT_NAME}_nodelet ${catkin_LIBRARIES} gmock_main) +catkin_add_gmock( + test_amcl_node_resampling_policies + filter_update_control/test_filter_update_control_mixin.cpp + filter_update_control/test_resample_interval_policy.cpp + filter_update_control/test_selective_resampling_policy.cpp + filter_update_control/test_update_filter_when_moving_policy.cpp) +target_compile_options(test_amcl_node_resampling_policies + PRIVATE -Wno-gnu-zero-variadic-macro-arguments) +target_link_libraries( + test_amcl_node_resampling_policies + ${PROJECT_NAME}_nodelet + ${catkin_LIBRARIES} + gmock_main) diff --git a/beluga_benchmark/CMakeLists.txt b/beluga_benchmark/CMakeLists.txt index 9a6b1f088..25920cf18 100644 --- a/beluga_benchmark/CMakeLists.txt +++ b/beluga_benchmark/CMakeLists.txt @@ -1,3 +1,17 @@ +# Copyright 2023 Ekumen, Inc. +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + cmake_minimum_required(VERSION 3.16) project(beluga_benchmark) @@ -10,11 +24,8 @@ if(ROS_VERSION EQUAL 2) ament_python_install_package(${PROJECT_NAME}) - install(DIRECTORY - scripts/profiling - scripts/benchmarking - USE_SOURCE_PERMISSIONS - DESTINATION lib/${PROJECT_NAME}) + install(DIRECTORY scripts/profiling scripts/benchmarking + USE_SOURCE_PERMISSIONS DESTINATION lib/${PROJECT_NAME}) if(BUILD_TESTING) find_package(ament_lint_auto REQUIRED) diff --git a/beluga_example/CMakeLists.txt b/beluga_example/CMakeLists.txt index 90b46dbaa..4302adbac 100644 --- a/beluga_example/CMakeLists.txt +++ b/beluga_example/CMakeLists.txt @@ -1,3 +1,17 @@ +# Copyright 2023 Ekumen, Inc. +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + cmake_minimum_required(VERSION 3.16) project(beluga_example) diff --git a/beluga_example/cmake/ament.cmake b/beluga_example/cmake/ament.cmake index c5abeeed8..1b01d1325 100644 --- a/beluga_example/cmake/ament.cmake +++ b/beluga_example/cmake/ament.cmake @@ -16,27 +16,30 @@ find_package(ament_cmake REQUIRED) find_package(ament_cmake_python REQUIRED) find_package(beluga_amcl REQUIRED) -ament_python_install_package(${PROJECT_NAME} - PACKAGE_DIR ${PROJECT_SOURCE_DIR}/${PROJECT_NAME}) +ament_python_install_package(${PROJECT_NAME} PACKAGE_DIR + ${PROJECT_SOURCE_DIR}/${PROJECT_NAME}) -install(DIRECTORY bags +install( + DIRECTORY bags DESTINATION share/${PROJECT_NAME} PATTERN "*.bag" EXCLUDE) -install(DIRECTORY launch +install( + DIRECTORY launch DESTINATION share/${PROJECT_NAME} PATTERN "*.launch" EXCLUDE) -install(DIRECTORY rviz +install( + DIRECTORY rviz DESTINATION share/${PROJECT_NAME} PATTERN "*.ros2.rviz") -install(DIRECTORY params +install( + DIRECTORY params DESTINATION share/${PROJECT_NAME} PATTERN "*.ros2.yaml") -install(DIRECTORY maps models worlds - DESTINATION share/${PROJECT_NAME}) +install(DIRECTORY maps models worlds DESTINATION share/${PROJECT_NAME}) if(BUILD_TESTING) find_package(ament_lint_auto REQUIRED) diff --git a/beluga_example/cmake/catkin.cmake b/beluga_example/cmake/catkin.cmake index 3793914b2..e499db0bc 100644 --- a/beluga_example/cmake/catkin.cmake +++ b/beluga_example/cmake/catkin.cmake @@ -16,21 +16,24 @@ find_package(catkin REQUIRED) catkin_package() -install(DIRECTORY bags +install( + DIRECTORY bags DESTINATION ${CATKIN_PACKAGE_SHARE_DESTINATION} PATTERN "*.bag") -install(DIRECTORY launch +install( + DIRECTORY launch DESTINATION ${CATKIN_PACKAGE_SHARE_DESTINATION} PATTERN "*.launch") -install(DIRECTORY rviz +install( + DIRECTORY rviz DESTINATION ${CATKIN_PACKAGE_SHARE_DESTINATION} PATTERN "*.ros.rviz") -install(DIRECTORY params +install( + DIRECTORY params DESTINATION ${CATKIN_PACKAGE_SHARE_DESTINATION} PATTERN "*.ros.yaml") -install(DIRECTORY maps models worlds - DESTINATION share/${PROJECT_NAME}) +install(DIRECTORY maps models worlds DESTINATION share/${PROJECT_NAME}) diff --git a/beluga_example/package.xml b/beluga_example/package.xml index ed55c7f86..3890673d5 100644 --- a/beluga_example/package.xml +++ b/beluga_example/package.xml @@ -30,7 +30,6 @@ rviz2 teleop_twist_keyboard - ament_lint_common ament_lint_auto launch launch_testing diff --git a/beluga_system_tests/CMakeLists.txt b/beluga_system_tests/CMakeLists.txt index b74c0c72a..beadb0214 100644 --- a/beluga_system_tests/CMakeLists.txt +++ b/beluga_system_tests/CMakeLists.txt @@ -1,3 +1,17 @@ +# Copyright 2023 Ekumen, Inc. +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + cmake_minimum_required(VERSION 3.16) project(beluga_system_tests VERSION 1.0) @@ -9,11 +23,18 @@ if(ROS_VERSION EQUAL 2) if(NOT CMAKE_BUILD_TYPE) message(STATUS "Setting build type to 'Release' as none was specified.") - set(CMAKE_BUILD_TYPE "Release" CACHE STRING "Build type" FORCE) + set(CMAKE_BUILD_TYPE + "Release" + CACHE STRING "Build type" FORCE) endif() if(CMAKE_COMPILER_IS_GNUCXX OR CMAKE_CXX_COMPILER_ID MATCHES "Clang") - add_compile_options(-Wall -Wconversion -Werror -Wextra -Wpedantic) + add_compile_options( + -Wall + -Wconversion + -Werror + -Wextra + -Wpedantic) endif() option(BUILD_TESTING "Build the testing tree." ON) diff --git a/beluga_system_tests/test/CMakeLists.txt b/beluga_system_tests/test/CMakeLists.txt index 17ee6604a..5104c5c21 100644 --- a/beluga_system_tests/test/CMakeLists.txt +++ b/beluga_system_tests/test/CMakeLists.txt @@ -1,3 +1,17 @@ +# Copyright 2023 Ekumen, Inc. +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + find_package(rosbag2_cpp REQUIRED) find_package(beluga REQUIRED) find_package(beluga_amcl REQUIRED) @@ -6,13 +20,12 @@ find_package(nav_msgs REQUIRED) add_executable(test_system test_system.cpp) -target_link_libraries(test_system - PUBLIC - beluga::beluga - beluga_amcl::amcl_node_utils - GTest::gtest_main - rosbag2_cpp::rosbag2_cpp -) +target_link_libraries( + test_system + PUBLIC beluga::beluga + beluga_amcl::amcl_node_utils + GTest::gtest_main + rosbag2_cpp::rosbag2_cpp) include(GoogleTest) gtest_discover_tests(test_system WORKING_DIRECTORY ${CMAKE_CURRENT_LIST_DIR})