GNUInstallDirs: Fix regression on -DCMAKE_INSTALL_<dir>=<default>

In commit 42dfcbf1a5 (GNUInstallDirs: Refactor LIBDIR default
calculation, 2025-03-27, v4.1.0-rc1~384^2~2) we introduced the
`_GNUInstallDirs_LIBDIR_get_default` helper and exercised code from
commit 9789f7d05e (GNUInstallDirs: Add internal helper to compute
specific defaults, 2025-03-28, v4.1.0-rc1~384^2~3) for the first time.
Fix the latter's code to update the `CMAKE_INSTALL_<dir>` cache entry
without triggering conversion of a relative path to an absolute path.

Fixes: #27027
This commit is contained in:
Brad King
2025-07-01 14:19:50 -04:00
parent 49120bbf2b
commit 5071c93a78
4 changed files with 31 additions and 1 deletions
+4 -1
View File
@@ -279,7 +279,10 @@ function(_GNUInstallDirs_cache_path var description)
# the old default, reset the value to the new default
if(${cmake_install_var} STREQUAL "$CACHE{${cmake_install_var}}"
AND ${cmake_install_var} STREQUAL last_default)
set(${cmake_install_var} "${default}" CACHE PATH "${full_description}" FORCE)
set(full_description "${description} (${default})")
set_property(CACHE ${cmake_install_var} PROPERTY TYPE PATH)
set_property(CACHE ${cmake_install_var} PROPERTY VALUE "${default}")
set_property(CACHE ${cmake_install_var} PROPERTY HELPSTRING "${full_description}")
endif()
# Continue to normal flow
endif()