ros2 / rcl_logging

Logging implementations for ROS 2.
Apache License 2.0
20 stars 36 forks source link

Missing ament_export_dependencies for spdlog for static ros2 builds #82

Closed hannes09 closed 2 years ago

hannes09 commented 3 years ago

I tried to compile a static ROS2 stack with the folling options:

colcon build --packages-ignore rclcpp_components --symlink-install --cmake-args -DBUILD_TESTING=OFF -DBUILD_SHARED_LIBS=OFF -DENABLE_SECURITY=OFF -DENABLE_SSL=NO -DCMAKE_POSITION_INDEPENDENT_CODE=ON -DFORCE_BUILD_VENDOR_PKG=ON -DSPDLOG_BUILD_SHARED=OFF

Multipel packages can not be build because rcl_logging_spdlog is not exporting spdlog as a dependency. I belive PR 60 has broken static builds.

Adding ament_target_dependencies(${PROJECT_NAME} rcl_logging_interface rcpputils rcutils spdlog )

for static builds should solve the problems.

sloretz commented 2 years ago

I was able to reproduce with

colcon build --packages-ignore rclcpp_components --symlink-install --cmake-args -DBUILD_TESTING=OFF -DBUILD_SHARED_LIBS=OFF -DENABLE_SECURITY=OFF -DENABLE_SSL=NO -DCMAKE_POSITION_INDEPENDENT_CODE=ON -DFORCE_BUILD_VENDOR_PKG=ON -DSPDLOG_BUILD_SHARED=OFF --packages-ignore-regex .*connext.* .*fastcdr.* .*fastrtps.* .*foonathan.* --packages-up-to-regex rclcpp.*
Starting >>> rcl
--- stderr: rcl                              
CMake Error at CMakeLists.txt:69 (add_library):
  Target "rcl" links to target "CycloneDDS::ddsc" but the target was not
  found.  Perhaps a find_package() call is missing for an IMPORTED target, or
  an ALIAS target is missing?

CMake Error at CMakeLists.txt:69 (add_library):
  Target "rcl" links to target "iceoryx_binding_c::iceoryx_binding_c" but the
  target was not found.  Perhaps a find_package() call is missing for an
  IMPORTED target, or an ALIAS target is missing?

CMake Error at CMakeLists.txt:69 (add_library):
  Target "rcl" links to target "spdlog::spdlog" but the target was not found.
  Perhaps a find_package() call is missing for an IMPORTED target, or an
  ALIAS target is missing?

CMake Generate step failed.  Build files cannot be regenerated correctly.

Reading https://cmake.org/pipermail/cmake/2016-May/063400.html I learned CMake links PRIVATE dependencies in downstream targets as if they were PUBLIC when building a static library.

Calling ament_export_dependencies(...) should fix it. Was ament_target_dependencies in the issue description a typo?