Skip to content

cmake: Improve robustness and usability

This PR:

  1. Switches to a modern CMake approach by using the Python3::Interpreter imported target, which is more robust than using variables.

  2. Disables tests instead of ignoring them.

For example:

  • building without Python available:
$ cmake -B build
$ cmake --build build -j 16
$ # ctest --test-dir build -j 16 -R "^util_"
Internal ctest changing into directory: /bitcoin/build
Test project /bitcoin/build
    Start 113: util_tests
    Start 114: util_threadnames_tests
    Start 112: util_string_tests
    Start   1: util_test_runner
1/5 Test   #1: util_test_runner .................***Not Run (Disabled)   0.00 sec
    Start   2: util_rpcauth_test
2/5 Test   #2: util_rpcauth_test ................***Not Run (Disabled)   0.00 sec
3/5 Test #112: util_string_tests ................   Passed    0.01 sec
4/5 Test #114: util_threadnames_tests ...........   Passed    0.01 sec
5/5 Test #113: util_tests .......................   Passed    0.13 sec

100% tests passed, 0 tests failed out of 3

Total Test time (real) =   0.13 sec

The following tests did not run:
	  1 - util_test_runner (Disabled)
	  2 - util_rpcauth_test (Disabled)
  • building without bitcoin-tx:
$ cmake -B build -DBUILD_TX=OFF
$ cmake --build build -j 16
$ ctest --test-dir build -j 16 -R "^util_"
Internal ctest changing into directory: /bitcoin/build
Test project /bitcoin/build
    Start   1: util_test_runner
1/5 Test   #1: util_test_runner .................***Not Run (Disabled)   0.00 sec
    Start   2: util_rpcauth_test
    Start 112: util_string_tests
    Start 113: util_tests
    Start 114: util_threadnames_tests
2/5 Test #112: util_string_tests ................   Passed    0.01 sec
3/5 Test #114: util_threadnames_tests ...........   Passed    0.01 sec
4/5 Test   #2: util_rpcauth_test ................   Passed    0.06 sec
5/5 Test #113: util_tests .......................   Passed    0.13 sec

100% tests passed, 0 tests failed out of 4

Total Test time (real) =   0.13 sec

The following tests did not run:
	  1 - util_test_runner (Disabled)

Merge request reports

Loading