summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--Help/prop_tgt/XCODE_EMBED_type.rst16
-rw-r--r--Modules/CMakePackageConfigHelpers.cmake94
-rw-r--r--Modules/FetchContent.cmake15
-rw-r--r--Modules/Internal/ApplePlatformSelection.cmake.in (renamed from Modules/Internal/PlatformSelectionFile.cmake.in)4
-rw-r--r--Source/CMakeVersion.cmake2
-rw-r--r--Source/cmGeneratorTarget.cxx22
-rw-r--r--Tests/RunCMake/CMakeLists.txt7
-rw-r--r--Tests/RunCMake/CMakePackage/ApplePlatformMissingDest-result.txt1
-rw-r--r--Tests/RunCMake/CMakePackage/ApplePlatformMissingDest-stderr.txt6
-rw-r--r--Tests/RunCMake/CMakePackage/ApplePlatformMissingDest.cmake4
-rw-r--r--Tests/RunCMake/CMakePackage/CMakeLists.txt3
-rw-r--r--Tests/RunCMake/CMakePackage/RunCMakeTest.cmake90
-rw-r--r--Tests/RunCMake/CMakePackage/apple-common.cmake15
-rw-r--r--Tests/RunCMake/CMakePackage/apple-export-common.cmake22
-rw-r--r--Tests/RunCMake/CMakePackage/apple-export-ios-simulator.cmake2
-rw-r--r--Tests/RunCMake/CMakePackage/apple-export-ios.cmake2
-rw-r--r--Tests/RunCMake/CMakePackage/apple-export-macos.cmake2
-rw-r--r--Tests/RunCMake/CMakePackage/apple-export-tvos-simulator.cmake2
-rw-r--r--Tests/RunCMake/CMakePackage/apple-export-tvos.cmake2
-rw-r--r--Tests/RunCMake/CMakePackage/apple-export-visionos-simulator.cmake2
-rw-r--r--Tests/RunCMake/CMakePackage/apple-export-visionos.cmake2
-rw-r--r--Tests/RunCMake/CMakePackage/apple-export-watchos-simulator.cmake2
-rw-r--r--Tests/RunCMake/CMakePackage/apple-export-watchos.cmake2
-rw-r--r--Tests/RunCMake/CMakePackage/apple-import-common.cmake7
-rw-r--r--Tests/RunCMake/CMakePackage/apple-import-ios-simulator.cmake1
-rw-r--r--Tests/RunCMake/CMakePackage/apple-import-ios.cmake1
-rw-r--r--Tests/RunCMake/CMakePackage/apple-import-macos.cmake1
-rw-r--r--Tests/RunCMake/CMakePackage/apple-import-tvos-simulator.cmake1
-rw-r--r--Tests/RunCMake/CMakePackage/apple-import-tvos.cmake1
-rw-r--r--Tests/RunCMake/CMakePackage/apple-import-visionos-simulator.cmake1
-rw-r--r--Tests/RunCMake/CMakePackage/apple-import-visionos.cmake1
-rw-r--r--Tests/RunCMake/CMakePackage/apple-import-watchos-simulator.cmake1
-rw-r--r--Tests/RunCMake/CMakePackage/apple-import-watchos.cmake1
-rw-r--r--Tests/RunCMake/CMakePackage/include/mylib.h3
-rw-r--r--Tests/RunCMake/CMakePackage/src/myexe.c6
-rw-r--r--Tests/RunCMake/CMakePackage/src/mylib.c4
-rw-r--r--Tests/RunCMake/DependencyProviders/ProviderFirst-stdout.txt6
-rw-r--r--Tests/RunCMake/DependencyProviders/ProviderFirst.cmake8
-rw-r--r--Tests/RunCMake/DependencyProviders/RunCMakeTest.cmake5
-rw-r--r--Tests/RunCMake/target_link_libraries/ImportedTargetPerConfig.cmake27
-rw-r--r--Tests/RunCMake/target_link_libraries/RunCMakeTest.cmake1
41 files changed, 341 insertions, 54 deletions
diff --git a/Help/prop_tgt/XCODE_EMBED_type.rst b/Help/prop_tgt/XCODE_EMBED_type.rst
index 0f71ead..0354f97 100644
--- a/Help/prop_tgt/XCODE_EMBED_type.rst
+++ b/Help/prop_tgt/XCODE_EMBED_type.rst
@@ -49,6 +49,22 @@ The supported values for ``<type>`` are:
The specified items will be added to the ``Embed XPC Services`` build phase.
They must be CMake target names.
+When listing a target as any of the things to embed, Xcode must see that target
+as part of the same Xcode project, or a sub-project of the one defining the
+bundle. In order to satisfy this constraint, the CMake project must ensure
+at least one of the following:
+
+* The :variable:`CMAKE_XCODE_GENERATE_TOP_LEVEL_PROJECT_ONLY` variable is set
+ to true in the top level ``CMakeLists.txt`` file. This is the simplest and
+ most robust approach.
+* Define the target-to-embed in a subdirectory of the one that defines the
+ target being embedded into.
+* If the target-to-embed and the target being embedded into are in separate,
+ unrelated directories (i.e. they are siblings, not one a parent of the
+ other), ensure they have a common :command:`project` call in a parent
+ directory and no other :command:`project` calls between themselves and that
+ common :command:`project` call.
+
See also :prop_tgt:`XCODE_EMBED_<type>_PATH`,
:prop_tgt:`XCODE_EMBED_<type>_REMOVE_HEADERS_ON_COPY` and
:prop_tgt:`XCODE_EMBED_<type>_CODE_SIGN_ON_COPY`.
diff --git a/Modules/CMakePackageConfigHelpers.cmake b/Modules/CMakePackageConfigHelpers.cmake
index ab38820..407acff 100644
--- a/Modules/CMakePackageConfigHelpers.cmake
+++ b/Modules/CMakePackageConfigHelpers.cmake
@@ -193,64 +193,66 @@ point to create more sophisticated custom ``ConfigVersion.cmake`` files.
Generating an Apple Platform Selection File
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
-.. versionadded:: 3.29
-
.. command:: generate_apple_platform_selection_file
- Create an Apple platform selection file:
+ .. versionadded:: 3.29
- generate_apple_platform_selection_file(<filename>
- INSTALL_DESTINATION <path>
- [MACOS_CONFIG_FILE <file>]
- [IOS_CONFIG_FILE <file>]
- [IOS_SIMULATOR_CONFIG_FILE <file>]
- [TVOS_CONFIG_FILE <file>]
- [TVOS_SIMULATOR_CONFIG_FILE <file>]
- [WATCHOS_CONFIG_FILE <file>]
- [WATCHOS_SIMULATOR_CONFIG_FILE <file>]
- [VISIONOS_CONFIG_FILE <file>]
- [VISIONOS_SIMULATOR_CONFIG_FILE <file>]
- )
+ Create an Apple platform selection file:
+
+ .. code-block:: cmake
-Writes a file for use as ``<PackageName>Config.cmake`` which can include an
-Apple-platform-specific ``<PackageName>Config.cmake`` from a different
-directory. This can be used in conjunction with the ``XCFRAMEWORK_LOCATION``
-argument of :command:`export(SETUP)` to export packages in a way that a project
-built for any Apple platform can use them.
+ generate_apple_platform_selection_file(<filename>
+ INSTALL_DESTINATION <path>
+ [MACOS_CONFIG_FILE <file>]
+ [IOS_CONFIG_FILE <file>]
+ [IOS_SIMULATOR_CONFIG_FILE <file>]
+ [TVOS_CONFIG_FILE <file>]
+ [TVOS_SIMULATOR_CONFIG_FILE <file>]
+ [WATCHOS_CONFIG_FILE <file>]
+ [WATCHOS_SIMULATOR_CONFIG_FILE <file>]
+ [VISIONOS_CONFIG_FILE <file>]
+ [VISIONOS_SIMULATOR_CONFIG_FILE <file>]
+ )
-``INSTALL_DESTINATION <path>``
- Path that the file will be installed to.
+ Writes a file for use as ``<PackageName>Config.cmake`` which can include an
+ Apple-platform-specific ``<PackageName>Config.cmake`` from a different
+ directory. This can be used in conjunction with the ``XCFRAMEWORK_LOCATION``
+ argument of :command:`export(SETUP)` to export packages in a way that a project
+ built for any Apple platform can use them.
-``MACOS_CONFIG_FILE <file>``
- File to include if the platform is macOS.
+ ``INSTALL_DESTINATION <path>``
+ Path that the file will be installed to.
-``IOS_CONFIG_FILE <file>``
- File to include if the platform is iOS.
+ ``MACOS_CONFIG_FILE <file>``
+ File to include if the platform is macOS.
-``IOS_SIMULATOR_CONFIG_FILE <file>``
- File to include if the platform is iOS Simulator.
+ ``IOS_CONFIG_FILE <file>``
+ File to include if the platform is iOS.
-``TVOS_CONFIG_FILE <file>``
- File to include if the platform is tvOS.
+ ``IOS_SIMULATOR_CONFIG_FILE <file>``
+ File to include if the platform is iOS Simulator.
-``TVOS_SIMULATOR_CONFIG_FILE <file>``
- File to include if the platform is tvOS Simulator.
+ ``TVOS_CONFIG_FILE <file>``
+ File to include if the platform is tvOS.
-``WATCHOS_CONFIG_FILE <file>``
- File to include if the platform is watchOS.
+ ``TVOS_SIMULATOR_CONFIG_FILE <file>``
+ File to include if the platform is tvOS Simulator.
-``WATCHOS_SIMULATOR_CONFIG_FILE <file>``
- File to include if the platform is watchOS Simulator.
+ ``WATCHOS_CONFIG_FILE <file>``
+ File to include if the platform is watchOS.
-``VISIONOS_CONFIG_FILE <file>``
- File to include if the platform is visionOS.
+ ``WATCHOS_SIMULATOR_CONFIG_FILE <file>``
+ File to include if the platform is watchOS Simulator.
-``VISIONOS_SIMULATOR_CONFIG_FILE <file>``
- File to include if the platform is visionOS Simulator.
+ ``VISIONOS_CONFIG_FILE <file>``
+ File to include if the platform is visionOS.
-If any of the optional config files are not specified, and the consuming
-project is built for their corresponding platform, an error will be thrown
-when including the generated file.
+ ``VISIONOS_SIMULATOR_CONFIG_FILE <file>``
+ File to include if the platform is visionOS Simulator.
+
+ If any of the optional config files are not specified, and the consuming
+ project is built for their corresponding platform, an error will be thrown
+ when including the generated file.
Example Generating Package Files
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
@@ -428,6 +430,10 @@ function(generate_apple_platform_selection_file _output_file)
set(_multi)
cmake_parse_arguments(PARSE_ARGV 0 _gpsf "${_options}" "${_single}" "${_multi}")
+ if(NOT _gpsf_INSTALL_DESTINATION)
+ message(FATAL_ERROR "No INSTALL_DESTINATION given to generate_apple_platform_selection_file()")
+ endif()
+
set(_have_relative 0)
foreach(_opt IN LISTS _config_file_options)
if(_gpsf_${_opt})
@@ -442,7 +448,7 @@ function(generate_apple_platform_selection_file _output_file)
endif()
endforeach()
- configure_package_config_file("${CMAKE_CURRENT_FUNCTION_LIST_DIR}/Internal/PlatformSelectionFile.cmake.in" "${_output_file}"
+ configure_package_config_file("${CMAKE_CURRENT_FUNCTION_LIST_DIR}/Internal/ApplePlatformSelection.cmake.in" "${_output_file}"
INSTALL_DESTINATION "${_gpsf_INSTALL_DESTINATION}"
NO_SET_AND_CHECK_MACRO
NO_CHECK_REQUIRED_COMPONENTS_MACRO
diff --git a/Modules/FetchContent.cmake b/Modules/FetchContent.cmake
index 1038585..48cdaf4 100644
--- a/Modules/FetchContent.cmake
+++ b/Modules/FetchContent.cmake
@@ -685,6 +685,17 @@ A number of cache variables can influence the behavior where details from a
any content details, turning this option ``ON`` can significantly speed up
the configure stage. It is ``OFF`` by default.
+ .. note::
+
+ The ``FETCHCONTENT_FULLY_DISCONNECTED`` variable is not an appropriate way
+ to prevent any network access on the first run in a build directory.
+ Doing so can break projects, lead to misleading error messages, and hide
+ subtle population failures. This variable is specifically intended to
+ only be turned on *after* the first time CMake has been run.
+ If you want to prevent network access even on the first run, use a
+ :ref:`dependency provider <dependency_providers>` and populate the
+ dependency from local content instead.
+
.. variable:: FETCHCONTENT_UPDATES_DISCONNECTED
This is a less severe download/update control compared to
@@ -1975,12 +1986,12 @@ macro(FetchContent_MakeAvailable)
# This property might be defined but empty. As long as it is defined,
# find_package() can be called.
get_property(__cmake_addfpargs GLOBAL PROPERTY
- _FetchContent_${contentNameLower}_find_package_args
+ _FetchContent_${__cmake_contentNameLower}_find_package_args
DEFINED
)
if(__cmake_addfpargs)
get_property(__cmake_fpargs GLOBAL PROPERTY
- _FetchContent_${contentNameLower}_find_package_args
+ _FetchContent_${__cmake_contentNameLower}_find_package_args
)
string(APPEND __cmake_providerArgs " FIND_PACKAGE_ARGS")
foreach(__cmake_item IN LISTS __cmake_fpargs)
diff --git a/Modules/Internal/PlatformSelectionFile.cmake.in b/Modules/Internal/ApplePlatformSelection.cmake.in
index 3f80f4b..493d650 100644
--- a/Modules/Internal/PlatformSelectionFile.cmake.in
+++ b/Modules/Internal/ApplePlatformSelection.cmake.in
@@ -5,9 +5,9 @@ if(_CMAKE_OSX_SYSROOT_LOWER MATCHES "(^|/)iphonesimulator")
@_branch_IOS_SIMULATOR_CONFIG_FILE@
elseif(_CMAKE_OSX_SYSROOT_LOWER MATCHES "(^|/)iphoneos")
@_branch_IOS_CONFIG_FILE@
-elseif(_CMAKE_OSX_SYSROOT_LOWER MATCHES "(^|/)tvsimulator")
+elseif(_CMAKE_OSX_SYSROOT_LOWER MATCHES "(^|/)appletvsimulator")
@_branch_TVOS_SIMULATOR_CONFIG_FILE@
-elseif(_CMAKE_OSX_SYSROOT_LOWER MATCHES "(^|/)tvos")
+elseif(_CMAKE_OSX_SYSROOT_LOWER MATCHES "(^|/)appletvos")
@_branch_TVOS_CONFIG_FILE@
elseif(_CMAKE_OSX_SYSROOT_LOWER MATCHES "(^|/)watchsimulator")
@_branch_WATCHOS_SIMULATOR_CONFIG_FILE@
diff --git a/Source/CMakeVersion.cmake b/Source/CMakeVersion.cmake
index 8fec59c..4a3179a 100644
--- a/Source/CMakeVersion.cmake
+++ b/Source/CMakeVersion.cmake
@@ -1,7 +1,7 @@
# CMake version number components.
set(CMake_VERSION_MAJOR 3)
set(CMake_VERSION_MINOR 28)
-set(CMake_VERSION_PATCH 20231216)
+set(CMake_VERSION_PATCH 20231219)
#set(CMake_VERSION_RC 0)
set(CMake_VERSION_IS_DIRTY 0)
diff --git a/Source/cmGeneratorTarget.cxx b/Source/cmGeneratorTarget.cxx
index feeae95..289bb24 100644
--- a/Source/cmGeneratorTarget.cxx
+++ b/Source/cmGeneratorTarget.cxx
@@ -8860,11 +8860,23 @@ bool cmGeneratorTarget::IsFrameworkOnApple() const
bool cmGeneratorTarget::IsImportedFrameworkFolderOnApple(
const std::string& config) const
{
- return this->IsApple() && this->IsImported() &&
- (this->GetType() == cmStateEnums::STATIC_LIBRARY ||
- this->GetType() == cmStateEnums::SHARED_LIBRARY ||
- this->GetType() == cmStateEnums::UNKNOWN_LIBRARY) &&
- cmSystemTools::IsPathToFramework(this->GetLocation(config));
+ if (this->IsApple() && this->IsImported() &&
+ (this->GetType() == cmStateEnums::STATIC_LIBRARY ||
+ this->GetType() == cmStateEnums::SHARED_LIBRARY ||
+ this->GetType() == cmStateEnums::UNKNOWN_LIBRARY)) {
+ std::string cfg = config;
+ if (cfg.empty() && this->GetGlobalGenerator()->IsXcode()) {
+ // FIXME(#25515): Remove the need for this workaround.
+ // The Xcode generator queries include directories without any
+ // specific configuration. Pick one in case this target does
+ // not set either IMPORTED_LOCATION or IMPORTED_CONFIGURATIONS.
+ cfg =
+ this->Makefile->GetGeneratorConfigs(cmMakefile::IncludeEmptyConfig)[0];
+ }
+ return cmSystemTools::IsPathToFramework(this->GetLocation(cfg));
+ }
+
+ return false;
}
bool cmGeneratorTarget::IsAppBundleOnApple() const
diff --git a/Tests/RunCMake/CMakeLists.txt b/Tests/RunCMake/CMakeLists.txt
index 7e1b0e4..dbcb94e 100644
--- a/Tests/RunCMake/CMakeLists.txt
+++ b/Tests/RunCMake/CMakeLists.txt
@@ -325,6 +325,13 @@ if(UNIX AND "${CMAKE_GENERATOR}" MATCHES "Unix Makefiles|Ninja")
add_RunCMake_test(Byproducts)
endif()
add_RunCMake_test(CMakeDependentOption)
+if(APPLE # Remove these conditions when the test has non-Apple cases
+ AND CMAKE_C_COMPILER_ID STREQUAL "AppleClang")
+ add_RunCMake_test(CMakePackage
+ -DCMake_TEST_XCODE_VERSION=${CMake_TEST_XCODE_VERSION}
+ -DCMAKE_C_COMPILER_ID=${CMAKE_C_COMPILER_ID}
+ )
+endif()
add_RunCMake_test(CMakeRoleGlobalProperty)
add_RunCMake_test(CMakeRelease -DCMake_TEST_JQ=${CMake_TEST_JQ})
if(CMAKE_GENERATOR MATCHES "Make|Ninja")
diff --git a/Tests/RunCMake/CMakePackage/ApplePlatformMissingDest-result.txt b/Tests/RunCMake/CMakePackage/ApplePlatformMissingDest-result.txt
new file mode 100644
index 0000000..d00491f
--- /dev/null
+++ b/Tests/RunCMake/CMakePackage/ApplePlatformMissingDest-result.txt
@@ -0,0 +1 @@
+1
diff --git a/Tests/RunCMake/CMakePackage/ApplePlatformMissingDest-stderr.txt b/Tests/RunCMake/CMakePackage/ApplePlatformMissingDest-stderr.txt
new file mode 100644
index 0000000..03be015
--- /dev/null
+++ b/Tests/RunCMake/CMakePackage/ApplePlatformMissingDest-stderr.txt
@@ -0,0 +1,6 @@
+^CMake Error at [^
+]*/Modules/CMakePackageConfigHelpers\.cmake:[0-9]+ \(message\):
+ No INSTALL_DESTINATION given to generate_apple_platform_selection_file\(\)
+Call Stack \(most recent call first\):
+ ApplePlatformMissingDest\.cmake:[0-9]+ \(generate_apple_platform_selection_file\)
+ CMakeLists.txt:[0-9]+ \(include\)$
diff --git a/Tests/RunCMake/CMakePackage/ApplePlatformMissingDest.cmake b/Tests/RunCMake/CMakePackage/ApplePlatformMissingDest.cmake
new file mode 100644
index 0000000..e47b595
--- /dev/null
+++ b/Tests/RunCMake/CMakePackage/ApplePlatformMissingDest.cmake
@@ -0,0 +1,4 @@
+include(CMakePackageConfigHelpers)
+generate_apple_platform_selection_file(mylib-config-install.cmake
+ #missing: INSTALL_DESTINATION lib/cmake/mylib
+ )
diff --git a/Tests/RunCMake/CMakePackage/CMakeLists.txt b/Tests/RunCMake/CMakePackage/CMakeLists.txt
new file mode 100644
index 0000000..6a9ce76
--- /dev/null
+++ b/Tests/RunCMake/CMakePackage/CMakeLists.txt
@@ -0,0 +1,3 @@
+cmake_minimum_required(VERSION 3.28)
+project(${RunCMake_TEST} NONE)
+include(${RunCMake_TEST}.cmake)
diff --git a/Tests/RunCMake/CMakePackage/RunCMakeTest.cmake b/Tests/RunCMake/CMakePackage/RunCMakeTest.cmake
new file mode 100644
index 0000000..9c1dbd5
--- /dev/null
+++ b/Tests/RunCMake/CMakePackage/RunCMakeTest.cmake
@@ -0,0 +1,90 @@
+include(RunCMake)
+
+if(NOT RunCMake_GENERATOR_IS_MULTI_CONFIG)
+ set(maybe_CMAKE_BUILD_TYPE -DCMAKE_BUILD_TYPE=Release)
+endif()
+
+function(apple_export platform system_name archs sysroot)
+ set(RunCMake_TEST_BINARY_DIR ${RunCMake_BINARY_DIR}/apple-export-${platform}-build)
+ string(REPLACE ";" "\\;" archs "${archs}")
+ run_cmake_with_options(apple-export-${platform}
+ "-DCMAKE_SYSTEM_NAME=${system_name}"
+ "-DCMAKE_OSX_ARCHITECTURES=${archs}"
+ "-DCMAKE_OSX_SYSROOT=${sysroot}"
+ "-DCMAKE_INSTALL_PREFIX=${apple_install}"
+ ${maybe_CMAKE_BUILD_TYPE}
+ )
+ set(RunCMake_TEST_NO_CLEAN 1)
+ run_cmake_command(apple-export-${platform}-build ${CMAKE_COMMAND} --build . --config Release)
+ run_cmake_command(apple-export-${platform}-install ${CMAKE_COMMAND} --install . --config Release)
+endfunction()
+
+function(apple_import platform system_name archs sysroot)
+ set(RunCMake_TEST_BINARY_DIR ${RunCMake_BINARY_DIR}/apple-import-${platform}-build)
+ string(REPLACE ";" "\\;" archs "${archs}")
+ run_cmake_with_options(apple-import-${platform}
+ "-DCMAKE_SYSTEM_NAME=${system_name}"
+ "-DCMAKE_OSX_ARCHITECTURES=${archs}"
+ "-DCMAKE_OSX_SYSROOT=${sysroot}"
+ "-DCMAKE_PREFIX_PATH=${apple_install}"
+ ${maybe_CMAKE_BUILD_TYPE}
+ )
+ set(RunCMake_TEST_NO_CLEAN 1)
+ run_cmake_command(apple-import-${platform}-build ${CMAKE_COMMAND} --build . --config Release)
+endfunction()
+
+if(APPLE)
+ run_cmake(ApplePlatformMissingDest)
+endif()
+
+if(APPLE AND CMAKE_C_COMPILER_ID STREQUAL "AppleClang")
+ set(apple_install ${RunCMake_BINARY_DIR}/apple-install)
+ file(REMOVE_RECURSE "${apple_install}")
+
+ if(CMake_TEST_XCODE_VERSION VERSION_GREATER_EQUAL 12)
+ set(macos_archs "x86_64;arm64")
+ set(watch_sim_archs "x86_64")
+ else()
+ set(macos_archs "x86_64")
+ set(watch_sim_archs "i386")
+ endif()
+
+ if(CMake_TEST_XCODE_VERSION VERSION_GREATER_EQUAL 9)
+ set(watch_archs "armv7k;arm64_32")
+ else()
+ set(watch_archs "armv7k")
+ endif()
+
+ #FIXME(#25266): Xcode 15.0 does not have visionOS. Improve this condition.
+ #if(CMake_TEST_XCODE_VERSION VERSION_GREATER_EQUAL 15)
+ # set(enable_visionos 1)
+ #endif()
+
+ apple_export(macos Darwin "${macos_archs}" macosx)
+ apple_export(ios iOS "arm64" iphoneos)
+ apple_export(tvos tvOS "arm64" appletvos)
+ if(enable_visionos)
+ apple_export(visionos visionOS "arm64" xros)
+ endif()
+ apple_export(watchos watchOS "${watch_archs}" watchos)
+ apple_export(ios-simulator iOS "${macos_archs}" iphonesimulator)
+ apple_export(tvos-simulator tvOS "${macos_archs}" appletvsimulator)
+ if(enable_visionos)
+ apple_export(visionos-simulator visionOS "${macos_archs}" xrsimulator)
+ endif()
+ apple_export(watchos-simulator watchOS "${watch_sim_archs}" watchsimulator)
+
+ apple_import(macos Darwin "${macos_archs}" macosx)
+ apple_import(ios iOS "arm64" iphoneos)
+ apple_import(tvos tvOS "arm64" appletvos)
+ if(enable_visionos)
+ apple_import(visionos visionOS "arm64" xros)
+ endif()
+ apple_import(watchos watchOS "${watch_archs}" watchos)
+ apple_import(ios-simulator iOS "${macos_archs}" iphonesimulator)
+ apple_import(tvos-simulator tvOS "${macos_archs}" appletvsimulator)
+ if(enable_visionos)
+ apple_import(visionos-simulator visionOS "${macos_archs}" xrsimulator)
+ endif()
+ apple_import(watchos-simulator watchOS "${watch_sim_archs}" watchsimulator)
+endif()
diff --git a/Tests/RunCMake/CMakePackage/apple-common.cmake b/Tests/RunCMake/CMakePackage/apple-common.cmake
new file mode 100644
index 0000000..f854f34
--- /dev/null
+++ b/Tests/RunCMake/CMakePackage/apple-common.cmake
@@ -0,0 +1,15 @@
+enable_language(C)
+
+if(CMAKE_SYSTEM_NAME MATCHES "^(iOS)$")
+ set(CMAKE_XCODE_ATTRIBUTE_CODE_SIGNING_ALLOWED "NO")
+ set(CMAKE_XCODE_ATTRIBUTE_CODE_SIGNING_REQUIRED "NO")
+ set(CMAKE_XCODE_ATTRIBUTE_CODE_SIGN_IDENTITY "")
+ set(CMAKE_XCODE_ATTRIBUTE_ENABLE_BITCODE "NO")
+endif()
+
+if(CMAKE_SYSTEM_NAME MATCHES "^(tvOS|watchOS|visionOS)$")
+ set(CMAKE_XCODE_ATTRIBUTE_CODE_SIGNING_ALLOWED "NO")
+ set(CMAKE_XCODE_ATTRIBUTE_CODE_SIGNING_REQUIRED "NO")
+ set(CMAKE_XCODE_ATTRIBUTE_CODE_SIGN_IDENTITY "")
+ set(CMAKE_XCODE_ATTRIBUTE_ENABLE_BITCODE "YES")
+endif()
diff --git a/Tests/RunCMake/CMakePackage/apple-export-common.cmake b/Tests/RunCMake/CMakePackage/apple-export-common.cmake
new file mode 100644
index 0000000..1381f59
--- /dev/null
+++ b/Tests/RunCMake/CMakePackage/apple-export-common.cmake
@@ -0,0 +1,22 @@
+include(apple-common.cmake)
+
+add_library(mylib STATIC src/mylib.c)
+target_sources(mylib PUBLIC FILE_SET HEADERS BASE_DIRS ${CMAKE_CURRENT_SOURCE_DIR}/include FILES include/mylib.h)
+install(TARGETS mylib EXPORT mylib-targets FILE_SET HEADERS ARCHIVE DESTINATION lib/${platform_name})
+
+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
+ 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
+ TVOS_CONFIG_FILE lib/tvos/cmake/mylib/mylib-targets.cmake
+ TVOS_SIMULATOR_CONFIG_FILE lib/tvos-simulator/cmake/mylib/mylib-targets.cmake
+ VISIONOS_CONFIG_FILE lib/watchos/cmake/mylib/mylib-targets.cmake
+ VISIONOS_SIMULATOR_CONFIG_FILE lib/watchos-simulator/cmake/mylib/mylib-targets.cmake
+ WATCHOS_CONFIG_FILE lib/watchos/cmake/mylib/mylib-targets.cmake
+ WATCHOS_SIMULATOR_CONFIG_FILE lib/watchos-simulator/cmake/mylib/mylib-targets.cmake
+ )
+install(FILES ${CMAKE_CURRENT_BINARY_DIR}/mylib-config-install.cmake DESTINATION lib/cmake/mylib RENAME mylib-config.cmake)
diff --git a/Tests/RunCMake/CMakePackage/apple-export-ios-simulator.cmake b/Tests/RunCMake/CMakePackage/apple-export-ios-simulator.cmake
new file mode 100644
index 0000000..dd545bb
--- /dev/null
+++ b/Tests/RunCMake/CMakePackage/apple-export-ios-simulator.cmake
@@ -0,0 +1,2 @@
+set(platform_name ios-simulator)
+include(apple-export-common.cmake)
diff --git a/Tests/RunCMake/CMakePackage/apple-export-ios.cmake b/Tests/RunCMake/CMakePackage/apple-export-ios.cmake
new file mode 100644
index 0000000..33daa40
--- /dev/null
+++ b/Tests/RunCMake/CMakePackage/apple-export-ios.cmake
@@ -0,0 +1,2 @@
+set(platform_name ios)
+include(apple-export-common.cmake)
diff --git a/Tests/RunCMake/CMakePackage/apple-export-macos.cmake b/Tests/RunCMake/CMakePackage/apple-export-macos.cmake
new file mode 100644
index 0000000..d845d5c
--- /dev/null
+++ b/Tests/RunCMake/CMakePackage/apple-export-macos.cmake
@@ -0,0 +1,2 @@
+set(platform_name macos)
+include(apple-export-common.cmake)
diff --git a/Tests/RunCMake/CMakePackage/apple-export-tvos-simulator.cmake b/Tests/RunCMake/CMakePackage/apple-export-tvos-simulator.cmake
new file mode 100644
index 0000000..d44d663
--- /dev/null
+++ b/Tests/RunCMake/CMakePackage/apple-export-tvos-simulator.cmake
@@ -0,0 +1,2 @@
+set(platform_name tvos-simulator)
+include(apple-export-common.cmake)
diff --git a/Tests/RunCMake/CMakePackage/apple-export-tvos.cmake b/Tests/RunCMake/CMakePackage/apple-export-tvos.cmake
new file mode 100644
index 0000000..c58144b
--- /dev/null
+++ b/Tests/RunCMake/CMakePackage/apple-export-tvos.cmake
@@ -0,0 +1,2 @@
+set(platform_name tvos)
+include(apple-export-common.cmake)
diff --git a/Tests/RunCMake/CMakePackage/apple-export-visionos-simulator.cmake b/Tests/RunCMake/CMakePackage/apple-export-visionos-simulator.cmake
new file mode 100644
index 0000000..e783d80
--- /dev/null
+++ b/Tests/RunCMake/CMakePackage/apple-export-visionos-simulator.cmake
@@ -0,0 +1,2 @@
+set(platform_name visionos-simulator)
+include(apple-export-common.cmake)
diff --git a/Tests/RunCMake/CMakePackage/apple-export-visionos.cmake b/Tests/RunCMake/CMakePackage/apple-export-visionos.cmake
new file mode 100644
index 0000000..73e1b2e
--- /dev/null
+++ b/Tests/RunCMake/CMakePackage/apple-export-visionos.cmake
@@ -0,0 +1,2 @@
+set(platform_name visionos)
+include(apple-export-common.cmake)
diff --git a/Tests/RunCMake/CMakePackage/apple-export-watchos-simulator.cmake b/Tests/RunCMake/CMakePackage/apple-export-watchos-simulator.cmake
new file mode 100644
index 0000000..f4f95a6
--- /dev/null
+++ b/Tests/RunCMake/CMakePackage/apple-export-watchos-simulator.cmake
@@ -0,0 +1,2 @@
+set(platform_name watchos-simulator)
+include(apple-export-common.cmake)
diff --git a/Tests/RunCMake/CMakePackage/apple-export-watchos.cmake b/Tests/RunCMake/CMakePackage/apple-export-watchos.cmake
new file mode 100644
index 0000000..59fc572
--- /dev/null
+++ b/Tests/RunCMake/CMakePackage/apple-export-watchos.cmake
@@ -0,0 +1,2 @@
+set(platform_name watchos)
+include(apple-export-common.cmake)
diff --git a/Tests/RunCMake/CMakePackage/apple-import-common.cmake b/Tests/RunCMake/CMakePackage/apple-import-common.cmake
new file mode 100644
index 0000000..ce79541
--- /dev/null
+++ b/Tests/RunCMake/CMakePackage/apple-import-common.cmake
@@ -0,0 +1,7 @@
+include(apple-common.cmake)
+
+set(CMAKE_FIND_ROOT_PATH_MODE_PACKAGE NEVER)
+find_package(mylib CONFIG REQUIRED)
+
+add_executable(myexe src/myexe.c)
+target_link_libraries(myexe PRIVATE mylib)
diff --git a/Tests/RunCMake/CMakePackage/apple-import-ios-simulator.cmake b/Tests/RunCMake/CMakePackage/apple-import-ios-simulator.cmake
new file mode 100644
index 0000000..fa7ba53
--- /dev/null
+++ b/Tests/RunCMake/CMakePackage/apple-import-ios-simulator.cmake
@@ -0,0 +1 @@
+include(apple-import-common.cmake)
diff --git a/Tests/RunCMake/CMakePackage/apple-import-ios.cmake b/Tests/RunCMake/CMakePackage/apple-import-ios.cmake
new file mode 100644
index 0000000..fa7ba53
--- /dev/null
+++ b/Tests/RunCMake/CMakePackage/apple-import-ios.cmake
@@ -0,0 +1 @@
+include(apple-import-common.cmake)
diff --git a/Tests/RunCMake/CMakePackage/apple-import-macos.cmake b/Tests/RunCMake/CMakePackage/apple-import-macos.cmake
new file mode 100644
index 0000000..fa7ba53
--- /dev/null
+++ b/Tests/RunCMake/CMakePackage/apple-import-macos.cmake
@@ -0,0 +1 @@
+include(apple-import-common.cmake)
diff --git a/Tests/RunCMake/CMakePackage/apple-import-tvos-simulator.cmake b/Tests/RunCMake/CMakePackage/apple-import-tvos-simulator.cmake
new file mode 100644
index 0000000..fa7ba53
--- /dev/null
+++ b/Tests/RunCMake/CMakePackage/apple-import-tvos-simulator.cmake
@@ -0,0 +1 @@
+include(apple-import-common.cmake)
diff --git a/Tests/RunCMake/CMakePackage/apple-import-tvos.cmake b/Tests/RunCMake/CMakePackage/apple-import-tvos.cmake
new file mode 100644
index 0000000..fa7ba53
--- /dev/null
+++ b/Tests/RunCMake/CMakePackage/apple-import-tvos.cmake
@@ -0,0 +1 @@
+include(apple-import-common.cmake)
diff --git a/Tests/RunCMake/CMakePackage/apple-import-visionos-simulator.cmake b/Tests/RunCMake/CMakePackage/apple-import-visionos-simulator.cmake
new file mode 100644
index 0000000..fa7ba53
--- /dev/null
+++ b/Tests/RunCMake/CMakePackage/apple-import-visionos-simulator.cmake
@@ -0,0 +1 @@
+include(apple-import-common.cmake)
diff --git a/Tests/RunCMake/CMakePackage/apple-import-visionos.cmake b/Tests/RunCMake/CMakePackage/apple-import-visionos.cmake
new file mode 100644
index 0000000..fa7ba53
--- /dev/null
+++ b/Tests/RunCMake/CMakePackage/apple-import-visionos.cmake
@@ -0,0 +1 @@
+include(apple-import-common.cmake)
diff --git a/Tests/RunCMake/CMakePackage/apple-import-watchos-simulator.cmake b/Tests/RunCMake/CMakePackage/apple-import-watchos-simulator.cmake
new file mode 100644
index 0000000..fa7ba53
--- /dev/null
+++ b/Tests/RunCMake/CMakePackage/apple-import-watchos-simulator.cmake
@@ -0,0 +1 @@
+include(apple-import-common.cmake)
diff --git a/Tests/RunCMake/CMakePackage/apple-import-watchos.cmake b/Tests/RunCMake/CMakePackage/apple-import-watchos.cmake
new file mode 100644
index 0000000..fa7ba53
--- /dev/null
+++ b/Tests/RunCMake/CMakePackage/apple-import-watchos.cmake
@@ -0,0 +1 @@
+include(apple-import-common.cmake)
diff --git a/Tests/RunCMake/CMakePackage/include/mylib.h b/Tests/RunCMake/CMakePackage/include/mylib.h
new file mode 100644
index 0000000..4955e74
--- /dev/null
+++ b/Tests/RunCMake/CMakePackage/include/mylib.h
@@ -0,0 +1,3 @@
+#pragma once
+
+extern int mylib(void);
diff --git a/Tests/RunCMake/CMakePackage/src/myexe.c b/Tests/RunCMake/CMakePackage/src/myexe.c
new file mode 100644
index 0000000..c1182a2
--- /dev/null
+++ b/Tests/RunCMake/CMakePackage/src/myexe.c
@@ -0,0 +1,6 @@
+#include <mylib.h> /* include by angle-bracket to find installed copy */
+
+int main(void)
+{
+ return mylib();
+}
diff --git a/Tests/RunCMake/CMakePackage/src/mylib.c b/Tests/RunCMake/CMakePackage/src/mylib.c
new file mode 100644
index 0000000..f4c047e
--- /dev/null
+++ b/Tests/RunCMake/CMakePackage/src/mylib.c
@@ -0,0 +1,4 @@
+int mylib(void)
+{
+ return 0;
+}
diff --git a/Tests/RunCMake/DependencyProviders/ProviderFirst-stdout.txt b/Tests/RunCMake/DependencyProviders/ProviderFirst-stdout.txt
new file mode 100644
index 0000000..53e554b
--- /dev/null
+++ b/Tests/RunCMake/DependencyProviders/ProviderFirst-stdout.txt
@@ -0,0 +1,6 @@
+-- Before cmake_language
+-- After cmake_language
+-- Intercepted FetchContent_MakeAvailable\(SomeDep\)
+-- Provider invoked for method FETCHCONTENT_MAKEAVAILABLE_SERIAL with args: SOURCE_DIR;.*/Tests/RunCMake/DependencyProviders;BINARY_DIR;.*/Tests/RunCMake/DependencyProviders/ProviderFirst-build/_deps/somedep-build;EXTERNALPROJECT_INTERNAL_ARGUMENT_SEPARATOR;SOURCE_SUBDIR;DoesNotExist;FIND_PACKAGE_ARGS;QUIET;NO_DEFAULT_PATH;COMPONENTS;abc
+-- FetchContent_MakeAvailable\(\) succeeded
+-- Configuring done
diff --git a/Tests/RunCMake/DependencyProviders/ProviderFirst.cmake b/Tests/RunCMake/DependencyProviders/ProviderFirst.cmake
new file mode 100644
index 0000000..b27c841
--- /dev/null
+++ b/Tests/RunCMake/DependencyProviders/ProviderFirst.cmake
@@ -0,0 +1,8 @@
+include(FetchContent)
+FetchContent_Declare(SomeDep
+ SOURCE_DIR ${CMAKE_CURRENT_LIST_DIR}
+ SOURCE_SUBDIR DoesNotExist
+ FIND_PACKAGE_ARGS NO_DEFAULT_PATH COMPONENTS abc
+)
+FetchContent_MakeAvailable(SomeDep)
+message(STATUS "FetchContent_MakeAvailable() succeeded")
diff --git a/Tests/RunCMake/DependencyProviders/RunCMakeTest.cmake b/Tests/RunCMake/DependencyProviders/RunCMakeTest.cmake
index 42893d2..300bbc1 100644
--- a/Tests/RunCMake/DependencyProviders/RunCMakeTest.cmake
+++ b/Tests/RunCMake/DependencyProviders/RunCMakeTest.cmake
@@ -61,6 +61,11 @@ run_cmake_with_options(RedirectFetchContentSerial
-D "provider_command=redirect_FetchContentSerial_provider"
-D "provider_methods=FETCHCONTENT_MAKEAVAILABLE_SERIAL"
)
+run_cmake_with_options(ProviderFirst
+ -D "CMAKE_PROJECT_TOP_LEVEL_INCLUDES=set_provider.cmake"
+ -D "provider_command=FetchContentSerial_provider"
+ -D "provider_methods=FETCHCONTENT_MAKEAVAILABLE_SERIAL"
+)
run_cmake_with_options(Bypass
-D "CMAKE_PROJECT_TOP_LEVEL_INCLUDES=set_provider.cmake"
-D "provider_command=forward_find_package"
diff --git a/Tests/RunCMake/target_link_libraries/ImportedTargetPerConfig.cmake b/Tests/RunCMake/target_link_libraries/ImportedTargetPerConfig.cmake
new file mode 100644
index 0000000..a143617
--- /dev/null
+++ b/Tests/RunCMake/target_link_libraries/ImportedTargetPerConfig.cmake
@@ -0,0 +1,27 @@
+enable_language(C)
+get_property(_isMultiConfig GLOBAL PROPERTY GENERATOR_IS_MULTI_CONFIG)
+if(NOT _isMultiConfig AND NOT CMAKE_BUILD_TYPE)
+ set(CMAKE_BUILD_TYPE "Debug")
+endif()
+
+add_library(StaticImported STATIC IMPORTED)
+
+# Test with no IMPORTED_CONFIGURATIONS, which works if the
+# imported target provides all exact-name configurations
+# built by this project. See issue #25515.
+set_target_properties(StaticImported PROPERTIES
+ IMPORTED_LOCATION_DEBUG "a"
+ IMPORTED_LOCATION_RELEASE "b"
+ IMPORTED_LOCATION_MINSIZEREL "c"
+ IMPORTED_LOCATION_RELWITHDEBINFO "d"
+ )
+
+add_library(StaticLib STATIC empty.c)
+
+# The Xcode generator queries imported targets for system
+# include directories, but without any specific config.
+set_source_files_properties(empty.c PROPERTIES
+ INCLUDE_DIRECTORIES "${CMAKE_CURRENT_SOURCE_DIR}"
+ )
+
+target_link_libraries(StaticLib PRIVATE StaticImported)
diff --git a/Tests/RunCMake/target_link_libraries/RunCMakeTest.cmake b/Tests/RunCMake/target_link_libraries/RunCMakeTest.cmake
index 0e3877a..1bcebb8 100644
--- a/Tests/RunCMake/target_link_libraries/RunCMakeTest.cmake
+++ b/Tests/RunCMake/target_link_libraries/RunCMakeTest.cmake
@@ -25,6 +25,7 @@ run_cmake(CMP0108-NEW-self-link)
run_cmake(ImportedTarget)
run_cmake(ImportedTargetStub)
run_cmake(ImportedTargetFailure)
+run_cmake(ImportedTargetPerConfig)
run_cmake(MixedSignature)
run_cmake(Separate-PRIVATE-LINK_PRIVATE-uses)
run_cmake(SharedDepNotTarget)