diff --git a/beluga_vdb/CMakeLists.txt b/beluga_vdb/CMakeLists.txt index 518fcddd5..c305ddf67 100644 --- a/beluga_vdb/CMakeLists.txt +++ b/beluga_vdb/CMakeLists.txt @@ -22,7 +22,6 @@ set(OPENVDB_CMAKE_MODULE_PATH ${OPENVDB_CMAKE_MODULE_PATH} CACHE PATH "Path to OpenVDB CMake module") -add_library(${PROJECT_NAME} INTERFACE) if(NOT CMAKE_BUILD_TYPE) message(STATUS "Setting build type to 'Release' as none was specified.") set(CMAKE_BUILD_TYPE @@ -30,23 +29,11 @@ if(NOT CMAKE_BUILD_TYPE) 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) -endif() -if(CMAKE_BUILD_TYPE MATCHES "Debug") - target_compile_options(${PROJECT_NAME} INTERFACE -fno-inline) -endif() +find_package(beluga REQUIRED) find_package(Eigen3 REQUIRED NO_MODULE) find_package(range-v3 REQUIRED) find_package(Sophus REQUIRED) -find_package(TBB REQUIRED) -find_package(beluga REQUIRED) if(NOT OPENVDB_CMAKE_MODULE_PATH) file( @@ -78,12 +65,42 @@ if(OPENVDB_CMAKE_MODULE_PATH) list(POP_BACK CMAKE_MODULE_PATH) endif() +add_library(${PROJECT_NAME} INTERFACE) + +if(CMAKE_COMPILER_IS_GNUCXX OR CMAKE_CXX_COMPILER_ID MATCHES "Clang") + target_compile_options( + ${PROJECT_NAME} + INTERFACE -Wall + -Wconversion + -Wextra + -Werror + -Wpedantic) +endif() +if(CMAKE_BUILD_TYPE MATCHES "Debug") + target_compile_options(${PROJECT_NAME} INTERFACE -fno-inline) +endif() + target_include_directories( ${PROJECT_NAME} INTERFACE $ $) target_link_libraries(${PROJECT_NAME} INTERFACE beluga::beluga OpenVDB::openvdb) target_compile_features(${PROJECT_NAME} INTERFACE cxx_std_17) +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}) + +option(BUILD_TESTING "Build the testing tree." ON) +if(BUILD_TESTING) + message(STATUS "Build testing enabled.") + enable_testing() + add_subdirectory(test) +endif() + +install(DIRECTORY include/ DESTINATION include/${PROJECT_NAME}) install( TARGETS ${PROJECT_NAME} @@ -92,11 +109,23 @@ install( LIBRARY DESTINATION lib RUNTIME DESTINATION bin) -install(DIRECTORY include/ DESTINATION include/${PROJECT_NAME}) +set(INSTALL_CMAKEDIR ${CMAKE_INSTALL_PREFIX}/share/${PROJECT_NAME}/cmake) -option(BUILD_TESTING "Build the testing tree." ON) -if(BUILD_TESTING) - message(STATUS "Build testing enabled.") - enable_testing() - add_subdirectory(test) -endif() +install( + EXPORT ${PROJECT_NAME}Targets + FILE ${PROJECT_NAME}Targets.cmake + NAMESPACE ${PROJECT_NAME}:: + 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}) +write_basic_package_version_file( + ${CMAKE_CURRENT_BINARY_DIR}/${PROJECT_NAME}ConfigVersion.cmake + COMPATIBILITY SameMajorVersion) + +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_vdb/cmake/Config.cmake.in b/beluga_vdb/cmake/Config.cmake.in new file mode 100644 index 000000000..eddfa6d28 --- /dev/null +++ b/beluga_vdb/cmake/Config.cmake.in @@ -0,0 +1,42 @@ +@PACKAGE_INIT@ + +include(CMakeFindDependencyMacro) +find_dependency(Eigen3 REQUIRED NO_MODULE) +find_dependency(range-v3 REQUIRED) +find_dependency(Sophus REQUIRED) +find_dependency(beluga REQUIRED) + +set(OPENVDB_CMAKE_MODULE_PATH + ${OPENVDB_CMAKE_MODULE_PATH} + CACHE PATH "Path to OpenVDB CMake module") + +if(NOT OPENVDB_CMAKE_MODULE_PATH) + file( + GLOB_RECURSE + OPENVDB_MODULES + /usr/lib/*/FindOpenVDB.cmake + /usr/local/lib/*/FindOpenVDB.cmake) + list(LENGTH OPENVDB_MODULES NUM_OPENVDB_MODULES) + if(NUM_OPENVDB_MODULES EQUAL 1) + list(GET OPENVDB_MODULES 0 OPENVDB_MODULE) + get_filename_component(OPENVDB_CMAKE_MODULE_PATH ${OPENVDB_MODULE} DIRECTORY) + endif() + unset(NUM_OPENVDB_MODULES) + unset(OPENVDB_MODULES) +endif() + +if(OPENVDB_CMAKE_MODULE_PATH) + list(APPEND CMAKE_MODULE_PATH ${OPENVDB_CMAKE_MODULE_PATH}) +endif() + +find_dependency(OpenVDB REQUIRED) + +if(OPENVDB_CMAKE_MODULE_PATH) + list(POP_BACK CMAKE_MODULE_PATH) +endif() + +include("${CMAKE_CURRENT_LIST_DIR}/@PROJECT_NAME@Targets.cmake") + +set(@PROJECT_NAME@_LIBRARIES @PROJECT_NAME@::@PROJECT_NAME@) + +check_required_components($@PROJECT_NAME@) diff --git a/beluga_vdb/src/clang_tidy_findable.cpp b/beluga_vdb/src/clang_tidy_findable.cpp new file mode 100644 index 000000000..607e856e6 --- /dev/null +++ b/beluga_vdb/src/clang_tidy_findable.cpp @@ -0,0 +1,27 @@ +// Copyright 2022-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. + +/* + * This file exists in this header-only library as a workaround for + * clang-tidy to find and process the headers, since all the source files + * inside the test folder are ignored. + * It will not be exported or installed with the rest of the targets of this + * library. + */ + +#include + +int main() { + return 0; +} diff --git a/beluga_vdb/test/beluga_vdb/sensor/test_likelihood_3d_field_model.cpp b/beluga_vdb/test/beluga_vdb/sensor/test_likelihood_3d_field_model.cpp index ba3deb762..3abd678df 100644 --- a/beluga_vdb/test/beluga_vdb/sensor/test_likelihood_3d_field_model.cpp +++ b/beluga_vdb/test/beluga_vdb/sensor/test_likelihood_3d_field_model.cpp @@ -56,7 +56,7 @@ auto make_map(const double voxel_size, const std::vector& world_points) { } // Check grid - openvdb::tools::CheckLevelSet checker(*grid); + const openvdb::tools::CheckLevelSet checker(*grid); // Check inactive values have a magnitude equal to the background value assert(checker.checkInactiveValues() == ""); diff --git a/tools/run-clang-tidy.sh b/tools/run-clang-tidy.sh index fca7b6e3f..60ea94a08 100755 --- a/tools/run-clang-tidy.sh +++ b/tools/run-clang-tidy.sh @@ -26,7 +26,7 @@ COLCON_EXTRA_ARGS="" if [ "${ROS_DISTRO}" != "noetic" ]; then ROS_PACKAGES="beluga beluga_ros beluga_amcl beluga_system_tests" if [ "${ROS_DISTRO}" != "humble" ] && [ "${ROS_DISTRO}" != "iron" ]; then - ROS_PACKAGES="beluga beluga_ros beluga_amcl beluga_system_tests beluga_tools beluga_vdb" + ROS_PACKAGES="beluga beluga_ros beluga_amcl beluga_system_tests beluga_vdb" fi else ROS_PACKAGES="beluga beluga_ros beluga_amcl"