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-03-25 09:56:59 -04:00
committed by Brad King
parent fd76089631
commit 39a56136a3
54 changed files with 255 additions and 32 deletions

View File

@@ -60,6 +60,11 @@ signatures that specify them. The common options are:
``<dir>`` should be a relative path. An absolute path is allowed,
but not recommended.
.. versionadded:: 4.4
The :ref:`CMD_INSTALL_ABSOLUTE_DESTINATION <CMD_INSTALL_ABSOLUTE_DESTINATION>`
diagnostic can be enabled to warn or error out when an absolute destination
is provided.
When a relative path is given, it is interpreted relative to the value
of the :variable:`CMAKE_INSTALL_PREFIX` variable.
The prefix can be relocated at install time using the ``DESTDIR``