From 0f38658d483f3306bb0bc1b7785200de92616f7d Mon Sep 17 00:00:00 2001 From: Martin Valgur Date: Fri, 12 May 2023 18:14:06 +0300 Subject: [PATCH] Convert plain cupoch targets to namespaced targets This catches any undefined targets immediately during the configuration step. --- CMakeLists.txt | 1 + examples/cpp/CMakeLists.txt | 20 +++++++++------- src/cupoch/camera/CMakeLists.txt | 5 ++-- src/cupoch/collision/CMakeLists.txt | 7 +++--- src/cupoch/geometry/CMakeLists.txt | 9 +++---- src/cupoch/imageproc/CMakeLists.txt | 5 ++-- src/cupoch/integration/CMakeLists.txt | 9 +++---- src/cupoch/io/CMakeLists.txt | 7 +++--- src/cupoch/kinematics/CMakeLists.txt | 7 +++--- src/cupoch/kinfu/CMakeLists.txt | 9 +++---- src/cupoch/knn/CMakeLists.txt | 5 ++-- src/cupoch/odometry/CMakeLists.txt | 7 +++--- src/cupoch/planning/CMakeLists.txt | 7 +++--- src/cupoch/registration/CMakeLists.txt | 9 +++---- src/cupoch/utility/CMakeLists.txt | 3 ++- src/cupoch/visualization/CMakeLists.txt | 9 +++---- src/python/CMakeLists.txt | 15 ++++++------ src/tests/CMakeLists.txt | 32 ++++++++++++++----------- third_party/flann_cuda-config.cmake | 2 +- third_party/sgm-config.cmake | 2 +- 20 files changed, 96 insertions(+), 74 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index c3ea4a78..bcd0ef6d 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -157,6 +157,7 @@ find_package(thrust REQUIRED CONFIG) find_package(stdgpu REQUIRED CONFIG) find_package(CUDAToolkit REQUIRED) add_library(cupoch_flags INTERFACE) +add_library(cupoch::flags ALIAS cupoch_flags) if(NOT DEFINED CMAKE_CUDA_ARCHITECTURES) # Generate for 10xx+ series GPUs by default. # Newer but not listed GPUs will JIT compile on launch. diff --git a/examples/cpp/CMakeLists.txt b/examples/cpp/CMakeLists.txt index 1403b315..047d1a7a 100644 --- a/examples/cpp/CMakeLists.txt +++ b/examples/cpp/CMakeLists.txt @@ -1,20 +1,22 @@ macro(EXAMPLE_CPP EXAMPLE_CPP_NAME) + set(DEPS) foreach(module ${ARGN}) - if(NOT BUILD_${module}) - message(STATUS "Skipping example ${EXAMPLE_CPP_NAME} because ${module} is not enabled") + if(NOT BUILD_cupoch_${module}) + message(STATUS "Skipping example ${EXAMPLE_CPP_NAME} because cupoch_${module} is not enabled") return() endif() + list(APPEND DEPS cupoch::${module}) endforeach() add_executable(${EXAMPLE_CPP_NAME} "${EXAMPLE_CPP_NAME}.cpp") - target_link_libraries(${EXAMPLE_CPP_NAME} PRIVATE ${ARGN}) + target_link_libraries(${EXAMPLE_CPP_NAME} PRIVATE ${DEPS}) set_target_properties(${EXAMPLE_CPP_NAME} PROPERTIES FOLDER "examples/cpp/" RUNTIME_OUTPUT_DIRECTORY "${CMAKE_RUNTIME_OUTPUT_DIRECTORY}/examples") endmacro(EXAMPLE_CPP) -EXAMPLE_CPP(image cupoch_visualization cupoch_geometry cupoch_io) -EXAMPLE_CPP(pointcloud cupoch_visualization cupoch_geometry cupoch_io) -EXAMPLE_CPP(trianglemesh cupoch_visualization cupoch_geometry cupoch_io) -EXAMPLE_CPP(registration cupoch_visualization cupoch_registration cupoch_io) -EXAMPLE_CPP(voxelization cupoch_visualization cupoch_geometry cupoch_io) -EXAMPLE_CPP(kinematics cupoch_visualization cupoch_kinematics cupoch_io) \ No newline at end of file +EXAMPLE_CPP(image visualization geometry io) +EXAMPLE_CPP(pointcloud visualization geometry io) +EXAMPLE_CPP(trianglemesh visualization geometry io) +EXAMPLE_CPP(registration visualization registration io) +EXAMPLE_CPP(voxelization visualization geometry io) +EXAMPLE_CPP(kinematics visualization kinematics io) \ No newline at end of file diff --git a/src/cupoch/camera/CMakeLists.txt b/src/cupoch/camera/CMakeLists.txt index 7496187c..008d2138 100644 --- a/src/cupoch/camera/CMakeLists.txt +++ b/src/cupoch/camera/CMakeLists.txt @@ -5,10 +5,11 @@ set(CUPOCH_MODULES ${CUPOCH_MODULES} cupoch_camera PARENT_SCOPE) file(GLOB_RECURSE CAMERA_SOURCE_FILES "*.cpp") add_library(cupoch_camera ${CAMERA_SOURCE_FILES}) +add_library(cupoch::camera ALIAS cupoch_camera) target_link_libraries(cupoch_camera PUBLIC - cupoch_utility + cupoch::utility Eigen3::Eigen PRIVATE - cupoch_flags + cupoch::flags ) diff --git a/src/cupoch/collision/CMakeLists.txt b/src/cupoch/collision/CMakeLists.txt index 545abd52..577d9057 100644 --- a/src/cupoch/collision/CMakeLists.txt +++ b/src/cupoch/collision/CMakeLists.txt @@ -9,13 +9,14 @@ find_package(tritriintersect REQUIRED CONFIG) file(GLOB_RECURSE COLLISION_SOURCE_FILES "*.cu") add_library(cupoch_collision ${COLLISION_SOURCE_FILES}) +add_library(cupoch::collision ALIAS cupoch_collision) target_link_libraries(cupoch_collision PUBLIC - cupoch_geometry + cupoch::geometry Eigen3::Eigen PRIVATE - cupoch_flags - cupoch_utility + cupoch::flags + cupoch::utility lbvh::lbvh lbvh::lbvh_index stdgpu::stdgpu diff --git a/src/cupoch/geometry/CMakeLists.txt b/src/cupoch/geometry/CMakeLists.txt index 324651ac..e75a5328 100644 --- a/src/cupoch/geometry/CMakeLists.txt +++ b/src/cupoch/geometry/CMakeLists.txt @@ -8,14 +8,15 @@ find_package(tritriintersect REQUIRED CONFIG) file(GLOB_RECURSE GEOMETRY_SOURCE_FILES "*.cu") add_library(cupoch_geometry ${GEOMETRY_SOURCE_FILES}) +add_library(cupoch::geometry ALIAS cupoch_geometry) target_link_libraries(cupoch_geometry PUBLIC - cupoch_utility - cupoch_camera - cupoch_knn + cupoch::utility + cupoch::camera + cupoch::knn Eigen3::Eigen tritriintersect::tritriintersect PRIVATE - cupoch_flags + cupoch::flags stdgpu::stdgpu ) diff --git a/src/cupoch/imageproc/CMakeLists.txt b/src/cupoch/imageproc/CMakeLists.txt index e13544f7..e190e5c7 100644 --- a/src/cupoch/imageproc/CMakeLists.txt +++ b/src/cupoch/imageproc/CMakeLists.txt @@ -7,10 +7,11 @@ find_package(sgm REQUIRED CONFIG) file(GLOB_RECURSE IMAGEPROC_SOURCE_FILES "*.cpp") add_library(cupoch_imageproc ${IMAGEPROC_SOURCE_FILES}) +add_library(cupoch::imageproc ALIAS cupoch_imageproc) target_link_libraries(cupoch_imageproc PUBLIC - cupoch_geometry + cupoch::geometry sgm::sgm PRIVATE - cupoch_utility + cupoch::utility ) diff --git a/src/cupoch/integration/CMakeLists.txt b/src/cupoch/integration/CMakeLists.txt index 44467b14..2c5fecd6 100644 --- a/src/cupoch/integration/CMakeLists.txt +++ b/src/cupoch/integration/CMakeLists.txt @@ -10,12 +10,13 @@ file(GLOB_RECURSE ALL_CUDA_SOURCE_FILES "*.cu") # create object library add_library(cupoch_integration ${ALL_CUDA_SOURCE_FILES}) +add_library(cupoch::integration ALIAS cupoch_integration) target_link_libraries(cupoch_integration PUBLIC - cupoch_camera - cupoch_geometry + cupoch::camera + cupoch::geometry PRIVATE - cupoch_flags - cupoch_utility + cupoch::flags + cupoch::utility stdgpu::stdgpu ) diff --git a/src/cupoch/io/CMakeLists.txt b/src/cupoch/io/CMakeLists.txt index a97152a2..910b3b82 100644 --- a/src/cupoch/io/CMakeLists.txt +++ b/src/cupoch/io/CMakeLists.txt @@ -15,13 +15,14 @@ set(IO_ALL_SOURCE_FILES ${IO_CPP_SOURCE_FILES} ${IO_CUDA_SOURCE_FILES}) # Create object library add_library(cupoch_io ${IO_ALL_SOURCE_FILES}) +add_library(cupoch::io ALIAS cupoch_io) target_link_libraries(cupoch_io PUBLIC - cupoch_geometry - cupoch_utility + cupoch::geometry + cupoch::utility Eigen3::Eigen PRIVATE - cupoch_flags + cupoch::flags liblzf::liblzf PNG::PNG rply::rply diff --git a/src/cupoch/kinematics/CMakeLists.txt b/src/cupoch/kinematics/CMakeLists.txt index 3ed7df76..5b9e5a25 100644 --- a/src/cupoch/kinematics/CMakeLists.txt +++ b/src/cupoch/kinematics/CMakeLists.txt @@ -9,10 +9,11 @@ file(GLOB_RECURSE KINEMATICS_SOURCE_FILES "*.cpp") # Create object library add_library(cupoch_kinematics ${KINEMATICS_SOURCE_FILES}) +add_library(cupoch::kinematics ALIAS cupoch_kinematics) target_link_libraries(cupoch_kinematics PUBLIC - cupoch_collision - cupoch_io - cupoch_utility + cupoch::collision + cupoch::io + cupoch::utility urdfdom::urdfdom ) diff --git a/src/cupoch/kinfu/CMakeLists.txt b/src/cupoch/kinfu/CMakeLists.txt index d8ea60b3..d481bed5 100644 --- a/src/cupoch/kinfu/CMakeLists.txt +++ b/src/cupoch/kinfu/CMakeLists.txt @@ -7,10 +7,11 @@ file(GLOB_RECURSE KINFU_SOURCE_FILES "*.cpp") # Create object library add_library(cupoch_kinfu ${KINFU_SOURCE_FILES}) +add_library(cupoch::kinfu ALIAS cupoch_kinfu) target_link_libraries(cupoch_kinfu PUBLIC - cupoch_camera - cupoch_geometry - cupoch_integration - cupoch_registration + cupoch::camera + cupoch::geometry + cupoch::integration + cupoch::registration ) diff --git a/src/cupoch/knn/CMakeLists.txt b/src/cupoch/knn/CMakeLists.txt index ab195a7b..0a3d3bbb 100644 --- a/src/cupoch/knn/CMakeLists.txt +++ b/src/cupoch/knn/CMakeLists.txt @@ -11,12 +11,13 @@ file(GLOB_RECURSE ALL_CUDA_SOURCE_FILES "*.cu") # create object library add_library(cupoch_knn ${ALL_CUDA_SOURCE_FILES}) +add_library(cupoch::knn ALIAS cupoch_knn) target_link_libraries(cupoch_knn PUBLIC - cupoch_utility + cupoch::utility Eigen3::Eigen lbvh::lbvh_index flann::flann_cuda_s PRIVATE - cupoch_flags + cupoch::flags ) \ No newline at end of file diff --git a/src/cupoch/odometry/CMakeLists.txt b/src/cupoch/odometry/CMakeLists.txt index 0628950f..6f32adca 100644 --- a/src/cupoch/odometry/CMakeLists.txt +++ b/src/cupoch/odometry/CMakeLists.txt @@ -8,11 +8,12 @@ file(GLOB_RECURSE ALL_CUDA_SOURCE_FILES "*.cu") # create object library add_library(cupoch_odometry ${ALL_CUDA_SOURCE_FILES}) +add_library(cupoch::odometry ALIAS cupoch_odometry) target_link_libraries(cupoch_odometry PUBLIC - cupoch_camera - cupoch_geometry - cupoch_utility + cupoch::camera + cupoch::geometry + cupoch::utility PRIVATE Eigen3::Eigen ) diff --git a/src/cupoch/planning/CMakeLists.txt b/src/cupoch/planning/CMakeLists.txt index db1abef2..d84c2338 100644 --- a/src/cupoch/planning/CMakeLists.txt +++ b/src/cupoch/planning/CMakeLists.txt @@ -5,10 +5,11 @@ set(CUPOCH_MODULES ${CUPOCH_MODULES} cupoch_planning PARENT_SCOPE) file(GLOB_RECURSE ALL_CUDA_SOURCE_FILES "*.cu") add_library(cupoch_planning ${ALL_CUDA_SOURCE_FILES}) +add_library(cupoch::planning ALIAS cupoch_planning) target_link_libraries(cupoch_planning PUBLIC - cupoch_geometry + cupoch::geometry PRIVATE - cupoch_collision - cupoch_utility + cupoch::collision + cupoch::utility ) diff --git a/src/cupoch/registration/CMakeLists.txt b/src/cupoch/registration/CMakeLists.txt index 7f959a88..2eaf3e89 100644 --- a/src/cupoch/registration/CMakeLists.txt +++ b/src/cupoch/registration/CMakeLists.txt @@ -7,12 +7,13 @@ find_package(stdgpu REQUIRED CONFIG) file(GLOB_RECURSE ALL_CUDA_SOURCE_FILES "*.cu") add_library(cupoch_registration ${ALL_CUDA_SOURCE_FILES}) +add_library(cupoch::registration ALIAS cupoch_registration) target_link_libraries(cupoch_registration PUBLIC - cupoch_knn - cupoch_utility + cupoch::knn + cupoch::utility stdgpu::stdgpu - cupoch_flags - cupoch_geometry + cupoch::flags + cupoch::geometry Eigen3::Eigen ) diff --git a/src/cupoch/utility/CMakeLists.txt b/src/cupoch/utility/CMakeLists.txt index 34b9b9c8..765fccd7 100644 --- a/src/cupoch/utility/CMakeLists.txt +++ b/src/cupoch/utility/CMakeLists.txt @@ -9,9 +9,10 @@ find_package(stdgpu REQUIRED CONFIG) file(GLOB_RECURSE ALL_CPP_SOURCE_FILES "*.cpp") file(GLOB_RECURSE ALL_CUDA_SOURCE_FILES "*.cu") add_library(cupoch_utility ${ALL_CUDA_SOURCE_FILES} ${ALL_CPP_SOURCE_FILES}) +add_library(cupoch::utility ALIAS cupoch_utility) target_link_libraries(cupoch_utility PUBLIC - cupoch_flags + cupoch::flags dlpack::dlpack Eigen3::Eigen JsonCpp::JsonCpp diff --git a/src/cupoch/visualization/CMakeLists.txt b/src/cupoch/visualization/CMakeLists.txt index 75bd818b..60ea0749 100644 --- a/src/cupoch/visualization/CMakeLists.txt +++ b/src/cupoch/visualization/CMakeLists.txt @@ -34,16 +34,17 @@ file(GLOB_RECURSE VISUALIZATION_CPP_SOURCE_FILES "*.cpp") file(GLOB_RECURSE VISUALIZATION_CUDA_SOURCE_FILES "*.cu") # create object library add_library(cupoch_visualization ${VISUALIZATION_CUDA_SOURCE_FILES} ${VISUALIZATION_CPP_SOURCE_FILES}) +add_library(cupoch::visualization ALIAS cupoch_visualization) add_dependencies(cupoch_visualization shader_file_target) target_link_libraries(cupoch_visualization PUBLIC - cupoch_camera - cupoch_geometry - cupoch_utility + cupoch::camera + cupoch::geometry + cupoch::utility Eigen3::Eigen GLEW::GLEW glfw PRIVATE - cupoch_io + cupoch::io imgui::imgui ) diff --git a/src/python/CMakeLists.txt b/src/python/CMakeLists.txt index 7875647c..8ba40799 100644 --- a/src/python/CMakeLists.txt +++ b/src/python/CMakeLists.txt @@ -11,10 +11,11 @@ target_link_libraries(${PACKAGE_NAME} PUBLIC pybind11::pybind11) add_library(cupoch_wrapper cupoch_pybind/device_vector_wrapper.cu cupoch_pybind/device_map_wrapper.cu) +add_library(cupoch::wrapper ALIAS cupoch_wrapper) target_include_directories(cupoch_wrapper PRIVATE ${CMAKE_CURRENT_SOURCE_DIR} ) -target_link_libraries(cupoch_wrapper PRIVATE cupoch_geometry) +target_link_libraries(cupoch_wrapper PRIVATE cupoch::geometry) target_include_directories(${PACKAGE_NAME} PRIVATE ${CMAKE_CURRENT_SOURCE_DIR} @@ -24,12 +25,12 @@ target_include_directories(${PACKAGE_NAME} SYSTEM PRIVATE ${PYBIND11_INCLUDE_DIR} ${PYTHON_INCLUDE_DIRS} ) -target_link_libraries(${PACKAGE_NAME} PRIVATE cupoch_registration - cupoch_visualization cupoch_io cupoch_odometry - cupoch_planning cupoch_kinematics cupoch_kinfu - cupoch_collision cupoch_integration - cupoch_imageproc cupoch_geometry - cupoch_utility cupoch_wrapper +target_link_libraries(${PACKAGE_NAME} PRIVATE cupoch::registration + cupoch::visualization cupoch::io cupoch::odometry + cupoch::planning cupoch::kinematics cupoch::kinfu + cupoch::collision cupoch::integration + cupoch::imageproc cupoch::geometry + cupoch::utility cupoch::wrapper CUDA::cudart) if (WIN32) target_link_libraries(${PACKAGE_NAME} PRIVATE ${PYTHON_LIBRARIES}) diff --git a/src/tests/CMakeLists.txt b/src/tests/CMakeLists.txt index 14b5b205..7d656982 100644 --- a/src/tests/CMakeLists.txt +++ b/src/tests/CMakeLists.txt @@ -5,24 +5,28 @@ find_package(GTest REQUIRED CONFIG) file(GLOB_RECURSE UNIT_TEST_SOURCES "test_utility/*.cpp") set(DEPENDENCIES cupoch_utility) -function(TEST module) - if(NOT BUILD_cupoch_${module}) - message(STATUS "Skipping unit tests for ${module} because ${module} is not enabled") - return() - endif() - file(GLOB_RECURSE TEST_SOURCES "${module}/*.cpp") +function(TEST TEST_NAME) + set(DEPS) + foreach(module ${TEST_NAME} ${ARGN}) + if(NOT BUILD_cupoch_${module}) + message(STATUS "Skipping example ${TEST_NAME} because cupoch_${module} is not enabled") + return() + endif() + list(APPEND DEPS cupoch::${module}) + endforeach() + file(GLOB_RECURSE TEST_SOURCES "${TEST_NAME}/*.cpp") set(UNIT_TEST_SOURCES ${UNIT_TEST_SOURCES} ${TEST_SOURCES} PARENT_SCOPE) - set(DEPENDENCIES ${DEPENDENCIES} cupoch_${module} PARENT_SCOPE) + set(DEPENDENCIES ${DEPENDENCIES} ${DEPS} PARENT_SCOPE) endfunction() -TEST(collision) -TEST(geometry) -TEST(integration) +TEST(collision geometry) +TEST(geometry camera) +TEST(integration io) TEST(io) -TEST(knn) -TEST(odometry) -TEST(planning) -TEST(registration) +TEST(knn geometry) +TEST(odometry geometry) +TEST(planning geometry) +TEST(registration geometry) add_executable(unittests ${UNIT_TEST_SOURCES}) add_definitions(-DTEST_DATA_DIR="${PROJECT_SOURCE_DIR}/examples/testdata") diff --git a/third_party/flann_cuda-config.cmake b/third_party/flann_cuda-config.cmake index 4d0a2b56..a3944249 100644 --- a/third_party/flann_cuda-config.cmake +++ b/third_party/flann_cuda-config.cmake @@ -9,7 +9,7 @@ add_library(flann_cuda_s STATIC ${CU_SOURCES}) add_library(flann::flann_cuda_s ALIAS flann_cuda_s) target_include_directories(flann_cuda_s PUBLIC $) target_compile_definitions(flann_cuda_s PUBLIC FLANN_USE_CUDA) -target_link_libraries(flann_cuda_s PRIVATE cupoch_flags CUDA::cudart spdlog::spdlog rmm::rmm) +target_link_libraries(flann_cuda_s PRIVATE cupoch::flags CUDA::cudart spdlog::spdlog rmm::rmm) install(TARGETS flann_cuda_s) install(DIRECTORY ${flann_cuda_SOURCE_DIR}/ DESTINATION ${CMAKE_INSTALL_INCLUDEDIR} diff --git a/third_party/sgm-config.cmake b/third_party/sgm-config.cmake index b1ac35bc..c37faa2f 100644 --- a/third_party/sgm-config.cmake +++ b/third_party/sgm-config.cmake @@ -18,7 +18,7 @@ file(GLOB SGM_SRCS add_library(sgm ${SGM_SRCS}) add_library(sgm::sgm ALIAS sgm) target_include_directories(sgm PUBLIC $) -target_link_libraries(sgm PRIVATE cupoch_flags CUDA::cudart thrust::thrust) +target_link_libraries(sgm PRIVATE cupoch::flags CUDA::cudart thrust::thrust) install(TARGETS sgm) install(DIRECTORY ${sgm_SOURCE_DIR}/include/ DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}