This PR fixes two regressions introduced in #30911.
For example, on the master branch @ 28dec6c5f8bd35ef4e6cb8d7aa3f21b6879acf98:
- first regression:
0$ cmake -B build -G "Ninja" -DBUILD_UTIL_CHAINSTATE=ON -DBUILD_SHARED_LIBS=OFF -DCMAKE_INSTALL_PREFIX=/home/hebasto/INSTALL
1$ cmake --build build -j $(nproc) -t libbitcoinkernel
2$ cmake --install build --component libbitcoinkernel
3- Install configuration: "RelWithDebInfo"
4CMake Error at build/src/kernel/cmake_install.cmake:46 (file):
5 file INSTALL cannot find
6 "/home/hebasto/dev/bitcoin/build/src/crypto/libbitcoin_crypto.a": No such
7 file or directory.
8Call Stack (most recent call first):
9 build/src/cmake_install.cmake:172 (include)
10 build/cmake_install.cmake:57 (include)
- second regression:
0$ cmake -B build -G "Unix Makefiles" -DBUILD_UTIL_CHAINSTATE=ON -DBUILD_SHARED_LIBS=OFF -DCMAKE_INSTALL_PREFIX=/home/hebasto/INSTALL
1$ cmake --build build -j $(nproc) -t libbitcoinkernel
2...
3gmake[3]: *** No rule to make target 'src/CMakeFiles/bitcoin_clientversion.dir/clientversion.cpp.o', needed by 'src/kernel/libbitcoinkernel.a'. Stop.
4gmake[2]: *** [CMakeFiles/Makefile2:1360: src/kernel/CMakeFiles/bitcoinkernel.dir/all] Error 2
5gmake[1]: *** [CMakeFiles/Makefile2:1367: src/kernel/CMakeFiles/bitcoinkernel.dir/rule] Error 2
6gmake: *** [Makefile:647: bitcoinkernel] Error 2
With this PR:
0$ cmake -B build -G "Ninja" -DBUILD_UTIL_CHAINSTATE=ON -DBUILD_SHARED_LIBS=OFF -DCMAKE_INSTALL_PREFIX=/home/hebasto/INSTALL
1$ cmake --build build -j $(nproc) -t libbitcoinkernel
2$ cmake --install build --component libbitcoinkernel
and
0$ cmake -B build -G "Unix Makefiles" -DBUILD_UTIL_CHAINSTATE=ON -DBUILD_SHARED_LIBS=OFF -DCMAKE_INSTALL_PREFIX=/home/hebasto/INSTALL
1$ cmake --build build -j $(nproc) -t libbitcoinkernel
2$ cmake --install build --component libbitcoinkernel
A note for reviewers: An alternative approach would be to disable the OPTIMIZE_DEPENDENCIES
property for the bitcoinkernel
target. However, I contend that this PR is preferable because (1) it preserves parallel builds for the libbitcoinkernel
target, and (2) the resulting code has one less workaround for a CMake bug.