From 68a03cf3d4cbeae272e4b810d0b81fd3f34ebfc0 Mon Sep 17 00:00:00 2001 From: Brad King Date: Tue, 19 Dec 2023 08:38:45 -0500 Subject: [PATCH] generate_apple_platform_selection_file: Add INSTALL_PREFIX option This is necessary to forward to `configure_package_config_file`. --- Modules/CMakePackageConfigHelpers.cmake | 18 +++++++++++++++++- .../CMakePackage/apple-export-common.cmake | 1 + 2 files changed, 18 insertions(+), 1 deletion(-) diff --git a/Modules/CMakePackageConfigHelpers.cmake b/Modules/CMakePackageConfigHelpers.cmake index 407acffc0c..7fe625a388 100644 --- a/Modules/CMakePackageConfigHelpers.cmake +++ b/Modules/CMakePackageConfigHelpers.cmake @@ -203,6 +203,7 @@ Generating an Apple Platform Selection File generate_apple_platform_selection_file( INSTALL_DESTINATION + [INSTALL_PREFIX ] [MACOS_CONFIG_FILE ] [IOS_CONFIG_FILE ] [IOS_SIMULATOR_CONFIG_FILE ] @@ -221,7 +222,15 @@ Generating an Apple Platform Selection File built for any Apple platform can use them. ``INSTALL_DESTINATION `` - 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 prefix to which the package will be installed by the caller. + The ```` 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 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 1381f59f3a..eb6ce017f3 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