cmake: Improve build script correctness #31357

pull hebasto wants to merge 2 commits into bitcoin:master from hebasto:241123-no-targets changing 1 files +5 −2
  1. hebasto commented at 3:38 pm on November 23, 2024: member

    When no build targets are specified, it is reasonable to expect the configuration step to succeed and produce a build system that does not build any targets.

    This PR updates the code to ensure this behaviour:

    0$ cmake -B build -G "Ninja" -DBUILD_DAEMON=OFF -DBUILD_CLI=OFF -DBUILD_TX=OFF -DBUILD_UTIL=OFF -DENABLE_WALLET=OFF -DBUILD_TESTS=OFF
    1$ cmake --build build
    2ninja: no work to do.
    
  2. cmake: Ensure script correctness when no targets are specified 76a3a540a4
  3. cmake: Build `secp256k1` only when required ab5c63edcc
  4. hebasto added the label Build system on Nov 23, 2024
  5. DrahtBot commented at 3:39 pm on November 23, 2024: contributor

    The following sections might be updated with supplementary metadata relevant to reviewers and maintainers.

    Code Coverage & Benchmarks

    For details see: https://corecheck.dev/bitcoin/bitcoin/pulls/31357.

    Reviews

    See the guideline for information on the review process.

    Type Reviewers
    ACK TheCharlatan, tdb3

    If your review is incorrectly listed, please react with 👎 to this comment and the bot will ignore it on the next update.

  6. hebasto commented at 3:40 pm on November 23, 2024: member

    When no build targets are specified, it is reasonable to expect the configuration step to succeed…

    The issue was reported offline by @TheCharlatan.

  7. sedited approved
  8. sedited commented at 3:55 pm on November 23, 2024: contributor
    ACK ab5c63edccea7957e2c7b3b9d8b04655a7f82f22
  9. tdb3 approved
  10. tdb3 commented at 2:14 am on November 30, 2024: contributor

    light test ACK ab5c63edccea7957e2c7b3b9d8b04655a7f82f22

    On master (dbc8ba12f3b3548dd6955293c5d650320ca39c5b):

    Native (Make)

     0$ cmake -B build -DBUILD_DAEMON=OFF -DBUILD_CLI=OFF -DBUILD_TX=OFF -DBUILD_UTIL=OFF -DENABLE_WALLET=OFF -DBUILD_TESTS=OFF
     1...
     2-- Configuring done
     3CMake Error at src/CMakeLists.txt:289 (target_link_libraries):
     4  Target "bitcoin_node" links to:
     5
     6    libevent::core
     7
     8  but the target was not found.  Possible reasons include:
     9
    10    * There is a typo in the target name.
    11    * A find_package call is missing for an IMPORTED target.
    12    * An ALIAS target is missing.
    
    0$ cmake --build build
    1[100%] Building C object src/secp256k1/src/CMakeFiles/secp256k1_precomputed.dir/precomputed_ecmult.c.o
    2[100%] Building C object src/secp256k1/src/CMakeFiles/secp256k1_precomputed.dir/precomputed_ecmult_gen.c.o
    3[100%] Built target secp256k1_precomputed
    4[100%] Building C object src/secp256k1/src/CMakeFiles/secp256k1.dir/secp256k1.c.o
    5[100%] Linking C static library ../lib/libsecp256k1.a
    6[100%] Built target secp256k1
    

    Ninja

     0$ cmake -B build -G "Ninja" -DBUILD_DAEMON=OFF -DBUILD_CLI=OFF -DBUILD_TX=OFF -DBUILD_UTIL=OFF -DENABLE_WALLET=OFF -DBUILD_TESTS=OFF
     1...
     2-- Configuring done
     3CMake Error at src/CMakeLists.txt:289 (target_link_libraries):
     4  Target "bitcoin_node" links to:
     5
     6    libevent::core
     7
     8  but the target was not found.  Possible reasons include:
     9
    10    * There is a typo in the target name.
    11    * A find_package call is missing for an IMPORTED target.
    12    * An ALIAS target is missing.
    
    0$ cmake --build build
    1ninja: error: loading 'build.ninja': No such file or directory
    

    On PR branch (ab5c63edccea7957e2c7b3b9d8b04655a7f82f22): No error observed when generating the buildsystem (Make or Ninja)

    Make

    0$ cmake --build build
    1<no output>
    

    Ninja

    0$ cmake --build build
    1ninja: no work to do.
    
  11. fanquake merged this on Dec 2, 2024
  12. fanquake closed this on Dec 2, 2024

  13. hebasto deleted the branch on Dec 2, 2024
  14. sedited referenced this in commit bd64a555d7 on Dec 3, 2024
  15. sedited referenced this in commit 15319cfcd5 on Dec 4, 2024
  16. stickies-v referenced this in commit f6b6da7935 on Dec 18, 2024
  17. stickies-v referenced this in commit 6816a65596 on Dec 18, 2024
  18. stickies-v referenced this in commit de777e8ed6 on Dec 18, 2024
  19. bug-castercv502 referenced this in commit c87bcd9110 on Sep 28, 2025
  20. bitcoin locked this on Dec 2, 2025

github-metadata-mirror

This is a metadata mirror of the GitHub repository bitcoin/bitcoin. This site is not affiliated with GitHub. Content is generated from a GitHub metadata backup.
generated: 2025-12-06 18:13 UTC

This site is hosted by @0xB10C
More mirrored repositories can be found on mirror.b10c.me