Skip to content

Make generated CMake projects consumable via FetchContent - #9

Merged
bluesentinelsec merged 1 commit into
mainfrom
feature/cmake-consumable
Jul 27, 2026
Merged

Make generated CMake projects consumable via FetchContent#9
bluesentinelsec merged 1 commit into
mainfrom
feature/cmake-consumable

Conversation

@bluesentinelsec

Copy link
Copy Markdown
Owner

Summary

  • Detect when a generated project is top-level vs embedded (IS_TOP_LEVEL) so add_subdirectory / FetchContent only build the library by default (app, tests, benchmarks, and app deps off unless opted in).
  • Stop linking CLI11 / nlohmann/json / spdlog onto the static library (they stay on the app) so install(EXPORT) / find_package do not require third-party targets.
  • Emit ${name}Config.cmake + install(EXPORT) package config, dual aliases (::lib and ::${target}), and README docs for all three consumption modes.
  • Integration test asserts consumability markers in generated CMake/README.

Proven end-to-end

Bootstrapped a calc-like package with cppboot, pushed to GitHub, and verified a local consumer with:

  • add_subdirectory
  • FetchContent
  • find_package after install

Smoke repo was deleted after proof. 60 unit/integration tests pass.

Test plan

  • pytest (60 passed)
  • Manual: generate lib → FetchContent + add_subdirectory + install/find_package from a host app
  • CI green on this PR

Detect top-level vs embed so add_subdirectory/FetchContent only build the
library by default. Move CLI/JSON/spdlog onto the app, export package
config for find_package, and document the three consumption paths.
@bluesentinelsec
bluesentinelsec merged commit 91b399a into main Jul 27, 2026
11 checks passed
@bluesentinelsec
bluesentinelsec deleted the feature/cmake-consumable branch July 27, 2026 21:55
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant