cmake: Include headers from every target_capnp_sources call in TARGET_headers #372

pull ryanofsky wants to merge 1 commits into bitcoin-core:master from ryanofsky:pr/capnphdrs changing 1 files +8 −0
  1. ryanofsky commented at 3:36 AM on October 2, 2026: collaborator

    target_capnp_sources creates a TARGET_headers custom target that other targets can depend on to make sure generated headers exist, but it only creates it on the first call for a target. Headers from later calls for the same target, for example optional schemas or schemas added with a different include prefix, are left out, so building TARGET_headers does not generate them.

    Bitcoin Core runs into this in bitcoin/bitcoin#10102, which adds wallet.capnp to bitcoin_ipc with a second target_capnp_sources call (it is only built with the wallet enabled). The CI iwyu job only builds the *_headers targets before running IWYU, so wallet.capnp.h and wallet.capnp.proxy.h were never generated and files including them failed to compile, which fails the job since bitcoin/bitcoin#36235.

    This PR makes later calls add a helper target for their headers and makes TARGET_headers depend on it, since dependencies cannot be added to an existing custom target.

  2. cmake: Include headers from every target_capnp_sources call in TARGET_headers
    target_capnp_sources creates a TARGET_headers custom target that other
    targets can depend on to make sure generated headers exist, but it only did
    this on the first call for a target. Headers from later calls for the same
    target, for example optional schemas or schemas added with a different
    include prefix, were left out, so building TARGET_headers did not generate
    them.
    
    Bitcoin Core hit this when its multiprocess PR added wallet.capnp to
    bitcoin_ipc with a second call: the CI iwyu job only builds the *_headers
    targets, so wallet.capnp.h and wallet.capnp.proxy.h were never generated and
    files including them failed to compile.
    
    On later calls, add a helper target for that call's headers and make
    TARGET_headers depend on it, since dependencies cannot be added to an
    existing custom target.
    
    This change was written with Claude Opus 5.5 (1M context).
    cdd4fdcc0a
  3. DrahtBot commented at 3:36 AM on October 2, 2026: none

    <!--e57a25ab6845829454e8d69fc972939a-->

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

    <!--021abf342d371248e50ceaed478a90ca-->

    Reviews

    See the guideline and AI policy for information on the review process.

    Type Reviewers
    Concept ACK hebasto

    If your review is incorrectly listed, please copy-paste <code>&lt;!--meta-tag:bot-skip--&gt;</code> into the comment that the bot should ignore.

    <!--5faf32d7da4f0f540f40219e4f7537a3-->

  4. in cmake/TargetCapnpSources.cmake:131 in cdd4fdcc0a
     126 | +    # for example to add optional schemas or schemas with a different include
     127 | +    # prefix. Dependencies can't be added to an existing custom target, so add
     128 | +    # these headers through a helper target that ${target}_headers depends on.
     129 | +    string(MD5 headers_hash "${CMAKE_CURRENT_SOURCE_DIR};${generated_headers}")
     130 | +    add_custom_target("${target}_headers_${headers_hash}" DEPENDS ${generated_headers})
     131 | +    add_dependencies("${target}_headers" "${target}_headers_${headers_hash}")
    


    hebasto commented at 5:21 PM on October 3, 2026:

    style nit: Quoting here seems unnecessary.

  5. hebasto commented at 5:42 PM on October 3, 2026: member

    Concept ACK.

    For https://github.com/bitcoin/bitcoin/pull/10102, which requires CMake >=3.22, the following single line would work:

        target_sources(${target}_headers PRIVATE ${generated_headers})
    

    For CMake <3.20, the following should work:

      if(NOT TARGET ${target}_headers)
        add_custom_target(${target}_headers)
      endif()
      set_property(TARGET ${target}_headers APPEND PROPERTY SOURCES ${generated_headers})
    

github-metadata-mirror

This is a metadata mirror of the GitHub repository bitcoin-core/libmultiprocess. This site is not affiliated with GitHub. Content is generated from a GitHub metadata backup.
generated: 2026-10-08 00:30 UTC

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