RFC: Support for CMake `codegen` target #284

issue hebasto opened this issue on May 29, 2026
  1. hebasto commented at 9:20 PM on May 29, 2026: member

    CMake allows different approaches for running static analysis tools over a codebase: co-compiling and using a compilation database.

    Bitcoin Core uses the latter. This approach has many benefits: for example, the ability to filter entries, which allows us to maintain a list of sources where IWYU warnings are enforced. When processing the compilation database, IWYU expects to find every source and header. This is not the case when the database is generated solely during the configuration step, as it lacks the headers and sources that will be generated during the subsequent build step.

    Modern CMake provides a way to generate expected headers and sources beforehand using the built-in codegen target. This approach is currently used in the Bitcoin Core IWYU CI job.

    However, the Libmultiprocess project seems inherently incapable of supporting the codegen target. While it is almost trivial to amend add_custom_command in the target_capnp_sources function with the conditional CODEGEN option, doing so is not possible for the capnp_generate_cpp function shipped by libcapnp-dev or similar packages.

    There are several ways we could tackle this issue:

    1. Execute a normal build step: This guarantees that all files will be generated without relying on codegen at all.

    2. Introduce a custom target: We could create a custom target to generate all files beforehand, though this might be challenging.

    3. Use CMake's co-compilation: Switch to the co-compiling approach, though I am unsure about the usability of this method for the CI job.

    4. Alternative solutions: Open to other ideas.

    I am hoping to gather my colleagues' opinions on the best way forward.

  2. hebasto commented at 9:21 PM on May 29, 2026: member
Contributors

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-05-31 17:30 UTC

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