Skip to content

Remove useless "install" from CMake #36588

Description

@alexey-milovidov

Step 1: remove useless "install" directives. Examples:

Apr 22 06:07:27 [41/42] Install the project...
Apr 22 06:07:27 -- Install configuration: "RelWithDebInfo"
Apr 22 06:07:27 -- Installing: /build/packages/root/usr/lib/libglibc-compatibility.a
Apr 22 06:07:27 -- Installing: /build/packages/root/usr/lib/libmemcpy.a
Apr 22 06:07:27 -- Installing: /build/packages/root/usr/lib/libharmful.a
Apr 22 06:07:27 -- Installing: /build/packages/root/usr/lib/libunwind.a
Apr 22 06:07:27 -- Installing: /build/packages/root/usr/lib/libcxxabi.a
Apr 22 06:07:27 -- Installing: /build/packages/root/usr/lib/libcxx.a
Apr 22 06:07:27 -- Installing: /build/packages/root/usr/cmake/global.cmake
Apr 22 06:07:27 -- Installing: /build/packages/root/usr/cmake/global-relwithdebinfo.cmake
Apr 22 06:07:27 -- Installing: /build/packages/root/etc/clickhouse-server/config.xml
Apr 22 06:07:27 -- Installing: /build/packages/root/etc/clickhouse-server/users.xml
Apr 22 06:07:27 -- Installing: /build/packages/root/etc/clickhouse-client/config.xml
Apr 22 06:07:27 -- Installing: /build/packages/root/usr/share/bash-completion/completions/clickhouse-bootstrap
Apr 22 06:07:27 -- Installing: /build/packages/root/usr/share/bash-completion/completions/clickhouse-client
Apr 22 06:07:27 -- Installing: /build/packages/root/usr/share/bash-completion/completions/clickhouse-local
Apr 22 06:07:27 -- Installing: /build/packages/root/usr/share/bash-completion/completions/clickhouse-benchmark
Apr 22 06:07:27 -- Installing: /build/packages/root/usr/share/bash-completion/completions/clickhouse
Apr 22 06:07:27 -- Installing: /build/packages/root/etc/clickhouse-keeper/keeper_config.xml
Apr 22 06:07:27 -- Installing: /build/packages/root/usr/bin/clickhouse-keeper
Apr 22 06:07:27 -- Installing: /build/packages/root/usr/lib/debug/usr/bin/clickhouse-keeper.debug/clickhouse-keeper.debug
Apr 22 06:07:27 -- Installing: /build/packages/root/usr/bin/clickhouse-odbc-bridge
Apr 22 06:07:27 -- Installing: /build/packages/root/usr/lib/debug/usr/bin/clickhouse-odbc-bridge.debug/clickhouse-odbc-bridge.debug
Apr 22 06:07:27 -- Installing: /build/packages/root/usr/bin/clickhouse-library-bridge
Apr 22 06:07:28 -- Installing: /build/packages/root/usr/lib/debug/usr/bin/clickhouse-library-bridge.debug/clickhouse-library-bridge.debug
Apr 22 06:07:28 -- Installing: /build/packages/root/usr/bin/clickhouse-server
Apr 22 06:07:28 -- Installing: /build/packages/root/usr/bin/clickhouse-client
Apr 22 06:07:28 -- Installing: /build/packages/root/usr/bin/clickhouse-local
Apr 22 06:07:28 -- Installing: /build/packages/root/usr/bin/clickhouse-benchmark
Apr 22 06:07:28 -- Installing: /build/packages/root/usr/bin/clickhouse-copier
Apr 22 06:07:28 -- Installing: /build/packages/root/usr/bin/clickhouse-extract-from-config
Apr 22 06:07:28 -- Installing: /build/packages/root/usr/bin/clickhouse-compressor
Apr 22 06:07:28 -- Installing: /build/packages/root/usr/bin/clickhouse-format
Apr 22 06:07:28 -- Installing: /build/packages/root/usr/bin/clickhouse-obfuscator
Apr 22 06:07:28 -- Installing: /build/packages/root/usr/bin/clickhouse-git-import
Apr 22 06:07:28 -- Installing: /build/packages/root/usr/bin/clickhouse-static-files-disk-uploader
Apr 22 06:07:28 -- Installing: /build/packages/root/usr/bin/clickhouse-keeper-converter
Apr 22 06:07:28 -- Installing: /build/packages/root/usr/bin/clickhouse
Apr 22 06:07:28 -- Installing: /build/packages/root/usr/lib/debug/usr/bin/clickhouse.debug/clickhouse.debug
Apr 22 06:07:29 -- Installing: /build/packages/root/usr/bin/clickhouse-report
Apr 22 06:07:29 + bash -x /build/packages/build

Step 2: don't use "install" from CMake at all.

Motivation:

The "install" feature from CMake is intended for installation of the built project to the system. It does not make sense for ClickHouse, because CMake is not being able to correctly install it. Nevertheless, it has been used to copy some files to some subdirectories before converting these subdirectories to packages. It was used when "debian" packages infrastructure was used. We don't use it anymore, so the "install" feature of CMake appeared almost useless. The risk of misunderstanding this feature by developers and the risk of accumulation of garbage remains. A second point is that CMake is very complex piece of technology, and it is reasonable to use it as little as possible, avoiding most of the features. We already get rid of most of its features like "find_library", because we are using hermetic builds. This will also help to switch to different build systems (like Bazel) more easily, anticipating the trend that CMake will become less and less relevant.

Version info

Activity

  1. alexey-milovidov commented on Apr 24, 2022

    @alexey-milovidov
    MemberAuthor

    Here we can replace temporary "install" directory to the build directory:

    $ grep -F 'src: ' *.yaml
    clickhouse-client.yaml:- src: root/etc/clickhouse-client/config.xml
    clickhouse-client.yaml:- src: root/usr/bin/clickhouse-benchmark
    clickhouse-client.yaml:- src: root/usr/bin/clickhouse-compressor
    clickhouse-client.yaml:- src: root/usr/bin/clickhouse-format
    clickhouse-client.yaml:- src: root/usr/bin/clickhouse-client
    clickhouse-client.yaml:- src: root/usr/bin/clickhouse-local
    clickhouse-client.yaml:- src: root/usr/bin/clickhouse-obfuscator
    clickhouse-client.yaml:- src: ../AUTHORS
    clickhouse-client.yaml:- src: ../CHANGELOG.md
    clickhouse-client.yaml:- src: ../LICENSE
    clickhouse-client.yaml:- src: ../README.md
    clickhouse-common-static-dbg.yaml:- src: root/usr/lib/debug/usr/bin/clickhouse.debug
    clickhouse-common-static-dbg.yaml:- src: root/usr/lib/debug/usr/bin/clickhouse-odbc-bridge.debug
    clickhouse-common-static-dbg.yaml:- src: root/usr/lib/debug/usr/bin/clickhouse-library-bridge.debug
    clickhouse-common-static-dbg.yaml:- src: ../AUTHORS
    clickhouse-common-static-dbg.yaml:- src: ../CHANGELOG.md
    clickhouse-common-static-dbg.yaml:- src: ../LICENSE
    clickhouse-common-static-dbg.yaml:- src: ../README.md
    clickhouse-common-static.yaml:- src: root/usr/bin/clickhouse
    clickhouse-common-static.yaml:- src: root/usr/bin/clickhouse-odbc-bridge
    clickhouse-common-static.yaml:- src: root/usr/bin/clickhouse-library-bridge
    clickhouse-common-static.yaml:- src: root/usr/bin/clickhouse-extract-from-config
    clickhouse-common-static.yaml:- src: root/usr/share/bash-completion/completions
    clickhouse-common-static.yaml:- src: ../AUTHORS
    clickhouse-common-static.yaml:- src: ../CHANGELOG.md
    clickhouse-common-static.yaml:- src: ../LICENSE
    clickhouse-common-static.yaml:- src: ../README.md
    clickhouse-keeper-dbg.yaml:- src: root/usr/lib/debug/usr/bin/clickhouse-keeper.debug
    clickhouse-keeper-dbg.yaml:- src: ../AUTHORS
    clickhouse-keeper-dbg.yaml:- src: ../CHANGELOG.md
    clickhouse-keeper-dbg.yaml:- src: ../LICENSE
    clickhouse-keeper-dbg.yaml:- src: ../README.md
    clickhouse-keeper.yaml:- src: root/etc/clickhouse-keeper
    clickhouse-keeper.yaml:- src: root/usr/bin/clickhouse-keeper
    clickhouse-keeper.yaml:- src: ../AUTHORS
    clickhouse-keeper.yaml:- src: ../CHANGELOG.md
    clickhouse-keeper.yaml:- src: ../LICENSE
    clickhouse-keeper.yaml:- src: ../README.md
    clickhouse-server.yaml:- src: root/etc/clickhouse-server
    clickhouse-server.yaml:- src: clickhouse-server.init
    clickhouse-server.yaml:- src: clickhouse-server.service
    clickhouse-server.yaml:- src: root/usr/bin/clickhouse-copier
    clickhouse-server.yaml:- src: clickhouse
    clickhouse-server.yaml:- src: root/usr/bin/clickhouse-report
    clickhouse-server.yaml:- src: root/usr/bin/clickhouse-server
    clickhouse-server.yaml:- src: ../AUTHORS
    clickhouse-server.yaml:- src: ../CHANGELOG.md
    clickhouse-server.yaml:- src: ../LICENSE
    clickhouse-server.yaml:- src: ../README.md
    
  2. alexey-milovidov commented on Apr 29, 2026

    @alexey-milovidov
    MemberAuthor

    @groeneai, implement this change.

  3. groeneai commented on Apr 29, 2026

    @groeneai
    Collaborator

    @alexey-milovidov — audit complete, posting findings before opening PRs.

    Step 1 status: largely already done

    The static-library installs from the issue body (libglibc-compatibility.a, libmemcpy.a, libharmful.a, libunwind.a, libcxxabi.a, libcxx.a) and the cmake/global*.cmake files no longer have any install() directives. Verified by inspecting the generated cmake_install.cmake for contrib/libcxx-cmake, contrib/libcxxabi-cmake, contrib/libunwind-cmake, base/glibc-compatibility, base/harmful — they are all empty boilerplate. So the example output in the issue body is from 2022 and the obvious cleanup has happened over the years.

    Remaining first-party install() footprint

    File Lines What it installs
    programs/CMakeLists.txt 157, 164, 205, 216, 221, 263, 282, 297 Multi-call subcommand symlinks, the main clickhouse binary (when SPLIT_DEBUG_SYMBOLS=OFF), Google protobuf .proto files, chdig dummy fallbacks
    programs/server/CMakeLists.txt 34 config.xml, users.xml
    programs/client/CMakeLists.txt 33 clickhouse-client.xml (renamed to config.xml)
    programs/keeper/CMakeLists.txt 24, 37, 42 keeper_config.xml, standalone clickhouse-keeper binary, clickhouse-keeper-client symlink
    programs/bash-completion/completions/CMakeLists.txt 28 bash-completion scripts
    cmake/split_debug_symbols.cmake 34, 36, 61 Stripped binary + .debug symbol files for nfpm

    Orphan installs (Step 1.5 candidate)

    programs/CMakeLists.txt calls clickhouse_program_install(...) for several subcommands whose symlinks land in build/packages/root/usr/bin/ but are not referenced by any packaging YAML, so they get dropped at the nfpm step — pure wasted I/O:

    clickhouse-check-marks, clickhouse-checksum-for-compressed-block, clickhouse-disks, clickhouse-docker-init, clickhouse-git-import, clickhouse-static-files-disk-uploader, clickhouse-su, clickhouse-zookeeper-dump-tree, clickhouse-zookeeper-remove-by-list, clickhouse-keeper-data-dumper, clickhouse-keeper-utils, clickhouse-keeper-bench.

    (Cross-checked packages/*.yaml — none of these names appear.) Users still invoke them as clickhouse <subcommand> on the multi-call binary; only the standalone aliases are unused.

    Proposed plan — three small PRs

    1. Step 1.5: Drop orphan installs. Split clickhouse_program_install into a _link-only variant for non-packaged subcommands. Keeps the symlink in the build directory (handy for dev) but skips the wasted install(FILES …). Mechanical, low-risk.

    2. Step 2a: Replace install() of static source files with direct YAML paths. config.xml, users.xml, clickhouse-client.xml, keeper_config.xml, the bash completions, and the protobuf .proto files are already in the source tree — packaging YAMLs can point at them directly under the repo root. Removes 5 of the remaining 17 install() callsites without touching the build flow.

    3. Step 2b: Replace install() of build artifacts with direct YAML paths. The main clickhouse binary, multi-call symlinks, standalone keeper, and split-debug .debug files. Packaging YAMLs point into build/programs/. The CI script (ci/jobs/build_clickhouse.py:312 runs ninja programs/install with DESTDIR=root) becomes a no-op step that can be deleted alongside the install() removals. Bigger refactor — touches the build matrix and packaging flow.

    I'll open Step 1.5 first as the safest mechanical change, verify a clean build + packaging round-trip locally, and then iterate on Step 2a / 2b. If you'd prefer a single combined PR or a different order, happy to adjust.

  4. added
    comp-build-system
    on Sep 4, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    buildcomp-build-system

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions