cmake: Add libbitcoinkernel target #31869

pull hebasto wants to merge 2 commits into bitcoin:master from hebasto:250214-synonym changing 1 files +9 −5
  1. hebasto commented at 5:09 pm on February 14, 2025: member

    This PR amends #31844 by:

    1. Adding a convenience libbitcoinkernel target as a synonym for bitcoinkernel.
    2. Renaming the bitcoinkernel component to libbitcoinkernel, as initially intended in #31844

    Here is an example of usage:

    0cmake -B build -DBUILD_UTIL_CHAINSTATE=ON
    1cmake --build build --target libbitcoinkernel
    2cmake --install build --component libbitcoinkernel
    
  2. cmake: Add `libbitcoinkernel` target
    This is a convenience target as a synonym for `bitcoinkernel`.
    7ce09a5992
  3. cmake: Rename `bitcoinkernel` component to `libbitcoinkernel`
    The new component name is more convenient for the library and aligns
    with the `libbitcoinkernel` target introduced in the previous commit.
    3a914ab96b
  4. DrahtBot commented at 5:09 pm on February 14, 2025: 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/31869.

    Reviews

    See the guideline for information on the review process.

    Type Reviewers
    ACK theuni, s373nZ, TheCharlatan, BrandonOdiwuor

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

    Conflicts

    Reviewers, this pull request conflicts with the following ones:

    • #31884 (cmake: Make implicit libbitcoinkernel dependencies explicit by hebasto)

    If you consider this pull request important, please also help to review the conflicting pull requests. Ideally, start with the one that should be merged first.

  5. DrahtBot added the label Build system on Feb 14, 2025
  6. theuni approved
  7. theuni commented at 8:55 pm on February 14, 2025: member

    ACK 3a914ab96bdeb70cdf848dd74deda5a80d0a7f78

    Tested working as intended. Building/installing both targets works identically, no unnecessary rebuilds or installs either way.

    Thanks hebasto!

  8. fanquake added this to the milestone 29.0 on Feb 15, 2025
  9. fanquake requested review from TheCharlatan on Feb 15, 2025
  10. s373nZ commented at 2:58 pm on February 16, 2025: none

    ACK https://github.com/bitcoin/bitcoin/commit/3a914ab96bdeb70cdf848dd74deda5a80d0a7f78

    Tested compilation as per the usage example in the description with the same results – no rebuild between targets libbitcoinkernel and bitcoinkernel. Kernel library is installable via --component libbitcoinkernel, but --component bitcoinkernel is not recognized. Works as expected.

    While testing, I learned to generate with a clean build directory, or pass --fresh so that -DBUILD_KERNEL_LIB didn’t preserve the cached default value from -DBUILD_UTIL_CHAINSTATE of the last build.

  11. TheCharlatan approved
  12. TheCharlatan commented at 5:37 pm on February 16, 2025: contributor
    ACK 3a914ab96bdeb70cdf848dd74deda5a80d0a7f78
  13. in src/kernel/CMakeLists.txt:137 in 3a914ab96b
    134-install(FILES ${PROJECT_BINARY_DIR}/libbitcoinkernel.pc DESTINATION "${CMAKE_INSTALL_LIBDIR}/pkgconfig" COMPONENT bitcoinkernel)
    135+install(FILES ${PROJECT_BINARY_DIR}/libbitcoinkernel.pc DESTINATION "${CMAKE_INSTALL_LIBDIR}/pkgconfig" COMPONENT libbitcoinkernel)
    136+
    137+# Add a convenience libbitcoinkernel target as a synonym for bitcoinkernel.
    138+add_custom_target(libbitcoinkernel)
    139+add_dependencies(libbitcoinkernel bitcoinkernel)
    


    purpleKarrot commented at 8:50 pm on February 16, 2025:

    Synonyms can be created like this

    0add_library(libbitcoinkernel ALIAS bitcoinkernel)
    

    By the way, you can increase robustness by adding a namespace to the alias target:

    0add_library(Bitcoin::Kernel ALIAS bitcoinkernel)
    

    This is more robust against typos. Linking against Bitcorn::Kernel will result in a “no such target defined” error at configure time, while linking against bitcornkernel will simply result in -lbitcornkernel being passed to the linker.


    hebasto commented at 9:45 pm on February 16, 2025:

    Synonyms can be created like this

    0add_library(libbitcoinkernel ALIAS bitcoinkernel)
    

    Indeed, that was my starting point. However, an ALIAS library cannot be built:

    0$ cmake -B build -G "Unix Makefiles" -DBUILD_KERNEL_LIB=ON
    1$ cmake --build build -t libbitcoinkernel
    2gmake: *** No rule to make target 'libbitcoinkernel'.  Stop.
    

    or

    0$ cmake -B build -G "Ninja" -DBUILD_KERNEL_LIB=ON
    1$ cmake --build build -t libbitcoinkernel
    2ninja: error: unknown target 'libbitcoinkernel', did you mean 'libbitcoinkernel.so'?
    
  14. BrandonOdiwuor commented at 1:25 pm on February 17, 2025: contributor
    Tested ACK 3a914ab96bdeb70cdf848dd74deda5a80d0a7f78
  15. fanquake merged this on Feb 17, 2025
  16. fanquake closed this on Feb 17, 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-02-22 06:12 UTC

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