Skip to content

Commit

Permalink
Convert plain cupoch targets to namespaced targets
Browse files Browse the repository at this point in the history
This catches any undefined targets immediately during the configuration step.
  • Loading branch information
valgur committed May 22, 2023
1 parent 3bf03ed commit 0f38658
Show file tree
Hide file tree
Showing 20 changed files with 96 additions and 74 deletions.
1 change: 1 addition & 0 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down
20 changes: 11 additions & 9 deletions examples/cpp/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -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)
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)
5 changes: 3 additions & 2 deletions src/cupoch/camera/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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
)
7 changes: 4 additions & 3 deletions src/cupoch/collision/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
9 changes: 5 additions & 4 deletions src/cupoch/geometry/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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
)
5 changes: 3 additions & 2 deletions src/cupoch/imageproc/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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
)
9 changes: 5 additions & 4 deletions src/cupoch/integration/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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
)
7 changes: 4 additions & 3 deletions src/cupoch/io/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
7 changes: 4 additions & 3 deletions src/cupoch/kinematics/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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
)
9 changes: 5 additions & 4 deletions src/cupoch/kinfu/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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
)
5 changes: 3 additions & 2 deletions src/cupoch/knn/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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
)
7 changes: 4 additions & 3 deletions src/cupoch/odometry/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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
)
7 changes: 4 additions & 3 deletions src/cupoch/planning/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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
)
9 changes: 5 additions & 4 deletions src/cupoch/registration/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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
)
3 changes: 2 additions & 1 deletion src/cupoch/utility/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
9 changes: 5 additions & 4 deletions src/cupoch/visualization/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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
)
15 changes: 8 additions & 7 deletions src/python/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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}
Expand All @@ -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})
Expand Down
32 changes: 18 additions & 14 deletions src/tests/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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")
Expand Down
2 changes: 1 addition & 1 deletion third_party/flann_cuda-config.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -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 $<BUILD_INTERFACE:${flann_cuda_SOURCE_DIR}>)
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}
Expand Down
2 changes: 1 addition & 1 deletion third_party/sgm-config.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ file(GLOB SGM_SRCS
add_library(sgm ${SGM_SRCS})
add_library(sgm::sgm ALIAS sgm)
target_include_directories(sgm PUBLIC $<BUILD_INTERFACE:${sgm_SOURCE_DIR}/include>)
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}
Expand Down

0 comments on commit 0f38658

Please sign in to comment.