Skip to content

cmake: Add `--prefix` option to set CMAKE_INSTALL_PREFIX

Classically the primary way of specifying the install directory is via CMAKE_INSTALL_PREFIX. With the introduction of cmake --install we added --prefix to override the existing CMAKE_INSTALL_PREFIX.

My proposal is to do the following:

  • Extend cmake to support the command line flag --prefix which would map to CMAKE_INSTALL_PREFIX. This would unify cmake and cmake --install.
  • Extend configurePresets to support installDir which would be the preset high level key for specifying the install dir.

I am happy to be the implementer of this proposal :)

Note:

  • When both --prefix and -DCMAKE_INSTALL_PREFIX are specified, I propose CMake uses the last specified value. Which maps to the current behavior of specifying a cache variable twice (IIRC).

  • I think we should have the same discussion around offering --toolchain and a preset variable for it as well.

Edited by Brad King
To upload designs, you'll need to enable LFS and have an admin enable hashed storage. More information