The codebase, which is compiled, consists of both files in the source tree and additional files generated during the build process. These generated files include headers such as bitcoin-build-config.h
, headers generated for tests and benchmarks from data files, and files produced by Qt’s tools, such as moc
, rcc
and uic
.
When using Makefile or Ninja generators, CMake 3.31 and later provides a convenient builtin build target codegen
, which builds all generated files. For example:
0$ cmake -B build -DCMAKE_GENERATOR="Ninja"
1$ cmake --build build --target codegen
or
0$ cmake -B build -DCMAKE_GENERATOR="Unix Makefiles"
1$ cmake --build build --target codegen
However, when building with -DBUILD_GUI=ON
, setting the CMAKE_{AUTOMOC,RCC,UIC}
variables globally introduces undesired dependencies for Makefiles generators, resulting in building dependencies directly unrelated to the generated files.
This PR resolves that issue. The first commit refactors the build system by factoring out the main library from the test_bitcoin-qt
executable, just as is already done for bitcoinqt
and bitcoin-qt
, and prepares the ground for the second commit.