Diagnostic: Add warn or error on absolute install paths

Add `-Winstall-absolute-destination` diagnostic to warn or
error when an install command has an absolute destination.

This allow projects to enforce the best practice of not allowing
absolute install DESTINATIONS.
This commit is contained in:
Robert Maynard
2026-04-29 09:22:29 -04:00
committed by Brad King
parent fd76089631
commit 39a56136a3
54 changed files with 255 additions and 32 deletions
@@ -8,3 +8,11 @@ The fatal error is emitted before the installation of the offending
file takes place. This variable is used by CMake-generated
``cmake_install.cmake`` scripts. If one sets this variable to ``ON`` while
running the script, it may get fatal error messages from the script.
.. versionadded:: 4.4
The :ref:`CMD_INSTALL_ABSOLUTE_DESTINATION <CMD_INSTALL_ABSOLUTE_DESTINATION>`
diagnostic can be used to to generate errors for absolute install destinations
at generate time.
See also :variable:`CMAKE_WARN_ON_ABSOLUTE_INSTALL_DESTINATION`.
@@ -7,3 +7,11 @@ Ask ``cmake_install.cmake`` script to warn each time a file with absolute
This variable is used by CMake-generated ``cmake_install.cmake`` scripts.
If one sets this variable to ``ON`` while running the script, it may get
warning messages from the script.
.. versionadded:: 4.4
The :ref:`CMD_INSTALL_ABSOLUTE_DESTINATION <CMD_INSTALL_ABSOLUTE_DESTINATION>`
diagnostic can be used to to generate warnings for absolute install destinations
at generate time.
See also :variable:`CMAKE_ERROR_ON_ABSOLUTE_INSTALL_DESTINATION`.