build: install shell completions via cmake #34721

pull willcl-ark wants to merge 1 commits into bitcoin:master from willcl-ark:cmake-shell-completions changing 2 files +18 −0
  1. willcl-ark commented at 2:33 pm on March 3, 2026: member

    Fixes: #34714

    Packagers currently need to manually copy shell completion scripts from contrib/completions/ into the appropriate system directories.

    Install bash and fish completions alongside their corresponding binaries as part of install_binary_component(), following the same pattern used for man pages. Completion files are automatically detected per component and installed to the standard locations:

    • bash: ${datadir}/bash-completion/completions/
    • fish: ${datadir}/fish/vendor_completions.d/

    Enabled by default. Can be disabled with -DINSTALL_COMPLETIONS=OFF. (This matches INSTALL_MAN default)

  2. build: install shell completions via cmake
    Packagers currently need to manually copy shell completion scripts
    from contrib/completions/ into the appropriate system directories.
    
    Install bash and fish completions alongside their corresponding
    binaries as part of install_binary_component(), following the same
    pattern used for man pages. Completion files are automatically
    detected per component and installed to the standard locations:
    - bash: ${datadir}/bash-completion/completions/
    - fish: ${datadir}/fish/vendor_completions.d/
    
    Enabled by default. Can be disabled with -DINSTALL_COMPLETIONS=OFF.
    0a2d2cd116
  3. DrahtBot added the label Build system on Mar 3, 2026
  4. DrahtBot commented at 2:33 pm on March 3, 2026: contributor

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

    Reviews

    See the guideline for information on the review process.

    Type Reviewers
    Concept ACK w0xlt, hebasto, caesrcd, BrandonOdiwuor

    If your review is incorrectly listed, please copy-paste <!–meta-tag:bot-skip–> into the comment that the bot should ignore.

  5. kpcyrd commented at 3:28 pm on March 3, 2026: none
    I tested this patch and it works well for me :smiley_cat:
  6. DrahtBot added the label CI failed on Mar 3, 2026
  7. w0xlt commented at 3:52 pm on March 3, 2026: contributor
    Concept ACK
  8. hebasto commented at 3:57 pm on March 3, 2026: member
    Concept ACK.
  9. fanquake commented at 4:08 pm on March 3, 2026: member
    Will we start maintaining these, if we plan on installing them? #33747, #33402, #33385. There doesn’t seem to be any interest historically from contributors.
  10. DrahtBot removed the label CI failed on Mar 3, 2026
  11. willcl-ark commented at 11:45 am on March 4, 2026: member

    Will we start maintaining these, if we plan on installing them?

    Fair shout. The alternative is to not maintain them and but to then also not ship them at all. My preference would be to maintain and install them.

    I have reviewed #33385 as I think this looks in the best shape to move forward, barring author response time.

  12. caesrcd commented at 6:30 pm on March 4, 2026: none
    Concept ACK
  13. in CMakeLists.txt:180 in 0a2d2cd116
    176@@ -177,6 +177,7 @@ option(BUILD_FUZZ_BINARY "Build fuzz binary." OFF)
    177 option(BUILD_FOR_FUZZING "Build for fuzzing. Enabling this will disable all other targets and override BUILD_FUZZ_BINARY." OFF)
    178 
    179 option(INSTALL_MAN "Install man pages." ON)
    180+option(INSTALL_COMPLETIONS "Install shell completion scripts." ON)
    


    luke-jr commented at 7:09 am on March 10, 2026:
    Users are at least somewhat unlikely to use multiple shells, so it probably makes sense to have a separate option for each one
  14. purpleKarrot commented at 9:45 am on March 10, 2026: contributor

    I don’t like the direction the install_binary_component command is evolving. My concerns are:

    • if(EXISTS ${...}): The problem is that adding a file may change the behavior of install, but only after cmake was manually rerun. Adding the file will not trigger the reconfiguration by itself. This leads to flakiness (similar to file(GLOB)). CMakeLists.txt files should always explicitly describe the source tree. Things like if(EXISTS) and file(GLOB) should be reserved for cmake -P scripts.

    • option(INSTALL_COMPLETIONS): This is a build option, that does not affect the build, hence the wrong tool for the job (so is INSTALL_MAN). Better: Use fine grained install components, to let the user decide at install time what to install. The 1:1 relationship of target and component is not helpful.

    The whole install_binary_component command should be inlined at the call sites and then removed. This makes the CMakeLists.txt much more declarative:

    • For targets that are installed to the default location, don’t specify the location but use the default.
    • For targets that have manpages and shell completions, install them. For targets that don’t, just don’t.

    Any “convenience” wrapper should be killed before it attracts more and more responsibilities.

  15. BrandonOdiwuor commented at 8:23 am on March 11, 2026: contributor

    Concept ACK

    Installing shell completions automatically with cmake --install is more convenient. Tested on Ubuntu 24.04 with bash.

    –prefix and –component install


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: 2026-03-30 18:13 UTC

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