Repository navigation
Backlog
Labels
enhancementNew feature or requestknown-downstream-workaroundsDownstream consumer pain or workaround observed in real-world OSS reposneeds-triageMaintainer needs to evaluate this issue
Description
Part of #138
Popularity: 4/7 corpus consumers (cuda-quantum, fanuc-libs, moqx, wolf)
Problem
- Consumers that want a minimal, deterministic single-format configuration (e.g. YAML-only or TOML-only, no vcpkg, no install rules) must spell out many
REFLECTCPP_*cache flags (23set(...)statements incuda-quantum, 8 inwolf) to guard against default-on options (REFLECTCPP_JSON,REFLECTCPP_INSTALL,REFLECTCPP_USE_VCPKG, etc.). - Enabling any non-JSON format (
REFLECTCPP_YAML=ON,REFLECTCPP_TOML=ON,REFLECTCPP_MSGPACK=ON, etc.) silently flipsREFLECTCPP_USE_VCPKG_DEFAULTtoONinsidereflect-cpp/CMakeLists.txt(#L71-L94,#L185) — even when embedded as a subproject (NOT PROJECT_IS_TOP_LEVEL) where vcpkg is never configured — mutatingCMAKE_TOOLCHAIN_FILEin the parent project'sCMakeCache.txtunless consumers explicitly overrideREFLECTCPP_USE_VCPKG=OFF. - Under
FetchContent/CPMwithout vcpkg,reflect-cpprelies on undocumented ordering tricks (if (NOT TARGET yaml-cpp::yaml-cpp) find_package(yaml-cpp CONFIG REQUIRED)/if (NOT TARGET tomlplusplus::tomlplusplus) find_package(tomlplusplus)), forcing every consumer to manually pre-fetchyaml-cpportomlplusplus(withOVERRIDE_FIND_PACKAGE) strictly beforereflect-cpp, with no explicit CMake target-injection API.
Observed Downstream Workarounds
NVIDIA/cuda-quantum (90e4aa08)
cudaq/lib/Target/cmake/FetchDependencies.cmake#L42-L69: sets 23REFLECTCPP_*variables to select YAML-only with bundled header dependencies, then enforcesFetchContent_MakeAvailableordering:# reflect-cpp: YAML support only, on top of the bundled header dependencies # (ctre, enchantum); never resolve dependencies through vcpkg. set(REFLECTCPP_BUILD_SHARED OFF) set(REFLECTCPP_INSTALL OFF) set(REFLECTCPP_YAML ON) set(REFLECTCPP_JSON OFF) ... # 14 more format OFF flags + VCPKG/BUNDLED/TESTS/BENCHMARKS/CHECK_HEADERS set(REFLECTCPP_CHECK_HEADERS OFF) # Ordering matters: yaml-cpp is a dependency of reflect-cpp. FetchContent_MakeAvailable(yaml_cpp reflectcpp)
FANUC-CORPORATION/fanuc_driver (da5db3f6)
fanuc_libs/CMakeLists.txt#L38-L56: must declare and makeyaml-cppavailable beforereflect-cppsoTARGET yaml-cpp::yaml-cppis already defined, and setsREFLECTCPP_YAML ONwithoutREFLECTCPP_USE_VCPKG OFF(which silently flipsREFLECTCPP_USE_VCPKG_DEFAULT=ONand writesCMAKE_TOOLCHAIN_FILEinto the parent cache):FetchContent_Declare( yaml-cpp GIT_REPOSITORY ${CMAKE_SOURCE_DIR}/dependencies/yaml-cpp GIT_TAG 2f86d13775d119edbb69af52e5f566fd65c6953b ) FetchContent_MakeAvailable(yaml-cpp) set(YAML_BUILD_SHARED_LIBS OFF CACHE BOOL "Build yaml-cpp shared library") set(YAML_CPP_INSTALL OFF CACHE BOOL "Enable generation of yaml-cpp install targets") # Build the reflectcpp library FetchContent_Declare( reflect-cpp GIT_REPOSITORY ${CMAKE_SOURCE_DIR}/dependencies/reflect-cpp GIT_TAG 2a0fdeabe35bdab0e07e05d4f869ca88bd6d2b8c PATCH_COMMAND bash ${CMAKE_SOURCE_DIR}/dependencies/apply_patch.bash ${CMAKE_SOURCE_DIR}/dependencies/reflectcpp.patch ) 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)
.gitmodules#L4-L6and.github/workflows/ci.yaml#L37-L39: CI also checks outsubmodules: recursive(andFetchContent_DeclareomitsGIT_SUBMODULES ""), pullinggetml/reflect-cpp's dev-onlyvcpkgsubmodule unnecessarily (related to Build/CMake: dev-only vcpkg git submodule fetched by default under FetchContent, CPM, and recursive git submodules #139).
openmoq/moqx (60bab7f13925acbaf578670223e660d71e891547)
CMakeLists.txt#L286-L305: must manually declare and configureyaml-cppbeforereflect-cppvia CPM with an explicit ordering comment:# --- yaml-cpp (CPM) --- CPMAddPackage( NAME yaml-cpp GITHUB_REPOSITORY jbeder/yaml-cpp GIT_TAG ${YAMLCPP_VERSION} OPTIONS "YAML_CPP_BUILD_TESTS OFF" "YAML_CPP_BUILD_TOOLS OFF" "YAML_CPP_FORMAT_SOURCE OFF" "CMAKE_WARN_DEPRECATED OFF" ) # --- reflect-cpp (CPM, needs yaml-cpp available) --- CPMAddPackage( NAME reflectcpp GITHUB_REPOSITORY getml/reflect-cpp GIT_TAG ${REFLECTCPP_VERSION} OPTIONS "REFLECTCPP_YAML ON" "REFLECTCPP_BUILD_TESTS OFF" )
CMakeLists.txt#L93-L95: must also carry a CMake 4+ policy workaround (set(CMAKE_POLICY_VERSION_MINIMUM 3.5)) foryaml-cpp 0.8.0.cmake/dependencies.cmake#L23-L25: must maintain and bump a separateYAMLCPP_VERSIONpin alongsideREFLECTCPP_VERSIONsolely to satisfyreflect-cpp's YAML backend.
games-on-whales/wolf (ac2461f6)
src/moonlight-server/CMakeLists.txt#L28-L59: must pre-fetchtomlpluspluswithOVERRIDE_FIND_PACKAGEstrictly beforereflect-cpp, explicitly turnREFLECTCPP_USE_VCPKG OFF, and enumerate 7 format flags:# TOML FetchContent_Declare( tomlplusplus GIT_REPOSITORY https://github.com/marzer/tomlplusplus.git GIT_TAG v3.4.0 OVERRIDE_FIND_PACKAGE ) FetchContent_MakeAvailable(tomlplusplus) ... # Serialization FetchContent_Declare( reflect-cpp GIT_REPOSITORY https://github.com/getml/reflect-cpp GIT_TAG v0.21.0 ) set(REFLECTCPP_USE_VCPKG OFF) set(REFLECTCPP_BSON OFF) set(REFLECTCPP_CBOR OFF) set(REFLECTCPP_FLEXBUFFERS OFF) set(REFLECTCPP_MSGPACK OFF) set(REFLECTCPP_TOML ON) set(REFLECTCPP_XML OFF) set(REFLECTCPP_YAML OFF) FetchContent_MakeAvailable(reflect-cpp) target_link_libraries(wolf_runner PUBLIC reflectcpp)
- Historical context in
wolf's git log confirms the same vcpkg friction previously blocked enablingREFLECTCPP_MSGPACK: commit62936637initially carriedset(REFLECTCPP_MSGPACK OFF) # Only works with vcpkg, doing it manuallyand wiredpkg_check_modules(MSGPACK ...)manually before commite0ba6e60switched toREFLECTCPP_USE_VCPKG OFF+tomlpluspluswithOVERRIDE_FIND_PACKAGE.
Potential Improvements
- Never default
REFLECTCPP_USE_VCPKGtoON(and never overwriteCMAKE_TOOLCHAIN_FILE) whenNOT PROJECT_IS_TOP_LEVEL. - Default
REFLECTCPP_INSTALLtoPROJECT_IS_TOP_LEVEL(standard CMake practice when embedded viaFetchContent/add_subdirectory) and consider a minimal/explicit format preset. - Document and standardize explicit target injection for external format backends (
yaml-cpp,tomlplusplus,yyjson,pugixml, etc.).
Upstream Overlap
- Provide CMake components for different serialization formats munich-data-engineering/reflect-cpp#576 (open, partial) — Proposes CMake components for modular serialization format selection; maintainer (
@liuzicheng1987) replied "OK, I think that could be done." - Skip
find_packagecalls if required targets are already available during configuration munich-data-engineering/reflect-cpp#231 / Skipfind_packagefor already present targets munich-data-engineering/reflect-cpp#236 (closed/fixed via merged PR, partial) — Addedif (NOT TARGET ...)checks to skipfind_packagewhen targets are pre-fetched viaCPM/FetchContent. - Fix target check for tomlplusplus in CMakeLists munich-data-engineering/reflect-cpp#563 (merged, partial) — Fixed the mismatched
tomlplusplustarget check inCMakeLists.txt(merged post-wolfv0.21.0, wherewolfneededOVERRIDE_FIND_PACKAGE). - added REFLECTCPP_INSTALL to allow user to control if required munich-data-engineering/reflect-cpp#453 (merged, partial) — Added
REFLECTCPP_INSTALLtoggle to control install rules (subsequently defaulted toPROJECT_IS_TOP_LEVEL). - Unfiled upstream: Silent
REFLECTCPP_USE_VCPKG=ONflip /CMAKE_TOOLCHAIN_FILEmutation when enabling non-JSON formats in a subproject (NOT PROJECT_IS_TOP_LEVEL).
Metadata
Metadata
Assignees
Labels
enhancementNew feature or requestknown-downstream-workaroundsDownstream consumer pain or workaround observed in real-world OSS reposneeds-triageMaintainer needs to evaluate this issue
Activity
[-]Build/CMake: verbose format opt-in boilerplate (23 REFLECTCPP_* flags) and implicit yaml-cpp FetchContent ordering[/-][+]Build/CMake: format opt-in boilerplate, implicit yaml-cpp/tomlplusplus FetchContent ordering, and silent REFLECTCPP_USE_VCPKG=ON[/+]build(cmake): keep REFLECTCPP_USE_VCPKG and REFLECTCPP_INSTALL off in…
build(cmake): keep REFLECTCPP_USE_VCPKG and REFLECTCPP_INSTALL off in…
build(cmake): keep REFLECTCPP_USE_VCPKG and REFLECTCPP_INSTALL off in…
build(cmake): keep REFLECTCPP_USE_VCPKG and REFLECTCPP_INSTALL off in…
build(cmake): subproject ergonomics, CMake 3.20 support, warning/lint…
build(cmake): subproject ergonomics, CMake 3.20 support, warning/lint…
build(cmake): subproject ergonomics, CMake 3.20 support, warning/lint…
build(cmake): subproject ergonomics, CMake 3.20 support, warning/lint…
build(cmake): subproject ergonomics, CMake 3.20 support, warning/lint…
build(cmake): subproject ergonomics, CMake 3.20 support, warning/lint…