diff --git a/CMakeLists.txt b/CMakeLists.txt index d930b97..debd7aa 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -184,6 +184,11 @@ ament_export_dependencies( ament_export_targets(export_${PROJECT_NAME} HAS_LIBRARY_TARGET) if(BUILD_TESTING) + add_test(NAME test_public_headers + COMMAND ${CMAKE_COMMAND} -DSOURCE_DIR=${CMAKE_CURRENT_SOURCE_DIR} + -P ${CMAKE_CURRENT_SOURCE_DIR}/tests/check_public_headers.cmake + ) + find_package(ament_cmake_gtest REQUIRED) ament_add_gtest(test_torque_rate_saturation diff --git a/include/crisp_controllers/utils/friction_model.hpp b/include/crisp_controllers/utils/friction_model.hpp index 20635a8..e5cf0b7 100644 --- a/include/crisp_controllers/utils/friction_model.hpp +++ b/include/crisp_controllers/utils/friction_model.hpp @@ -2,8 +2,6 @@ // Based in // https://github.com/marcocognetti/FrankaEmikaPandaDynModel/tree/master -#include -#include #include inline Eigen::VectorXd get_friction( diff --git a/src/cartesian_admittance_controller.cpp b/src/cartesian_admittance_controller.cpp index e58013d..ec43f28 100644 --- a/src/cartesian_admittance_controller.cpp +++ b/src/cartesian_admittance_controller.cpp @@ -3,7 +3,7 @@ #include #include -#include // NOLINT(build/include_order) +#include #include #include #include diff --git a/src/cartesian_controller.cpp b/src/cartesian_controller.cpp index f1d8bd8..f014aa3 100644 --- a/src/cartesian_controller.cpp +++ b/src/cartesian_controller.cpp @@ -3,7 +3,7 @@ #include #include -#include // NOLINT(build/include_order) +#include #include #include #include diff --git a/src/pose_broadcaster.cpp b/src/pose_broadcaster.cpp index e0101ed..2bebb19 100644 --- a/src/pose_broadcaster.cpp +++ b/src/pose_broadcaster.cpp @@ -1,9 +1,8 @@ -#include #include #include #include -#include // NOLINT(build/include_order) +#include #include #include "crisp_controllers/utils/ros2_version.hpp" diff --git a/src/twist_broadcaster.cpp b/src/twist_broadcaster.cpp index 358758e..46fc1ff 100644 --- a/src/twist_broadcaster.cpp +++ b/src/twist_broadcaster.cpp @@ -1,9 +1,8 @@ -#include #include #include #include -#include // NOLINT(build/include_order) +#include #include #include "crisp_controllers/utils/ros2_version.hpp" diff --git a/tests/check_public_headers.cmake b/tests/check_public_headers.cmake new file mode 100644 index 0000000..9091826 --- /dev/null +++ b/tests/check_public_headers.cmake @@ -0,0 +1,14 @@ +# Production headers must not depend on Eigen or libstdc++ implementation headers. +file(GLOB_RECURSE production_sources + "${SOURCE_DIR}/src/*.cpp" + "${SOURCE_DIR}/include/*.hpp" + "${SOURCE_DIR}/include/*.h" +) +foreach(source IN LISTS production_sources) + file(STRINGS "${source}" includes REGEX "^[ \t]*#[ \t]*include") + foreach(include IN LISTS includes) + if(include MATCHES "[<\"](Eigen/src/|binders[.]h[>\"]|backward/|bits/)") + message(FATAL_ERROR "Private implementation header in ${source}: ${include}") + endif() + endforeach() +endforeach()