|
Some checks failed
CI / build-test-release (push) Failing after 5m36s
Canonical LGPL-3.0-only text, GPL-3.0 companion, SPDX headers on all first-party sources, MIT for examples/. Vendored lib/ untouched. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com> |
||
|---|---|---|
| .. | ||
| mylib | ||
| main.cpp | ||
| project.cpp | ||
| README.md | ||
library
A static library + an executable that consumes it.
cd examples/library
crafter-build
./bin/math-app-x86_64-pc-linux-gnu-native/math-app
Layout:
mylib/MyMath.cppm # the library's module interface
main.cpp # the consumer
project.cpp # declares both, with cfg.dependencies wiring them
Two Configuration objects: a LibraryStatic and an Executable whose dependencies points at the lib. The build runs them in parallel and links libMyMath.a into math-app automatically. import MyMath; in main.cpp resolves through the dep graph — no header paths to hand-wire.
The static unique_ptr<Configuration> for the lib is the canonical lifetime pattern: the parent's dependencies is vector<Configuration*> (raw), so something needs to keep the lib alive across the function return. File-local static does it cleanly without a global pool.