From c65a0df4654155c61efe4c58c32ddd87454a4ba3 Mon Sep 17 00:00:00 2001 From: Alireza Moayyedi Date: Thu, 12 Feb 2026 19:19:37 +0100 Subject: [PATCH] Fixed cmake issues and added some improvements --- cloudini_lib/CMakeLists.txt | 36 ++++++++------------------------ cloudini_lib/package.xml | 5 +++-- cloudini_lib/test/CMakeLists.txt | 2 +- cloudini_ros/CMakeLists.txt | 28 +++++++++++++++---------- 4 files changed, 30 insertions(+), 41 deletions(-) diff --git a/cloudini_lib/CMakeLists.txt b/cloudini_lib/CMakeLists.txt index 0b56f70..d750314 100644 --- a/cloudini_lib/CMakeLists.txt +++ b/cloudini_lib/CMakeLists.txt @@ -50,21 +50,14 @@ target_include_directories(data_path INTERFACE ${CMAKE_BINARY_DIR}/include) ################################################################################## -if(ament_cmake_FOUND) - message(STATUS "PCL found using ament_cmake") - find_package(pcl_ros REQUIRED) - set(PCL_SRC src/pcl_conversion.cpp) +find_package(PCL COMPONENTS common io QUIET) +if(PCL_FOUND) + message(STATUS "PCL found in system") + add_definitions(${PCL_DEFINITIONS}) + set(PCL_SRC src/pcl_conversion.cpp) else() - find_package(PCL QUIET) - if(PCL_FOUND) - message(STATUS "PCL found in system") - add_definitions(${PCL_DEFINITIONS}) - link_directories(${PCL_LIBRARY_DIRS}) - set(PCL_SRC src/pcl_conversion.cpp) - else() - message(STATUS "PCL NOT found") - endif() + message(STATUS "PCL NOT found") endif() ################################################################################## @@ -112,22 +105,13 @@ target_include_directories(cloudini_lib $ ) -if(ament_cmake_FOUND) - find_package(pcl_ros REQUIRED) - target_link_libraries(cloudini_lib PUBLIC ${pcl_ros_TARGETS}) -else() - if(PCL_FOUND) - target_include_directories(cloudini_lib PUBLIC ${PCL_INCLUDE_DIRS}) - target_link_libraries(cloudini_lib PUBLIC ${PCL_LIBRARIES}) - endif() -endif() - target_link_libraries(cloudini_lib PRIVATE $ $ PUBLIC - ${PCL_LIBRARIES} + ${PCL_COMMON_LIBRARIES} + ${PCL_IO_LIBRARIES} ) if(NOT EMSCRIPTEN) @@ -211,8 +195,6 @@ INSTALL( DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}/include/ if(ament_cmake_FOUND) ament_export_targets(cloudini_libTargets HAS_LIBRARY_TARGET) - ament_export_libraries(cloudini_lib) - ament_export_dependencies(pcl_ros) - ament_export_include_directories(include) + ament_export_dependencies(PCL) ament_package() endif() diff --git a/cloudini_lib/package.xml b/cloudini_lib/package.xml index 8bb95f3..0eb71ce 100644 --- a/cloudini_lib/package.xml +++ b/cloudini_lib/package.xml @@ -14,10 +14,11 @@ ament_cmake - lz4 + libpcl-common + libpcl-io libzstd-dev + lz4 mcap_vendor - pcl_ros ament_cmake_gtest diff --git a/cloudini_lib/test/CMakeLists.txt b/cloudini_lib/test/CMakeLists.txt index f8253ac..5420643 100644 --- a/cloudini_lib/test/CMakeLists.txt +++ b/cloudini_lib/test/CMakeLists.txt @@ -32,7 +32,7 @@ else() GTest::gtest_main) if(PCL_FOUND) - target_link_libraries(test_cloudini ${PCL_LIBRARIES} ) + target_link_libraries(test_cloudini ${PCL_COMMON_LIBRARIES} ${PCL_IO_LIBRARIES}) endif() endif() diff --git a/cloudini_ros/CMakeLists.txt b/cloudini_ros/CMakeLists.txt index 6ab2a94..afa7b30 100644 --- a/cloudini_ros/CMakeLists.txt +++ b/cloudini_ros/CMakeLists.txt @@ -12,8 +12,8 @@ find_package(pluginlib REQUIRED) find_package(point_cloud_interfaces REQUIRED) find_package(point_cloud_transport REQUIRED) find_package(Draco QUIET) +find_package(PCL COMPONENTS common REQUIRED) find_package(pcl_conversions REQUIRED) -find_package(pcl_ros REQUIRED) set(PLUGIN_DEPS pluginlib::pluginlib @@ -36,16 +36,16 @@ target_include_directories(cloudini_ros PUBLIC $ $ - ${PCL_INCLUDE_DIRS} ) target_link_libraries(cloudini_ros PUBLIC ${PLUGIN_DEPS} - ${PCL_LIBRARIES} + ${PCL_COMMON_LIBRARIES} ) install(TARGETS cloudini_ros + EXPORT export_${PROJECT_NAME} ARCHIVE DESTINATION lib LIBRARY DESTINATION lib RUNTIME DESTINATION lib/cloudini_ros @@ -104,7 +104,7 @@ add_executable(test_cloudini_subscriber test/test_cloudini_subscriber.cpp) target_link_libraries(test_cloudini_subscriber cloudini_ros - ${PCL_LIBRARIES} + ${PCL_COMMON_LIBRARIES} ) target_include_directories(test_cloudini_subscriber @@ -123,15 +123,13 @@ add_executable(test_plugin_subscriber test/test_plugin_subscriber.cpp) target_link_libraries(test_plugin_subscriber cloudini_ros - ${PCL_LIBRARIES} + ${PCL_COMMON_LIBRARIES} ${point_cloud_interfaces_TARGETS} - ${pcl_conversions_TARGETS} point_cloud_transport::point_cloud_transport ) target_include_directories(test_plugin_subscriber PRIVATE - ${PCL_INCLUDE_DIRS} ${pcl_conversions_INCLUDE_DIRS} ) @@ -178,6 +176,7 @@ target_include_directories(${PLUGIN_NAME} PRIVATE ) install(TARGETS ${PLUGIN_NAME} + EXPORT export_${PROJECT_NAME} ARCHIVE DESTINATION lib LIBRARY DESTINATION lib RUNTIME DESTINATION lib/${PLUGIN_NAME} @@ -188,10 +187,17 @@ install( DESTINATION include/${PLUGIN_NAME} ) - pluginlib_export_plugin_description_file(point_cloud_transport cloudini_plugins.xml) -ament_export_include_directories(include) -ament_export_libraries(cloudini_ros ${PLUGIN_NAME}) -ament_export_dependencies(${PLUGIN_DEPS}) +ament_export_targets(export_${PROJECT_NAME} HAS_LIBRARY_TARGET) +ament_export_dependencies( + pluginlib + rosbag2_cpp + point_cloud_transport + rclcpp + cloudini_lib + sensor_msgs + point_cloud_interfaces + PCL +) ament_package()