Repository navigation
build(cmake): subproject ergonomics, CMake 3.20 support, warning/linter isolation, and FetchContent docs - #256
Open
clockblocker wants to merge 1 commit into
Open
clockblocker wants to merge 1 commit into
clockblocker wants to merge 1 commit into
Conversation
This was referenced Dec 2, 2026
…er isolation, and FetchContent docs Make reflect-cpp work out of the box as a CMake subproject (FetchContent / add_subdirectory) across Linux, macOS, and Windows (VS 2022 MSBuild, Ninja MSVC, Ninja clang-cl) without mutating parent project state or tripping consumer warning/linter policies: - **Target-scoped C++ standard & top-level scoping (#157):** Compute `_REFLECTCPP_IS_TOP_LEVEL` (`CMAKE_CURRENT_SOURCE_DIR STREQUAL CMAKE_SOURCE_DIR`), scope global `CMAKE_CXX_STANDARD` / `CMAKE_CXX_STANDARD_REQUIRED` / `CMAKE_EXPORT_COMPILE_COMMANDS` defaults, `ament_cmake` / `ament_package()`, and `CPack` to top-level builds, and declare target-scoped `target_compile_features` (`cxx_std_20` / `cxx_std_23` / `cxx_std_26` guarded on CMake >= 3.30 with `CXX_STANDARD 26` fallback on 3.25-3.29) + `CXX_STANDARD_REQUIRED ON`. - **CMake 3.20 minimum with 3.23 FILE_SET fallback (#156):** Lower `cmake_minimum_required` from 3.23 to 3.20 (supporting RHEL 8 / Ubuntu 22.04 / ROS 2 Humble), replace `PROJECT_IS_TOP_LEVEL` with `_REFLECTCPP_IS_TOP_LEVEL`, gate `FILE_SET reflectcpp_headers` on CMake >= 3.23 with an `install(DIRECTORY ...)` fallback, fix `${INCLUDE_INSTALL_DIR}` to `${CMAKE_INSTALL_INCLUDEDIR}`, and guard `$<LINK_LIBRARY:WHOLE_ARCHIVE,...>` on CMake >= 3.24 with `/WHOLEARCHIVE:` fallback. - **Subproject vcpkg/install defaults & config ordering (#142):** Default `REFLECTCPP_INSTALL` and `REFLECTCPP_USE_VCPKG` to `${_REFLECTCPP_IS_TOP_LEVEL}` (removing the unconditional top-level `REFLECTCPP_INSTALL=ON` override), preserve pre-set `CMAKE_TOOLCHAIN_FILE` (preferring explicit `-DVCPKG_ROOT`, then local `./vcpkg` submodule, then `$ENV{VCPKG_ROOT}`), replace directory-level `include_directories(PUBLIC ${jsoncons_INCLUDE_DIRS})` with target-scoped `SYSTEM PUBLIC $<BUILD_INTERFACE:...>`, and order `reflectcpp-exports.cmake` after all `find_dependency()` calls in `reflectcpp-config.cmake.in`. Keep default library naming untouched for Conan (`conanfile.py`) and existing Windows Debug consumers, documenting `-DCMAKE_DEBUG_POSTFIX=d` for multi-config single-prefix Windows installs. - **SYSTEM interface includes & warning/linter isolation (#140 Part 1):** Mark subproject consumer interface includes `SYSTEM` (unless top-level or `REFLECTCPP_STRICT_WARNINGS=ON`), propagate subproject `pugixml` includes onto `reflectcpp`'s own `SYSTEM PUBLIC $<BUILD_INTERFACE:...>` without mutating parent targets, mark bundled thirdparty & YAS includes `SYSTEM`, silence vendored `src/yyjson.c` warnings cleanly (`-w` on GNU/Clang, `/W0` under MSVC `REFLECTCPP_STRICT_WARNINGS`), clear inherited `CLANG_TIDY`/`CPPCHECK`/`IWYU` and `COMPILE_WARNING_AS_ERROR` on subproject `reflectcpp`, strip inherited MSVC `/W*`/`-W*`/`/WX*`/`-WX*` flags cleanly in local scope to eliminate D9025 spam (restoring `/W3` for `tests/` and `benchmarks/` under top-level `REFLECTCPP_STRICT_WARNINGS=ON`), use `/W4` instead of `-Wall` under `REFLECTCPP_STRICT_WARNINGS` on MSVC/clang-cl, remove redundant Release `-DNDEBUG` injection, and fix compiled-source warnings in `src/rfl/env/Writer.cpp`, `include/rfl/parsing/schema/Type.hpp`/`.cpp` (explicit out-of-line copy/move special members for C5267), and `src/rfl/json/to_schema.cpp` (C4459/C4702). - **CXX-only & MSVC-safe test/benchmark subprojects:** Add `LANGUAGES CXX` to all `tests/*/CMakeLists.txt` and `benchmarks/*/CMakeLists.txt` so `-DCMAKE_CXX_COMPILER=clang-cl` does not probe a C compiler, and guard GCC-only `-Wall -O2` `CMAKE_C_FLAGS` with `if (NOT MSVC)`. - **FetchContent quickstart & install docs:** Fix broken links and Option 5 option ordering in `README.md` and `docs/content/install.md`, and add JSON-only (`GIT_SUBMODULES ""`) and YAML FetchContent quickstart snippets. Addresses #140, #142, #156, #157 and clockblocker/refl-cpp-workbench#23.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Problem
Embedding
reflect-cppviaFetchContentoradd_subdirectorymutates parent CMake globals and unconditionally enables install andvcpkgintegration.It also requires CMake 3.23+ (breaking RHEL 8, Ubuntu 22.04, and ROS 2 Humble) and trips strict parent
-Werror,clang-tidy, and MSVC/WXpolicies.Summary
FILE_SETand 3.24WHOLE_ARCHIVEfallbacks), uses target-scoped C++20/23/26 features, and scopesCPack,ament_cmake, install, andvcpkgdefaults to top-level builds.SYSTEMincludes, strips inherited linter and warning-as-error flags across GCC, Clang, MSVC, andclang-cl, and fixes compiled-source MSVC warnings (C4459/C4702/C5267).FetchContentquickstart docs.OSS consumers
NVIDIA/cuda-quantumNVIDIA/cuda-quantumreflect-cppinside a multi-compiler CMake build with strict warning/linter policies.nvidia-holoscan/holoscan-sdknvidia-holoscan/holoscan-sdkvcpkgoverrides.FANUC-CORPORATION/fanuc_driverFANUC-CORPORATION/fanuc_driverament_cmake) consumer on CMake 3.22 needing subproject-safeament_package()scoping.For Agents
upstream-queue(f93d1a18) · Score67+/100(post-polish) ·+461/-154(7f)