Repository navigation
Conversation
…_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).
|
The following sections might be updated with supplementary metadata relevant to reviewers and maintainers. ReviewsSee the guideline and AI policy for information on the review process.
If your review is incorrectly listed, please copy-paste |
hebasto
reviewed
Oct 3, 2026
hebasto
left a comment
Member
There was a problem hiding this comment.
Concept ACK.
For bitcoin/bitcoin#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})
Comment on lines
+130
to
+131
| add_custom_target("${target}_headers_${headers_hash}" DEPENDS ${generated_headers}) | ||
| add_dependencies("${target}_headers" "${target}_headers_${headers_hash}") |
Member
There was a problem hiding this comment.
style nit: Quoting here seems unnecessary.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
target_capnp_sourcescreates aTARGET_headerscustom 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 buildingTARGET_headersdoes not generate them.Bitcoin Core runs into this in bitcoin/bitcoin#10102, which adds
wallet.capnptobitcoin_ipcwith a secondtarget_capnp_sourcescall (it is only built with the wallet enabled). The CI iwyu job only builds the*_headerstargets before running IWYU, sowallet.capnp.handwallet.capnp.proxy.hwere 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_headersdepend on it, since dependencies cannot be added to an existing custom target.