We can use a subtree split to export only a subset of this repository to downstream projects. The only thing we need to do is publish and maintain a branch, e.g. lib, generated as follows:
git subtree split --prefix=lib -b lib
I published such a branch here: https://github.com/Sjors/libmultiprocess/commits/lib/
Commits that don't touch the prefix directory are skipped entirely. Others are stripped of content outside the prefix. This of course breaks PGP signatures, but the lib branch commits are deterministically generated. On the Bitcoin Core side I plan to update the subtree linter to verify this.
Because we can only export one directory, this PR moves the following library sources to lib/:
- CMakeLists.txt
- cmake
- include
- pkgconfig
- src
- test
This leaves examples, documentation and CI outside the export. Tests could be moved out as well, but it seems useful to offer downstream projects an easy way to run these tests as part of their own CI.
A new top-level CMakeLists.txt wrapper preserves 'cmake -S .' for standalone builds; this is also the only way to build the example/ subdirectory. See comments in CMakeLists.txt and lib/CMakeLists.txt for details on how lib/ adapts between the two build modes. This can use some CMake expertise eyes. Most of the existing CMakeList.txt content is simply moved, so it's best reviewed with --color-moved=dimmed-zebra.
Commit 66d7b4871d47e77e89c80cb691436f4f86974971 can be avoided if we drop examples from cmake/libmultiprocess.cmake in Bitcoin Core in a separate PR first.
Bitcoin Core side: https://github.com/Sjors/bitcoin/pull/113 (will upstream later)
Fixes #232