From ea26397d70ceab64483649f27ea95a187e735a92 Mon Sep 17 00:00:00 2001 From: cc Date: Sat, 10 Jan 2026 21:40:20 -0500 Subject: [PATCH 1/3] chore: make reflect-cpp compilable as ros pacakge --- .gitignore | 3 ++- CMakeLists.txt | 10 ++++++++-- package.xml | 15 +++++++++++++++ 3 files changed, 25 insertions(+), 3 deletions(-) create mode 100644 package.xml diff --git a/.gitignore b/.gitignore index 91479bda..43aa36d0 100644 --- a/.gitignore +++ b/.gitignore @@ -54,6 +54,7 @@ *.toml *.ubjson *.xml +!package.xml *.yml *.yaml @@ -94,4 +95,4 @@ share/python-wheels/ MANIFEST # Docs -site/ \ No newline at end of file +site/ diff --git a/CMakeLists.txt b/CMakeLists.txt index 193f9f47..29c68332 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -141,9 +141,11 @@ if (REFLECTCPP_USE_VCPKG) set(CMAKE_TOOLCHAIN_FILE ${CMAKE_CURRENT_SOURCE_DIR}/vcpkg/scripts/buildsystems/vcpkg.cmake CACHE STRING "Vcpkg toolchain file") endif () -project(reflectcpp VERSION 0.23.0 LANGUAGES CXX) +project(reflect_cpp VERSION 0.23.0 LANGUAGES CXX) -if (PROJECT_IS_TOP_LEVEL) +find_package(ament_cmake QUIET) + +if (PROJECT_IS_TOP_LEVEL AND ament_cmake_FOUND) set(REFLECTCPP_INSTALL ON) endif() @@ -508,3 +510,7 @@ set(CPACK_RPM_PACKAGE_REQUIRES "") include(CPack) +if (ament_cmake_FOUND) + ament_package() +endif() + diff --git a/package.xml b/package.xml new file mode 100644 index 00000000..a67d1dce --- /dev/null +++ b/package.xml @@ -0,0 +1,15 @@ + + + + reflect_cpp + 0.1.0 + C++ reflection library + liuzicheng1987 + MIT + + ament_cmake + + + ament_cmake + + From f91ccf448ffd6dc329f35386fd96ea221d776162 Mon Sep 17 00:00:00 2001 From: cc Date: Tue, 13 Jan 2026 18:28:24 -0500 Subject: [PATCH 2/3] doc: ros2 install instruction --- docs/install.md | 39 +++++++++++++++++++++++++++++++++++++++ 1 file changed, 39 insertions(+) diff --git a/docs/install.md b/docs/install.md index ef099db3..e2ed4390 100644 --- a/docs/install.md +++ b/docs/install.md @@ -128,3 +128,42 @@ If you want to include all formats supported on Conan, do the following: ```bash conan build . --build=missing -s compiler.cppstd=gnu20 -o *:with_cbor=True -o *:with_flatbuffers=True -o *:with_msgpack=True -o *:with_toml=True -o *:with_ubjson=True -o *:with_xml=True -o *:with_yaml=True ``` + +## Option 7: Integrate as a ROS2 package + +reflect-cpp now ships with an `ament_cmake` package manifest so it can be +built directly in a ROS 2 workspace and consumed like any other +CMake-config package. + +1. Fetch the sources with `vcs` using the `.repos` file from the + [tea-ros2](https://github.com/getml/tea-ros2) workspace, which already + tracks `reflect-cpp`: + + ```bash + mkdir -p ~/ros2_ws/src + cd ~/ros2_ws + # adding the entry to your vcs .repos file, or create one + # reflect-cpp: + # type: git + # url: git@github.com:getml/reflect-cpp.git + # version: main + vcs import src < src/.repos + ``` + +2. Build the package with `colcon` (package name: `reflect_cpp`). The build + enables installation automatically when invoked from an ament workspace: + + ```bash + colcon build --packages-select reflect_cpp + ``` + +3. Link against reflect-cpp from your ROS 2 package via the exported CMake + config. + + ```cmake + find_package(reflectcpp REQUIRED) + target_link_libraries(${PROJECT_NAME} reflectcpp::reflectcpp) + ``` + + This makes the `reflectcpp::reflectcpp` target available to your nodes + while keeping the ROS build flow unchanged. From d10546712dc0f332393043925c2ea3f6c2254619 Mon Sep 17 00:00:00 2001 From: cc Date: Tue, 13 Jan 2026 18:40:31 -0500 Subject: [PATCH 3/3] fix: apply gemini suggestions --- CMakeLists.txt | 4 ++-- docs/install.md | 4 ++-- package.xml | 4 ++-- 3 files changed, 6 insertions(+), 6 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 29c68332..71c8ce2b 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -141,11 +141,11 @@ if (REFLECTCPP_USE_VCPKG) set(CMAKE_TOOLCHAIN_FILE ${CMAKE_CURRENT_SOURCE_DIR}/vcpkg/scripts/buildsystems/vcpkg.cmake CACHE STRING "Vcpkg toolchain file") endif () -project(reflect_cpp VERSION 0.23.0 LANGUAGES CXX) +project(reflectcpp VERSION 0.23.0 LANGUAGES CXX) find_package(ament_cmake QUIET) -if (PROJECT_IS_TOP_LEVEL AND ament_cmake_FOUND) +if (PROJECT_IS_TOP_LEVEL) set(REFLECTCPP_INSTALL ON) endif() diff --git a/docs/install.md b/docs/install.md index e2ed4390..daba7af2 100644 --- a/docs/install.md +++ b/docs/install.md @@ -150,11 +150,11 @@ CMake-config package. vcs import src < src/.repos ``` -2. Build the package with `colcon` (package name: `reflect_cpp`). The build +2. Build the package with `colcon` (package name: `reflectcpp`). The build enables installation automatically when invoked from an ament workspace: ```bash - colcon build --packages-select reflect_cpp + colcon build --packages-select reflectcpp ``` 3. Link against reflect-cpp from your ROS 2 package via the exported CMake diff --git a/package.xml b/package.xml index a67d1dce..b2960e8d 100644 --- a/package.xml +++ b/package.xml @@ -1,8 +1,8 @@ - reflect_cpp - 0.1.0 + reflectcpp + 0.23.0 C++ reflection library liuzicheng1987 MIT