Conversation
#312 introduced a CMAKE_SOURCE_DIR STREQUAL PROJECT_SOURCE_DIR check to skip installing pkgconfig files when Graaf is consumed via FetchContent. CMake 3.21+ exposes this as PROJECT_IS_TOP_LEVEL directly; since this project's floor is 3.11, define it ourselves when CMake doesn't. Same behavior, clearer intent, and reusable for future top-level-only logic.
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #348 +/- ##
=======================================
Coverage 99.58% 99.58%
=======================================
Files 59 59
Lines 2622 2622
Branches 136 136
=======================================
Hits 2611 2611
Misses 11 11 ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
|
Closing this — on reflection there's a real gap: my verification only ran on CMake 4.4.3, so the CMake<3.21 fallback branch (guarded by |
Why
#312 fixed the FetchContent crash from #310 by skipping the pkgconfig install block unless Graaf is the top-level project, via
CMAKE_SOURCE_DIR STREQUAL PROJECT_SOURCE_DIR. CMake 3.21+ exposes exactly this as the built-inPROJECT_IS_TOP_LEVELvariable, which is clearer and self-documenting -- but this project's floor is CMake 3.11, so it isn't guaranteed to be defined.What Changed
Defines
PROJECT_IS_TOP_LEVELourselves (matching CMake's own semantics) when it isn't already set by CMake, and uses it for the pkgconfig guard instead of the raw path comparison. No behavior change; same guard, clearer name, and reusable if more top-level-only logic gets added later.Verification
Built and installed locally in both scenarios:
graaf.pcis still generated and installed..pcfile is generated (matching Fix FetchContent following 2a4715ff46a25048e06078ea20afc325d59f987a #312's intended behavior), headers still install correctly.