summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorBrad King <brad.king@kitware.com>2023-12-19 13:38:45 (GMT)
committerBrad King <brad.king@kitware.com>2023-12-19 13:51:16 (GMT)
commit68a03cf3d4cbeae272e4b810d0b81fd3f34ebfc0 (patch)
tree80857db1297dbcfa9e993b0ac51d47d61c2c7fcb
parentff21f0f70f4cd977b6baa22ead5b142a80acd67d (diff)
downloadCMake-68a03cf3d4cbeae272e4b810d0b81fd3f34ebfc0.zip
CMake-68a03cf3d4cbeae272e4b810d0b81fd3f34ebfc0.tar.gz
CMake-68a03cf3d4cbeae272e4b810d0b81fd3f34ebfc0.tar.bz2
generate_apple_platform_selection_file: Add INSTALL_PREFIX option
This is necessary to forward to `configure_package_config_file`.
-rw-r--r--Modules/CMakePackageConfigHelpers.cmake18
-rw-r--r--Tests/RunCMake/CMakePackage/apple-export-common.cmake1
2 files changed, 18 insertions, 1 deletions
diff --git a/Modules/CMakePackageConfigHelpers.cmake b/Modules/CMakePackageConfigHelpers.cmake
index 407acff..7fe625a 100644
--- a/Modules/CMakePackageConfigHelpers.cmake
+++ b/Modules/CMakePackageConfigHelpers.cmake
@@ -203,6 +203,7 @@ Generating an Apple Platform Selection File
generate_apple_platform_selection_file(<filename>
INSTALL_DESTINATION <path>
+ [INSTALL_PREFIX <path>]
[MACOS_CONFIG_FILE <file>]
[IOS_CONFIG_FILE <file>]
[IOS_SIMULATOR_CONFIG_FILE <file>]
@@ -221,7 +222,15 @@ Generating an Apple Platform Selection File
built for any Apple platform can use them.
``INSTALL_DESTINATION <path>``
- Path that the file will be installed to.
+ Path to which the file will be installed by the caller, e.g., via
+ :command:`install(FILES)`. The path may be either relative to the
+ ``INSTALL_PREFIX`` or absolute.
+
+ ``INSTALL_PREFIX <path>``
+ Path prefix to which the package will be installed by the caller.
+ The ``<path>`` argument must be an absolute path. If this argument
+ is not passed, the :variable:`CMAKE_INSTALL_PREFIX` variable will be
+ used instead.
``MACOS_CONFIG_FILE <file>``
File to include if the platform is macOS.
@@ -425,6 +434,7 @@ function(generate_apple_platform_selection_file _output_file)
set(_options)
set(_single
INSTALL_DESTINATION
+ INSTALL_PREFIX
${_config_file_options}
)
set(_multi)
@@ -433,6 +443,11 @@ function(generate_apple_platform_selection_file _output_file)
if(NOT _gpsf_INSTALL_DESTINATION)
message(FATAL_ERROR "No INSTALL_DESTINATION given to generate_apple_platform_selection_file()")
endif()
+ if(_gpsf_INSTALL_PREFIX)
+ set(maybe_INSTALL_PREFIX INSTALL_PREFIX ${_gpsf_INSTALL_PREFIX})
+ else()
+ set(maybe_INSTALL_PREFIX "")
+ endif()
set(_have_relative 0)
foreach(_opt IN LISTS _config_file_options)
@@ -450,6 +465,7 @@ function(generate_apple_platform_selection_file _output_file)
configure_package_config_file("${CMAKE_CURRENT_FUNCTION_LIST_DIR}/Internal/ApplePlatformSelection.cmake.in" "${_output_file}"
INSTALL_DESTINATION "${_gpsf_INSTALL_DESTINATION}"
+ ${maybe_INSTALL_PREFIX}
NO_SET_AND_CHECK_MACRO
NO_CHECK_REQUIRED_COMPONENTS_MACRO
)
diff --git a/Tests/RunCMake/CMakePackage/apple-export-common.cmake b/Tests/RunCMake/CMakePackage/apple-export-common.cmake
index 1381f59..eb6ce01 100644
--- a/Tests/RunCMake/CMakePackage/apple-export-common.cmake
+++ b/Tests/RunCMake/CMakePackage/apple-export-common.cmake
@@ -9,6 +9,7 @@ install(EXPORT mylib-targets DESTINATION lib/${platform_name}/cmake/mylib)
include(CMakePackageConfigHelpers)
generate_apple_platform_selection_file(mylib-config-install.cmake
INSTALL_DESTINATION lib/cmake/mylib
+ INSTALL_PREFIX ${CMAKE_INSTALL_PREFIX}
MACOS_CONFIG_FILE lib/macos/cmake/mylib/mylib-targets.cmake
IOS_CONFIG_FILE lib/ios/cmake/mylib/mylib-targets.cmake
IOS_SIMULATOR_CONFIG_FILE lib/ios-simulator/cmake/mylib/mylib-targets.cmake