diff options
author | Brad King <brad.king@kitware.com> | 2024-04-11 13:06:41 (GMT) |
---|---|---|
committer | Brad King <brad.king@kitware.com> | 2024-04-11 13:23:46 (GMT) |
commit | 0e4db177647e29b5f4a99ec220e38b5dbbf01361 (patch) | |
tree | 51cc15ef6f9c3b0391e66f94d00f7192dd13c5d3 /Modules/CMakePackageConfigHelpers.cmake | |
parent | 85f501ed59cb3df68bffc713cd3cfc62ad878f55 (diff) | |
download | CMake-0e4db177647e29b5f4a99ec220e38b5dbbf01361.zip CMake-0e4db177647e29b5f4a99ec220e38b5dbbf01361.tar.gz CMake-0e4db177647e29b5f4a99ec220e38b5dbbf01361.tar.bz2 |
CMakePackageConfigHelpers: Restore undocumented PACKAGE_PREFIX_DIR variable
Revert commit 6ddf8712cd (CMakePackageConfigHelpers: Use unique variable
name for pkg prefix, 2024-03-30, v3.29.1~8^2). It regressed existing
projects that rely on the undocumented `PACKAGE_PREFIX_DIR` variable in
package configuration files generated by `CMakePackageConfigHelpers`.
Fixes: #25873
Fixes: #25885
Issue: #25827
Diffstat (limited to 'Modules/CMakePackageConfigHelpers.cmake')
-rw-r--r-- | Modules/CMakePackageConfigHelpers.cmake | 42 |
1 files changed, 7 insertions, 35 deletions
diff --git a/Modules/CMakePackageConfigHelpers.cmake b/Modules/CMakePackageConfigHelpers.cmake index 8bd643e..dfe1ec7 100644 --- a/Modules/CMakePackageConfigHelpers.cmake +++ b/Modules/CMakePackageConfigHelpers.cmake @@ -377,24 +377,6 @@ macro(WRITE_BASIC_PACKAGE_VERSION_FILE) write_basic_config_version_file(${ARGN}) endmacro() -function(__CMAKE_get_config_file_package_prefix outvar) - get_property(counter GLOBAL PROPERTY CMAKE_CONFIGURE_PACKAGE_CONFIG_FILE_COUNTER) - if(NOT counter) - set(counter 1) - set_property(GLOBAL PROPERTY CMAKE_CONFIGURE_PACKAGE_CONFIG_FILE_COUNTER ${counter}) - endif() - set(${outvar} "PACKAGE_\${CMAKE_FIND_PACKAGE_NAME}_COUNTER_${counter}" PARENT_SCOPE) -endfunction() - -function(__CMAKE_increment_config_file_counter) - get_property(counter GLOBAL PROPERTY CMAKE_CONFIGURE_PACKAGE_CONFIG_FILE_COUNTER) - if(NOT counter) - message(FATAL_ERROR "Internal error: global counter unexpectedly not set") - endif() - math(EXPR counter "${counter} + 1") - set_property(GLOBAL PROPERTY CMAKE_CONFIGURE_PACKAGE_CONFIG_FILE_COUNTER ${counter}) -endfunction() - function(CONFIGURE_PACKAGE_CONFIG_FILE _inputFile _outputFile) set(options NO_SET_AND_CHECK_MACRO NO_CHECK_REQUIRED_COMPONENTS_MACRO) set(oneValueArgs INSTALL_DESTINATION INSTALL_PREFIX) @@ -430,17 +412,15 @@ function(CONFIGURE_PACKAGE_CONFIG_FILE _inputFile _outputFile) file(RELATIVE_PATH PACKAGE_RELATIVE_PATH "${absInstallDir}" "${installPrefix}" ) - __CMAKE_get_config_file_package_prefix(prefix_dir) - foreach(var ${CCF_PATH_VARS}) if(NOT DEFINED ${var}) message(FATAL_ERROR "Variable ${var} does not exist") else() if(IS_ABSOLUTE "${${var}}") - string(REPLACE "${installPrefix}" "\${${prefix_dir}}" + string(REPLACE "${installPrefix}" "\${PACKAGE_PREFIX_DIR}" PACKAGE_${var} "${${var}}") else() - set(PACKAGE_${var} "\${${prefix_dir}}/${${var}}") + set(PACKAGE_${var} "\${PACKAGE_PREFIX_DIR}/${${var}}") endif() endif() endforeach() @@ -452,7 +432,7 @@ function(CONFIGURE_PACKAGE_CONFIG_FILE _inputFile _outputFile) ####### Any changes to this file will be overwritten by the next CMake run #### ####### The input file was ${inputFileName} ######## -get_filename_component(${prefix_dir} \"\${CMAKE_CURRENT_LIST_DIR}/${PACKAGE_RELATIVE_PATH}\" ABSOLUTE) +get_filename_component(PACKAGE_PREFIX_DIR \"\${CMAKE_CURRENT_LIST_DIR}/${PACKAGE_RELATIVE_PATH}\" ABSOLUTE) ") if("${absInstallDir}" MATCHES "^(/usr)?/lib(64)?/.+") @@ -463,7 +443,7 @@ get_filename_component(${prefix_dir} \"\${CMAKE_CURRENT_LIST_DIR}/${PACKAGE_RELA get_filename_component(_realCurr \"\${CMAKE_CURRENT_LIST_DIR}\" REALPATH) get_filename_component(_realOrig \"${absInstallDir}\" REALPATH) if(_realCurr STREQUAL _realOrig) - set(${prefix_dir} \"${installPrefix}\") + set(PACKAGE_PREFIX_DIR \"${installPrefix}\") endif() unset(_realOrig) unset(_realCurr) @@ -501,10 +481,6 @@ endmacro() configure_file("${_inputFile}" "${_outputFile}" @ONLY) - # We're done writing the file. Make sure the next one has a unique prefix dir - # variable name (we may have multiple config files for the one package) - __CMAKE_increment_config_file_counter() - endfunction() function(generate_apple_platform_selection_file _output_file) @@ -545,14 +521,12 @@ function(generate_apple_platform_selection_file _output_file) set(_branch_INIT "") endif() - __CMAKE_get_config_file_package_prefix(prefix_dir) - set(_else ELSE) foreach(_opt IN LISTS _config_file_options _else) if(_gpsf_${_opt}) set(_config_file "${_gpsf_${_opt}}") if(NOT IS_ABSOLUTE "${_config_file}") - string(PREPEND _config_file "\${${prefix_dir}}/") + string(PREPEND _config_file [[${PACKAGE_PREFIX_DIR}/]]) endif() set(_branch_${_opt} "include(\"${_config_file}\")") elseif(_gpsf_ERROR_VARIABLE) @@ -626,13 +600,11 @@ function(generate_apple_architecture_selection_file _output_file) "endif()\n" ) - __CMAKE_get_config_file_package_prefix(prefix_dir) - foreach(pair IN ZIP_LISTS _gasf_SINGLE_ARCHITECTURES _gasf_SINGLE_ARCHITECTURE_INCLUDE_FILES) set(arch "${pair_0}") set(config_file "${pair_1}") if(NOT IS_ABSOLUTE "${config_file}") - string(PREPEND config_file "\${${prefix_dir}}/") + string(PREPEND config_file [[${PACKAGE_PREFIX_DIR}/]]) endif() string(APPEND _branch_code "\n" @@ -647,7 +619,7 @@ function(generate_apple_architecture_selection_file _output_file) string(JOIN " " universal_archs "${_gasf_UNIVERSAL_ARCHITECTURES}") set(config_file "${_gasf_UNIVERSAL_INCLUDE_FILE}") if(NOT IS_ABSOLUTE "${config_file}") - string(PREPEND config_file "\${${prefix_dir}}/") + string(PREPEND config_file [[${PACKAGE_PREFIX_DIR}/]]) endif() string(APPEND _branch_code "\n" |