mirror of
https://github.com/Kitware/CMake.git
synced 2026-04-26 16:18:43 -05:00
GNUInstallDirs: Fix regression on -DCMAKE_INSTALL_<dir>=<default> in /usr
Fix commit 9789f7d05e (GNUInstallDirs: Add internal helper to compute
specific defaults, 2025-03-28, v4.1.0-rc1~384^2~3) to avoid updating
explicitly-specified cache entries on the first run. Do not reset the
default value until at least the second run, during which we have
`_GNUInstallDirs_LAST_CMAKE_INSTALL_PREFIX` already defined.
Fixes: #27211
This commit is contained in:
@@ -257,15 +257,16 @@ function(_GNUInstallDirs_cache_path var description)
|
|||||||
if(COMMAND _GNUInstallDirs_${var}_get_default)
|
if(COMMAND _GNUInstallDirs_${var}_get_default)
|
||||||
# Check if the current CMAKE_INSTALL_PREFIX is the same as before
|
# Check if the current CMAKE_INSTALL_PREFIX is the same as before
|
||||||
set(install_prefix_is_same TRUE)
|
set(install_prefix_is_same TRUE)
|
||||||
set(last_default "${default}")
|
unset(last_default)
|
||||||
if(NOT DEFINED _GNUInstallDirs_LAST_CMAKE_INSTALL_PREFIX
|
if(DEFINED _GNUInstallDirs_LAST_CMAKE_INSTALL_PREFIX
|
||||||
OR NOT _GNUInstallDirs_LAST_CMAKE_INSTALL_PREFIX STREQUAL CMAKE_INSTALL_PREFIX)
|
AND NOT _GNUInstallDirs_LAST_CMAKE_INSTALL_PREFIX STREQUAL CMAKE_INSTALL_PREFIX)
|
||||||
set(install_prefix_is_same FALSE)
|
set(install_prefix_is_same FALSE)
|
||||||
# Recalculate what the last default would have been
|
# Recalculate what the last default would have been
|
||||||
cmake_language(CALL _GNUInstallDirs_${var}_get_default
|
cmake_language(CALL _GNUInstallDirs_${var}_get_default
|
||||||
last_default
|
last_default
|
||||||
"${_GNUInstallDirs_LAST_CMAKE_INSTALL_PREFIX}")
|
"${_GNUInstallDirs_LAST_CMAKE_INSTALL_PREFIX}")
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
if(DEFINED CACHE{${cmake_install_var}} AND install_prefix_is_same)
|
if(DEFINED CACHE{${cmake_install_var}} AND install_prefix_is_same)
|
||||||
# If the cache variable was already set from a previous run and the
|
# If the cache variable was already set from a previous run and the
|
||||||
# install prefix has not changed, we don't need to do anything
|
# install prefix has not changed, we don't need to do anything
|
||||||
@@ -278,6 +279,7 @@ function(_GNUInstallDirs_cache_path var description)
|
|||||||
# if the current value is the same as the cache value and the same as
|
# if the current value is the same as the cache value and the same as
|
||||||
# the old default, reset the value to the new default
|
# the old default, reset the value to the new default
|
||||||
if(${cmake_install_var} STREQUAL "$CACHE{${cmake_install_var}}"
|
if(${cmake_install_var} STREQUAL "$CACHE{${cmake_install_var}}"
|
||||||
|
AND DEFINED last_default
|
||||||
AND ${cmake_install_var} STREQUAL last_default)
|
AND ${cmake_install_var} STREQUAL last_default)
|
||||||
set(full_description "${description} (${default})")
|
set(full_description "${description} (${default})")
|
||||||
set_property(CACHE ${cmake_install_var} PROPERTY TYPE PATH)
|
set_property(CACHE ${cmake_install_var} PROPERTY TYPE PATH)
|
||||||
|
|||||||
-1
@@ -1,6 +1,5 @@
|
|||||||
set(CMAKE_SIZEOF_VOID_P 8)
|
set(CMAKE_SIZEOF_VOID_P 8)
|
||||||
set(CMAKE_LIBRARY_ARCHITECTURE "arch")
|
set(CMAKE_LIBRARY_ARCHITECTURE "arch")
|
||||||
set(CMAKE_INSTALL_PREFIX "/usr/local")
|
|
||||||
include(GNUInstallDirs)
|
include(GNUInstallDirs)
|
||||||
set(dirs
|
set(dirs
|
||||||
BINDIR
|
BINDIR
|
||||||
@@ -0,0 +1,6 @@
|
|||||||
|
-- CMAKE_INSTALL_BINDIR='bin'
|
||||||
|
-- CMAKE_INSTALL_INCLUDEDIR='include'
|
||||||
|
-- CMAKE_INSTALL_LIBDIR='lib'
|
||||||
|
-- CMAKE_INSTALL_FULL_BINDIR='/opt/bin'
|
||||||
|
-- CMAKE_INSTALL_FULL_INCLUDEDIR='/opt/include'
|
||||||
|
-- CMAKE_INSTALL_FULL_LIBDIR='/opt/lib'
|
||||||
@@ -0,0 +1,2 @@
|
|||||||
|
set(CMAKE_INSTALL_PREFIX "/opt")
|
||||||
|
include(ExplicitDefaults-Common.cmake)
|
||||||
@@ -0,0 +1,6 @@
|
|||||||
|
-- CMAKE_INSTALL_BINDIR='bin'
|
||||||
|
-- CMAKE_INSTALL_INCLUDEDIR='include'
|
||||||
|
-- CMAKE_INSTALL_LIBDIR='lib'
|
||||||
|
-- CMAKE_INSTALL_FULL_BINDIR='/usr/bin'
|
||||||
|
-- CMAKE_INSTALL_FULL_INCLUDEDIR='/usr/include'
|
||||||
|
-- CMAKE_INSTALL_FULL_LIBDIR='/usr/lib'
|
||||||
@@ -0,0 +1,2 @@
|
|||||||
|
set(CMAKE_INSTALL_PREFIX "/")
|
||||||
|
include(ExplicitDefaults-Common.cmake)
|
||||||
@@ -0,0 +1,6 @@
|
|||||||
|
-- CMAKE_INSTALL_BINDIR='bin'
|
||||||
|
-- CMAKE_INSTALL_INCLUDEDIR='include'
|
||||||
|
-- CMAKE_INSTALL_LIBDIR='lib'
|
||||||
|
-- CMAKE_INSTALL_FULL_BINDIR='/usr/bin'
|
||||||
|
-- CMAKE_INSTALL_FULL_INCLUDEDIR='/usr/include'
|
||||||
|
-- CMAKE_INSTALL_FULL_LIBDIR='/usr/lib'
|
||||||
@@ -0,0 +1,2 @@
|
|||||||
|
set(CMAKE_INSTALL_PREFIX "/usr")
|
||||||
|
include(ExplicitDefaults-Common.cmake)
|
||||||
@@ -0,0 +1,2 @@
|
|||||||
|
set(CMAKE_INSTALL_PREFIX "/usr/local")
|
||||||
|
include(ExplicitDefaults-Common.cmake)
|
||||||
@@ -40,8 +40,15 @@ endblock()
|
|||||||
run_cmake(GetAbs)
|
run_cmake(GetAbs)
|
||||||
run_cmake(NoSystem)
|
run_cmake(NoSystem)
|
||||||
|
|
||||||
run_cmake_with_options(ExplicitDefaults
|
foreach(case
|
||||||
-DCMAKE_INSTALL_BINDIR=bin
|
Opt
|
||||||
-DCMAKE_INSTALL_INCLUDEDIR=include
|
Root
|
||||||
-DCMAKE_INSTALL_LIBDIR=lib
|
Usr
|
||||||
)
|
UsrLocal
|
||||||
|
)
|
||||||
|
run_cmake_with_options(ExplicitDefaults-${case}
|
||||||
|
-DCMAKE_INSTALL_BINDIR=bin
|
||||||
|
-DCMAKE_INSTALL_INCLUDEDIR=include
|
||||||
|
-DCMAKE_INSTALL_LIBDIR=lib
|
||||||
|
)
|
||||||
|
endforeach()
|
||||||
|
|||||||
Reference in New Issue
Block a user