From aa4bfb639a5e8bfb115b4667b51ae981863a20c5 Mon Sep 17 00:00:00 2001 From: Shaokai Lin Date: Tue, 20 Jan 2026 11:15:11 -0800 Subject: [PATCH 01/13] Fix malformed package.xml for ROS2 colcon builds The package.xml had two root elements which is invalid XML. This caused colcon to fail to parse it, preventing ROS2 builds from finding the reactor-cpp package. Co-Authored-By: Claude Opus 4.5 --- package.xml | 10 ---------- 1 file changed, 10 deletions(-) diff --git a/package.xml b/package.xml index fdfe31c9..b1297ea5 100644 --- a/package.xml +++ b/package.xml @@ -10,13 +10,3 @@ cmake - - reactor-cpp-foo - 0.0.0 - A C++ reactor runtime - user - ISC License - - cmake - - From 0626031f4ea8b54369c0452bc7fd3de7028da69f Mon Sep 17 00:00:00 2001 From: Shaokai Lin Date: Tue, 20 Jan 2026 15:08:14 -0800 Subject: [PATCH 02/13] Add optional ament packaging Detect ament during ROS2 builds and export targets so reactor-cpp is discoverable by ament_target_dependencies. --- CMakeLists.txt | 13 +++++++++++++ package.xml | 3 ++- 2 files changed, 15 insertions(+), 1 deletion(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 92dfd42a..09c7d0dd 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -9,6 +9,13 @@ endif() project(${LIB_TARGET} LANGUAGES CXX VERSION 0.0.1) +if (NOT DEFINED LF_REACTOR_CPP_SUFFIX) + find_package(ament_cmake QUIET) + if(ament_cmake_FOUND) + set(REACTOR_CPP_USE_AMENT ON) + endif() +endif() + # require C++17 set(CMAKE_CXX_STANDARD 17) set(CMAKE_CXX_STANDARD_REQUIRED ON) @@ -71,3 +78,9 @@ if (DEFINED LF_REACTOR_CPP_SUFFIX) else() install(DIRECTORY include/ DESTINATION "${CMAKE_INSTALL_INCLUDEDIR}") endif() + +if (REACTOR_CPP_USE_AMENT) + ament_export_targets(${LIB_TARGET}Config HAS_LIBRARY_TARGET) + ament_export_include_directories(include) + ament_package() +endif() diff --git a/package.xml b/package.xml index b1297ea5..a42a7870 100644 --- a/package.xml +++ b/package.xml @@ -6,7 +6,8 @@ A C++ reactor runtime user ISC License + ament_cmake - cmake + ament_cmake From 9970f1ae7142e5ef34a08ea27819c24b8764fec3 Mon Sep 17 00:00:00 2001 From: Shaokai Lin Date: Tue, 20 Jan 2026 16:00:22 -0800 Subject: [PATCH 03/13] Fix ament export targets Use a standard target export name so ament generates reactor-cppConfig.cmake for downstream find_package calls. --- CMakeLists.txt | 2 +- lib/CMakeLists.txt | 6 ++---- 2 files changed, 3 insertions(+), 5 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 09c7d0dd..fc8da937 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -80,7 +80,7 @@ else() endif() if (REACTOR_CPP_USE_AMENT) - ament_export_targets(${LIB_TARGET}Config HAS_LIBRARY_TARGET) + ament_export_targets(${LIB_TARGET}Targets HAS_LIBRARY_TARGET) ament_export_include_directories(include) ament_package() endif() diff --git a/lib/CMakeLists.txt b/lib/CMakeLists.txt index 6f2ffd7d..0cdc114c 100644 --- a/lib/CMakeLists.txt +++ b/lib/CMakeLists.txt @@ -61,12 +61,10 @@ if(REACTOR_CPP_INSTALL) install(FILES "${PROJECT_BINARY_DIR}/include/reactor-cpp/config.hh" DESTINATION "${CMAKE_INSTALL_INCLUDEDIR}/reactor-cpp") endif() - install(TARGETS ${LIB_TARGET} EXPORT ${LIB_TARGET}Config + install(TARGETS ${LIB_TARGET} EXPORT ${LIB_TARGET}Targets ARCHIVE DESTINATION "${CMAKE_INSTALL_LIBDIR}" OPTIONAL LIBRARY DESTINATION "${CMAKE_INSTALL_LIBDIR}" OPTIONAL RUNTIME DESTINATION "${CMAKE_INSTALL_BINDIR}" OPTIONAL) - install(EXPORT ${LIB_TARGET}Config DESTINATION share/${LIB_TARGET}/cmake) - - export(TARGETS ${PROJECT_NAME} FILE ${LIB_TARGET}Config.cmake) + install(EXPORT ${LIB_TARGET}Targets DESTINATION share/${LIB_TARGET}/cmake) endif() From d283d946d8b8543c4822eb18ef754eba5095bba6 Mon Sep 17 00:00:00 2001 From: Shaokai Lin Date: Tue, 20 Jan 2026 23:26:55 -0800 Subject: [PATCH 04/13] Let ament handle export installation in ROS2 builds When using ament, ament_package() should handle installing the export files and generating the Config.cmake. The explicit install(EXPORT ...) was interfering with this, causing find_package(reactor-cpp) to fail in downstream packages. Co-Authored-By: Claude Opus 4.5 --- lib/CMakeLists.txt | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/lib/CMakeLists.txt b/lib/CMakeLists.txt index 0cdc114c..0eec842e 100644 --- a/lib/CMakeLists.txt +++ b/lib/CMakeLists.txt @@ -66,5 +66,9 @@ if(REACTOR_CPP_INSTALL) LIBRARY DESTINATION "${CMAKE_INSTALL_LIBDIR}" OPTIONAL RUNTIME DESTINATION "${CMAKE_INSTALL_BINDIR}" OPTIONAL) - install(EXPORT ${LIB_TARGET}Targets DESTINATION share/${LIB_TARGET}/cmake) + # Only install export file manually when not using ament. + # When using ament, ament_package() handles export installation. + if(NOT REACTOR_CPP_USE_AMENT) + install(EXPORT ${LIB_TARGET}Targets DESTINATION share/${LIB_TARGET}/cmake) + endif() endif() From 8c48841b2a1ee2267889feedf447dbd4f39792eb Mon Sep 17 00:00:00 2001 From: Shaokai Lin Date: Tue, 20 Jan 2026 23:42:24 -0800 Subject: [PATCH 05/13] Restore install(EXPORT) for ament compatibility The ament_package() generated Config.cmake includes the export targets file, so we need to install it. The previous fix incorrectly removed this when using ament. Co-Authored-By: Claude Opus 4.5 --- lib/CMakeLists.txt | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/lib/CMakeLists.txt b/lib/CMakeLists.txt index 0eec842e..95675201 100644 --- a/lib/CMakeLists.txt +++ b/lib/CMakeLists.txt @@ -66,9 +66,8 @@ if(REACTOR_CPP_INSTALL) LIBRARY DESTINATION "${CMAKE_INSTALL_LIBDIR}" OPTIONAL RUNTIME DESTINATION "${CMAKE_INSTALL_BINDIR}" OPTIONAL) - # Only install export file manually when not using ament. - # When using ament, ament_package() handles export installation. - if(NOT REACTOR_CPP_USE_AMENT) - install(EXPORT ${LIB_TARGET}Targets DESTINATION share/${LIB_TARGET}/cmake) - endif() + # Install the export file. Both ament and non-ament builds need this. + # For ament builds, ament_package() generates Config.cmake that includes this file. + install(EXPORT ${LIB_TARGET}Targets + DESTINATION share/${LIB_TARGET}/cmake) endif() From f95b7a2073c1aa69c7ea39c84d459a413d63f032 Mon Sep 17 00:00:00 2001 From: Shaokai Lin Date: Tue, 20 Jan 2026 23:53:39 -0800 Subject: [PATCH 06/13] Use standard ament export pattern Match the pattern used by rclcpp and other ROS2 packages: - Use PROJECT_NAME as export name instead of PROJECT_NAME + Targets - Add ament_export_libraries for legacy CMake compatibility Co-Authored-By: Claude Opus 4.5 --- CMakeLists.txt | 3 ++- lib/CMakeLists.txt | 4 ++-- 2 files changed, 4 insertions(+), 3 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index fc8da937..ab771f4d 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -80,7 +80,8 @@ else() endif() if (REACTOR_CPP_USE_AMENT) - ament_export_targets(${LIB_TARGET}Targets HAS_LIBRARY_TARGET) + ament_export_targets(${LIB_TARGET}) ament_export_include_directories(include) + ament_export_libraries(${LIB_TARGET}) ament_package() endif() diff --git a/lib/CMakeLists.txt b/lib/CMakeLists.txt index 95675201..f873f981 100644 --- a/lib/CMakeLists.txt +++ b/lib/CMakeLists.txt @@ -61,13 +61,13 @@ if(REACTOR_CPP_INSTALL) install(FILES "${PROJECT_BINARY_DIR}/include/reactor-cpp/config.hh" DESTINATION "${CMAKE_INSTALL_INCLUDEDIR}/reactor-cpp") endif() - install(TARGETS ${LIB_TARGET} EXPORT ${LIB_TARGET}Targets + install(TARGETS ${LIB_TARGET} EXPORT ${LIB_TARGET} ARCHIVE DESTINATION "${CMAKE_INSTALL_LIBDIR}" OPTIONAL LIBRARY DESTINATION "${CMAKE_INSTALL_LIBDIR}" OPTIONAL RUNTIME DESTINATION "${CMAKE_INSTALL_BINDIR}" OPTIONAL) # Install the export file. Both ament and non-ament builds need this. # For ament builds, ament_package() generates Config.cmake that includes this file. - install(EXPORT ${LIB_TARGET}Targets + install(EXPORT ${LIB_TARGET} DESTINATION share/${LIB_TARGET}/cmake) endif() From 94173353ff14eb04ee826aceb95435b70de7093a Mon Sep 17 00:00:00 2001 From: Shaokai Lin Date: Wed, 21 Jan 2026 00:14:02 -0800 Subject: [PATCH 07/13] Add debug output to diagnose ament detection --- CMakeLists.txt | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/CMakeLists.txt b/CMakeLists.txt index ab771f4d..862e8827 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -13,6 +13,9 @@ if (NOT DEFINED LF_REACTOR_CPP_SUFFIX) find_package(ament_cmake QUIET) if(ament_cmake_FOUND) set(REACTOR_CPP_USE_AMENT ON) + message(STATUS "reactor-cpp: ament_cmake FOUND, using ament build") + else() + message(STATUS "reactor-cpp: ament_cmake NOT found, using standalone build") endif() endif() @@ -80,8 +83,10 @@ else() endif() if (REACTOR_CPP_USE_AMENT) + message(STATUS "reactor-cpp: Exporting ament targets: ${LIB_TARGET}") ament_export_targets(${LIB_TARGET}) ament_export_include_directories(include) ament_export_libraries(${LIB_TARGET}) ament_package() + message(STATUS "reactor-cpp: ament_package() completed") endif() From afd45f38aadf7a471897636130797ab8a58785f4 Mon Sep 17 00:00:00 2001 From: Shaokai Lin Date: Wed, 21 Jan 2026 00:33:11 -0800 Subject: [PATCH 08/13] Use WARNING for debug messages to ensure visibility --- CMakeLists.txt | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 862e8827..dfb6e697 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -13,9 +13,9 @@ if (NOT DEFINED LF_REACTOR_CPP_SUFFIX) find_package(ament_cmake QUIET) if(ament_cmake_FOUND) set(REACTOR_CPP_USE_AMENT ON) - message(STATUS "reactor-cpp: ament_cmake FOUND, using ament build") + message(WARNING "reactor-cpp: ament_cmake FOUND, using ament build") else() - message(STATUS "reactor-cpp: ament_cmake NOT found, using standalone build") + message(WARNING "reactor-cpp: ament_cmake NOT found, using standalone build") endif() endif() @@ -83,10 +83,10 @@ else() endif() if (REACTOR_CPP_USE_AMENT) - message(STATUS "reactor-cpp: Exporting ament targets: ${LIB_TARGET}") + message(WARNING "reactor-cpp: Exporting ament targets: ${LIB_TARGET}") ament_export_targets(${LIB_TARGET}) ament_export_include_directories(include) ament_export_libraries(${LIB_TARGET}) ament_package() - message(STATUS "reactor-cpp: ament_package() completed") + message(WARNING "reactor-cpp: ament_package() completed") endif() From db4221f28e269adc2aa1e71ed780bbcc157692a5 Mon Sep 17 00:00:00 2001 From: Shaokai Lin Date: Wed, 21 Jan 2026 00:46:24 -0800 Subject: [PATCH 09/13] Add more debug output for install paths --- CMakeLists.txt | 2 ++ lib/CMakeLists.txt | 2 ++ 2 files changed, 4 insertions(+) diff --git a/CMakeLists.txt b/CMakeLists.txt index dfb6e697..980c5c9d 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -83,7 +83,9 @@ else() endif() if (REACTOR_CPP_USE_AMENT) + message(WARNING "reactor-cpp: PROJECT_NAME=${PROJECT_NAME}, LIB_TARGET=${LIB_TARGET}") message(WARNING "reactor-cpp: Exporting ament targets: ${LIB_TARGET}") + message(WARNING "reactor-cpp: CMAKE_INSTALL_PREFIX=${CMAKE_INSTALL_PREFIX}") ament_export_targets(${LIB_TARGET}) ament_export_include_directories(include) ament_export_libraries(${LIB_TARGET}) diff --git a/lib/CMakeLists.txt b/lib/CMakeLists.txt index f873f981..2d1bc599 100644 --- a/lib/CMakeLists.txt +++ b/lib/CMakeLists.txt @@ -61,6 +61,7 @@ if(REACTOR_CPP_INSTALL) install(FILES "${PROJECT_BINARY_DIR}/include/reactor-cpp/config.hh" DESTINATION "${CMAKE_INSTALL_INCLUDEDIR}/reactor-cpp") endif() + message(WARNING "reactor-cpp: Installing target ${LIB_TARGET} with EXPORT ${LIB_TARGET}") install(TARGETS ${LIB_TARGET} EXPORT ${LIB_TARGET} ARCHIVE DESTINATION "${CMAKE_INSTALL_LIBDIR}" OPTIONAL LIBRARY DESTINATION "${CMAKE_INSTALL_LIBDIR}" OPTIONAL @@ -68,6 +69,7 @@ if(REACTOR_CPP_INSTALL) # Install the export file. Both ament and non-ament builds need this. # For ament builds, ament_package() generates Config.cmake that includes this file. + message(WARNING "reactor-cpp: Installing EXPORT ${LIB_TARGET} to share/${LIB_TARGET}/cmake") install(EXPORT ${LIB_TARGET} DESTINATION share/${LIB_TARGET}/cmake) endif() From 7016d0dae439e51ce5b78e7b37ccdf9c2d0a0f96 Mon Sep 17 00:00:00 2001 From: Shaokai Lin Date: Wed, 21 Jan 2026 00:54:30 -0800 Subject: [PATCH 10/13] Move install(EXPORT) to root CMakeLists.txt for ament compatibility --- CMakeLists.txt | 10 +++++++++- lib/CMakeLists.txt | 7 +------ 2 files changed, 10 insertions(+), 7 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 980c5c9d..0e19f375 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -84,11 +84,19 @@ endif() if (REACTOR_CPP_USE_AMENT) message(WARNING "reactor-cpp: PROJECT_NAME=${PROJECT_NAME}, LIB_TARGET=${LIB_TARGET}") - message(WARNING "reactor-cpp: Exporting ament targets: ${LIB_TARGET}") message(WARNING "reactor-cpp: CMAKE_INSTALL_PREFIX=${CMAKE_INSTALL_PREFIX}") + # Install the export file - must be in root CMakeLists.txt for ament compatibility + message(WARNING "reactor-cpp: Installing EXPORT ${LIB_TARGET} to share/${LIB_TARGET}/cmake") + install(EXPORT ${LIB_TARGET} DESTINATION share/${LIB_TARGET}/cmake) + message(WARNING "reactor-cpp: Exporting ament targets: ${LIB_TARGET}") ament_export_targets(${LIB_TARGET}) ament_export_include_directories(include) ament_export_libraries(${LIB_TARGET}) ament_package() message(WARNING "reactor-cpp: ament_package() completed") +else() + # For non-ament builds, install export file from here + if(REACTOR_CPP_INSTALL) + install(EXPORT ${LIB_TARGET} DESTINATION share/${LIB_TARGET}/cmake) + endif() endif() diff --git a/lib/CMakeLists.txt b/lib/CMakeLists.txt index 2d1bc599..a3c16825 100644 --- a/lib/CMakeLists.txt +++ b/lib/CMakeLists.txt @@ -66,10 +66,5 @@ if(REACTOR_CPP_INSTALL) ARCHIVE DESTINATION "${CMAKE_INSTALL_LIBDIR}" OPTIONAL LIBRARY DESTINATION "${CMAKE_INSTALL_LIBDIR}" OPTIONAL RUNTIME DESTINATION "${CMAKE_INSTALL_BINDIR}" OPTIONAL) - - # Install the export file. Both ament and non-ament builds need this. - # For ament builds, ament_package() generates Config.cmake that includes this file. - message(WARNING "reactor-cpp: Installing EXPORT ${LIB_TARGET} to share/${LIB_TARGET}/cmake") - install(EXPORT ${LIB_TARGET} - DESTINATION share/${LIB_TARGET}/cmake) + # Note: install(EXPORT ...) moved to root CMakeLists.txt for ament compatibility endif() From eed2bf15fa431b131ed17f33c6b32600fbdc7b15 Mon Sep 17 00:00:00 2001 From: Shaokai Lin Date: Wed, 21 Jan 2026 01:05:28 -0800 Subject: [PATCH 11/13] Add HAS_LIBRARY_TARGET to ament_export_targets --- CMakeLists.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 0e19f375..993ad91a 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -89,7 +89,7 @@ if (REACTOR_CPP_USE_AMENT) message(WARNING "reactor-cpp: Installing EXPORT ${LIB_TARGET} to share/${LIB_TARGET}/cmake") install(EXPORT ${LIB_TARGET} DESTINATION share/${LIB_TARGET}/cmake) message(WARNING "reactor-cpp: Exporting ament targets: ${LIB_TARGET}") - ament_export_targets(${LIB_TARGET}) + ament_export_targets(${LIB_TARGET} HAS_LIBRARY_TARGET) ament_export_include_directories(include) ament_export_libraries(${LIB_TARGET}) ament_package() From 874e6889cfc3f57630a3b7b0e4d89cb6764b851c Mon Sep 17 00:00:00 2001 From: Shaokai Lin Date: Wed, 21 Jan 2026 01:37:59 -0800 Subject: [PATCH 12/13] Add NAMESPACE to export for proper target linking --- CMakeLists.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 993ad91a..fcd817aa 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -87,7 +87,7 @@ if (REACTOR_CPP_USE_AMENT) message(WARNING "reactor-cpp: CMAKE_INSTALL_PREFIX=${CMAKE_INSTALL_PREFIX}") # Install the export file - must be in root CMakeLists.txt for ament compatibility message(WARNING "reactor-cpp: Installing EXPORT ${LIB_TARGET} to share/${LIB_TARGET}/cmake") - install(EXPORT ${LIB_TARGET} DESTINATION share/${LIB_TARGET}/cmake) + install(EXPORT ${LIB_TARGET} DESTINATION share/${LIB_TARGET}/cmake NAMESPACE ${LIB_TARGET}::) message(WARNING "reactor-cpp: Exporting ament targets: ${LIB_TARGET}") ament_export_targets(${LIB_TARGET} HAS_LIBRARY_TARGET) ament_export_include_directories(include) From ce95a94ded25fff494b876849d92c0fbe082dc51 Mon Sep 17 00:00:00 2001 From: Shaokai Lin Date: Wed, 21 Jan 2026 02:25:29 -0800 Subject: [PATCH 13/13] Remove debug WARNING messages Clean up debug output that was added during ROS2/ament build troubleshooting. Co-Authored-By: Claude Opus 4.5 --- CMakeLists.txt | 8 -------- lib/CMakeLists.txt | 1 - 2 files changed, 9 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index fcd817aa..8f201698 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -13,9 +13,6 @@ if (NOT DEFINED LF_REACTOR_CPP_SUFFIX) find_package(ament_cmake QUIET) if(ament_cmake_FOUND) set(REACTOR_CPP_USE_AMENT ON) - message(WARNING "reactor-cpp: ament_cmake FOUND, using ament build") - else() - message(WARNING "reactor-cpp: ament_cmake NOT found, using standalone build") endif() endif() @@ -83,17 +80,12 @@ else() endif() if (REACTOR_CPP_USE_AMENT) - message(WARNING "reactor-cpp: PROJECT_NAME=${PROJECT_NAME}, LIB_TARGET=${LIB_TARGET}") - message(WARNING "reactor-cpp: CMAKE_INSTALL_PREFIX=${CMAKE_INSTALL_PREFIX}") # Install the export file - must be in root CMakeLists.txt for ament compatibility - message(WARNING "reactor-cpp: Installing EXPORT ${LIB_TARGET} to share/${LIB_TARGET}/cmake") install(EXPORT ${LIB_TARGET} DESTINATION share/${LIB_TARGET}/cmake NAMESPACE ${LIB_TARGET}::) - message(WARNING "reactor-cpp: Exporting ament targets: ${LIB_TARGET}") ament_export_targets(${LIB_TARGET} HAS_LIBRARY_TARGET) ament_export_include_directories(include) ament_export_libraries(${LIB_TARGET}) ament_package() - message(WARNING "reactor-cpp: ament_package() completed") else() # For non-ament builds, install export file from here if(REACTOR_CPP_INSTALL) diff --git a/lib/CMakeLists.txt b/lib/CMakeLists.txt index a3c16825..7fa490f9 100644 --- a/lib/CMakeLists.txt +++ b/lib/CMakeLists.txt @@ -61,7 +61,6 @@ if(REACTOR_CPP_INSTALL) install(FILES "${PROJECT_BINARY_DIR}/include/reactor-cpp/config.hh" DESTINATION "${CMAKE_INSTALL_INCLUDEDIR}/reactor-cpp") endif() - message(WARNING "reactor-cpp: Installing target ${LIB_TARGET} with EXPORT ${LIB_TARGET}") install(TARGETS ${LIB_TARGET} EXPORT ${LIB_TARGET} ARCHIVE DESTINATION "${CMAKE_INSTALL_LIBDIR}" OPTIONAL LIBRARY DESTINATION "${CMAKE_INSTALL_LIBDIR}" OPTIONAL