1
0
mirror of https://github.com/Kitware/CMake.git synced 2025-10-19 19:43:23 +08:00

GNUInstallDirs: Move the common handler for SYSCONFDIR and LOCALSTATEDIR

Signed-off-by: Cristian Le <git@lecris.dev>
This commit is contained in:
Cristian Le
2025-04-03 18:59:59 +02:00
parent ead4355b16
commit 03e796f9ab

View File

@@ -319,6 +319,17 @@ function(_GNUInstallDirs_special_absolute out_var original_path install_prefix)
return(PROPAGATE ${out_var}) return(PROPAGATE ${out_var})
endfunction() endfunction()
# Common handler for defaults that should be in /<dir>
# i.e. SYSCONFDIR and LOCALSTATEDIR
function(__GNUInstallDirs_default_in_root out_var original_path install_prefix)
if(_GNUInstallDirs_CMP0192 STREQUAL "NEW")
_GNUInstallDirs_special_absolute(${out_var}
"${original_path}" "${install_prefix}")
endif()
cmake_path(NORMAL_PATH ${out_var})
return(PROPAGATE ${out_var})
endfunction()
# Installation directories # Installation directories
# #
@@ -381,22 +392,21 @@ function(_GNUInstallDirs_LIBDIR_get_default out_var install_prefix)
return(PROPAGATE ${out_var}) return(PROPAGATE ${out_var})
endfunction() endfunction()
function(_GNUInstallDirs_SYSCONFDIR_get_default out_var install_prefix) foreach(dir IN ITEMS
if(_GNUInstallDirs_CMP0192 STREQUAL "NEW") SYSCONFDIR
_GNUInstallDirs_special_absolute(${out_var} LOCALSTATEDIR
"${_GNUInstallDirs_SYSCONFDIR_DEFAULT}" "${install_prefix}") )
endif() # Cannot call function() directly because `dir` would not be accessible inside the function
cmake_path(NORMAL_PATH ${out_var}) # Using cmake_language(EVAL) to call a short wrapper function instead
return(PROPAGATE ${out_var}) cmake_language(EVAL CODE "
endfunction() function(_GNUInstallDirs_${dir}_get_default out_var install_prefix)
function(_GNUInstallDirs_LOCALSTATEDIR_get_default out_var install_prefix) set(\${out_var} \"\${_GNUInstallDirs_${dir}_DEFAULT}\")
if(_GNUInstallDirs_CMP0192 STREQUAL "NEW") __GNUInstallDirs_default_in_root(\${out_var} \"\${\${out_var}}\" \"\${install_prefix}\")
_GNUInstallDirs_special_absolute(${out_var} return(PROPAGATE \${out_var})
"${_GNUInstallDirs_LOCALSTATEDIR_DEFAULT}" "${install_prefix}") endfunction()
endif() "
cmake_path(NORMAL_PATH ${out_var}) )
return(PROPAGATE ${out_var}) endforeach()
endfunction()
# Depends on current CMAKE_INSTALL_LOCALSTATEDIR value # Depends on current CMAKE_INSTALL_LOCALSTATEDIR value
function(_GNUInstallDirs_RUNSTATEDIR_get_default out_var install_prefix) function(_GNUInstallDirs_RUNSTATEDIR_get_default out_var install_prefix)