1
0
mirror of https://github.com/Kitware/CMake.git synced 2025-10-15 20:46:37 +08:00

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

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()

View File

@@ -0,0 +1,6 @@
-- CMAKE_INSTALL_BINDIR='bin'
-- CMAKE_INSTALL_INCLUDEDIR='include'
-- CMAKE_INSTALL_LIBDIR='lib'
-- CMAKE_INSTALL_FULL_BINDIR='/usr/local/bin'
-- CMAKE_INSTALL_FULL_INCLUDEDIR='/usr/local/include'
-- CMAKE_INSTALL_FULL_LIBDIR='/usr/local/lib'

View File

@@ -0,0 +1,15 @@
set(CMAKE_SIZEOF_VOID_P 8)
set(CMAKE_LIBRARY_ARCHITECTURE "arch")
set(CMAKE_INSTALL_PREFIX "/usr/local")
include(GNUInstallDirs)
set(dirs
BINDIR
INCLUDEDIR
LIBDIR
)
foreach(dir ${dirs})
message(STATUS "CMAKE_INSTALL_${dir}='$CACHE{CMAKE_INSTALL_${dir}}'")
endforeach()
foreach(dir ${dirs})
message(STATUS "CMAKE_INSTALL_FULL_${dir}='${CMAKE_INSTALL_FULL_${dir}}'")
endforeach()

View File

@@ -39,3 +39,9 @@ endblock()
run_cmake(GetAbs)
run_cmake(NoSystem)
run_cmake_with_options(ExplicitDefaults
-DCMAKE_INSTALL_BINDIR=bin
-DCMAKE_INSTALL_INCLUDEDIR=include
-DCMAKE_INSTALL_LIBDIR=lib
)