summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--Source/cmGeneratorTarget.cxx22
-rw-r--r--Tests/RunCMake/target_link_libraries/ImportedTargetPerConfig.cmake27
-rw-r--r--Tests/RunCMake/target_link_libraries/RunCMakeTest.cmake1
3 files changed, 45 insertions, 5 deletions
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/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)