Lokasi ngalangkungan proxy:   [ UP ]  
[Ngawartoskeun bug]   [Panyetelan cookie]                
Skip to content

Build/CMake: reflectcpp target lacks SYSTEM headers, warning/visibility/PIC/linter isolation, and collides on bundled yyjson #140

Backlog

Description

@clockblocker

Part of #138
Popularity: 5/7 corpus consumers (cuda-quantum, holoscan-sdk, fanuc-libs, wolf, slang-server)

Problem

Consuming the upstream reflectcpp CMake target directly in strict or multi-target builds triggers multiple build-hygiene and linkage issues:

  1. Public/interface include directories are not exported as SYSTEM, leaking third-party warnings into consumer -Werror builds and forcing per-target SYSTEM re-declarations or directory-wide -w hacks.
  2. reflect-cpp's own compiled sources inherit parent directory warning flags (triggering -Wmissing-field-initializers, -Wunused-parameter, Clang 19+ -Wmissing-template-arg-list-after-template-kw) and do not isolate COMPILE_WARNING_AS_ERROR, CXX_CLANG_TIDY, POSITION_INDEPENDENT_CODE, or hidden symbol visibility (CXX_VISIBILITY_PRESET hidden / VISIBILITY_INLINES_HIDDEN ON) when statically embedded into shared libraries.
  3. Bundled yyjson symbols are compiled with default ELF visibility (yyjson_api), and a consumer that already builds its own yyjson object cannot share that single hidden-visibility yyjson object with the reflectcpp CMake target without duplicate symbols or target-bypassing workarounds.

Observed Downstream Workarounds

NVIDIA/cuda-quantum (90e4aa08)

  • cudaq/lib/Target/cmake/FetchDependencies.cmake#L77-L89: manually overrides five target properties post-FetchContent_MakeAvailable to keep reflectcpp headers out of root -Werror and symbols hidden inside CUDAQTargetCatalog:
    set_target_properties(${_cudaq_target_dep} PROPERTIES
      POSITION_INDEPENDENT_CODE ON
      COMPILE_WARNING_AS_ERROR OFF
      SYSTEM ON
      CXX_VISIBILITY_PRESET hidden
      VISIBILITY_INLINES_HIDDEN ON)

nvidia-holoscan/holoscan-sdk (358c772f)

  • CMakeLists.txt#L527-L568: completely bypasses the reflectcpp CMake target and manually compiles ${reflectcpp_SOURCE_DIR}/src/reflectcpp.cpp and src/reflectcpp_json.cpp into a custom OBJECT library (holoscan_config_reflect_private_objects) with:
    • target_compile_definitions(... PRIVATE yyjson_api=) so yyjson honors hidden ELF visibility
    • SYSTEM PRIVATE include directories (include and include/rfl/thirdparty)
    • CXX_CLANG_TIDY "" and POSITION_INDEPENDENT_CODE ON
    • Reuse of Holoscan's single holoscan_config_yyjson_private_objects (yyjson.c) instead of reflect-cpp's bundled copy.

FANUC-CORPORATION/fanuc_driver (da5db3f6)

  • fanuc_libs/CMakeLists.txt#L54-L58: forces POSITION_INDEPENDENT_CODE ON on static reflectcpp post-FetchContent so it can be linked PRIVATE into installed ROS 2 SHARED libraries:
    set(REFLECTCPP_BUILD_SHARED OFF CACHE BOOL "Build reflectcpp as a shared library")
    set(REFLECTCPP_YAML ON CACHE BOOL "Enable YAML support")
    FetchContent_MakeAvailable(reflect-cpp)
    set_target_properties(reflectcpp PROPERTIES CXX_STANDARD 20)
    set_target_properties(reflectcpp PROPERTIES POSITION_INDEPENDENT_CODE ON)
  • Both fanuc_libs/gpio_config/CMakeLists.txt#L9-L10 and fanuc_libs/rmi/CMakeLists.txt#L9-L10 build SHARED libraries that privately absorb the static reflectcpp archive:
    add_library(gpio_config SHARED src/gpio_config.cpp )
    target_link_libraries(gpio_config PRIVATE reflectcpp)
    add_library(rmi SHARED src/rmi.cpp src/serialization.cpp src/deserialization.cpp)
    target_link_libraries(rmi PRIVATE reflectcpp Sockpp::sockpp)
  • Furthermore, fanuc_hardware_interface/CMakeLists.txt#L27-L35 links both fanuc_libs::rmi and fanuc_libs::gpio_config into the same libfanuc_robot_driver.so plugin, meaning both shared libraries embed default-visibility reflectcpp + bundled yyjson symbols in the same process.

games-on-whales/wolf (ac2461f6)

  1. Directory-wide -w toggle around FetchContent_MakeAvailable(reflect-cpp):
    While wolf imports nearly every other fetched library (fmt, eventbus, simple-web-server, mdns_cpp, enet, ICU::uc) through a custom target_link_libraries_system helper (cmake/TargetLinkLibrariesSystem.cmake#L1-L31), for reflect-cpp it saves and overwrites COMPILE_OPTIONS with -w before fetching and restores it afterwards (src/moonlight-server/CMakeLists.txt#L37-L61, introduced in commit 1d7ba8f9):
    # A nice little trick to disable warnings for external dependencies
    # see: https://stackoverflow.com/a/76128930
    get_directory_property(old_dir_compile_options COMPILE_OPTIONS)
    add_compile_options(-w)
    
    # Serialization
    FetchContent_Declare(
            reflect-cpp
            GIT_REPOSITORY https://github.com/getml/reflect-cpp
            GIT_TAG v0.21.0
    )
    ...
    FetchContent_MakeAvailable(reflect-cpp)
    target_link_libraries(wolf_runner PUBLIC reflectcpp)
    # Restore warnings
    set_directory_properties(PROPERTIES COMPILE_OPTIONS "${old_dir_compile_options}")
  2. Global Clang 19+ warning-suppression flag in Docker build:
    In docker/wolf.Dockerfile#L56-L66 (line 61, added in commit 40d43716 "fix: docker build with latest clangd 19 breaks reflect-cpp", explicitly citing getml/reflect-cpp#221):
        -DCMAKE_CXX_FLAGS="-Wno-missing-template-arg-list-after-template-kw"    ```
    

hudson-trading/slang-server (1b413a46)

slang-server compiles its own code with -Wall -Wextra -Wpedantic -Werror (CMakeLists.txt#L156-L162, CMakeLists.txt#L391-L405). Integrating reflect-cpp via add_subdirectory(external/reflect-cpp) requires patching both the reflectcpp target itself and every consumer target:

  1. Injecting warning suppressions onto reflectcpp (CMakeLists.txt#L317-L321):
    # Suppress warnings in reflect-cpp library
    if(CMAKE_CXX_COMPILER_ID MATCHES "GNU|Clang")
      target_compile_options(reflectcpp PRIVATE -Wno-missing-field-initializers
                                                -Wno-unused-parameter -fexceptions)
    endif()
  2. Re-declaring external/reflect-cpp/include as SYSTEM on 3 separate targets — including targets that already link reflectcpp:
    • CMakeLists.txt#L378-L379:
      target_include_directories(slang_server_obj_lib SYSTEM
                                 PRIVATE external/reflect-cpp/include)
    • CMakeLists.txt#L418-L420:
      target_include_directories(gen_config_schema SYSTEM
                                 PRIVATE external/reflect-cpp/include)
      target_link_libraries(gen_config_schema PRIVATE reflectcpp)
    • tests/cpp/CMakeLists.txt#L14-L17:
      target_include_directories(
        server_unittests SYSTEM
        PRIVATE ${PROJECT_SOURCE_DIR}/external/reflect-cpp/include)
      target_link_libraries(server_unittests PRIVATE reflectcpp)

Related Fork Work

Upstream Overlap

Activity

  1. added
    bug
    needs-triage
    known-downstream-workarounds
    on Nov 29, 2026
  2. changed the title [-]Build/CMake: reflectcpp target lacks SYSTEM headers, visibility/PIC/linter isolation, and collides on bundled yyjson[/-] [+]Build/CMake: reflectcpp target lacks SYSTEM headers, warning/visibility/PIC/linter isolation, and collides on bundled yyjson[/+] on Nov 29, 2026
  3. clockblocker commented on Nov 29, 2026

    @clockblocker
    OwnerAuthor

    Tracking & PR Cross-Reference

    Status: Partially addressed (upstream-queue Draft PR #191 for public-header warnings; upstream-queue-for-build-cmake in progress for CMake hygiene).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugknown-downstream-workaroundsneeds-triage

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions