diff options
author | Gregor Jasny <gjasny@googlemail.com> | 2016-12-26 17:07:24 (GMT) |
---|---|---|
committer | Brad King <brad.king@kitware.com> | 2017-01-31 13:59:15 (GMT) |
commit | 071f8e78dda152d8759539fa390b25c7f58d3cc5 (patch) | |
tree | 0f9e71cbe2e9556d44079a4311f53ec343bf3236 /Source | |
parent | d525754eabef7a9f6e6696ae323a8ed965e12f2e (diff) | |
download | CMake-071f8e78dda152d8759539fa390b25c7f58d3cc5.zip CMake-071f8e78dda152d8759539fa390b25c7f58d3cc5.tar.gz CMake-071f8e78dda152d8759539fa390b25c7f58d3cc5.tar.bz2 |
Apple: Add support for static frameworks
Closes: #16432
Diffstat (limited to 'Source')
-rw-r--r-- | Source/cmGeneratorTarget.cxx | 3 | ||||
-rw-r--r-- | Source/cmGlobalXCodeGenerator.cxx | 39 | ||||
-rw-r--r-- | Source/cmInstallCommand.cxx | 42 | ||||
-rw-r--r-- | Source/cmTarget.cxx | 3 |
4 files changed, 71 insertions, 16 deletions
diff --git a/Source/cmGeneratorTarget.cxx b/Source/cmGeneratorTarget.cxx index dcf3764..6ce8140 100644 --- a/Source/cmGeneratorTarget.cxx +++ b/Source/cmGeneratorTarget.cxx @@ -5308,7 +5308,8 @@ bool cmGeneratorTarget::IsLinkable() const bool cmGeneratorTarget::IsFrameworkOnApple() const { - return (this->GetType() == cmStateEnums::SHARED_LIBRARY && + return ((this->GetType() == cmStateEnums::SHARED_LIBRARY || + this->GetType() == cmStateEnums::STATIC_LIBRARY) && this->Makefile->IsOn("APPLE") && this->GetPropertyAsBool("FRAMEWORK")); } diff --git a/Source/cmGlobalXCodeGenerator.cxx b/Source/cmGlobalXCodeGenerator.cxx index d448315..8627cf2 100644 --- a/Source/cmGlobalXCodeGenerator.cxx +++ b/Source/cmGlobalXCodeGenerator.cxx @@ -1816,8 +1816,34 @@ void cmGlobalXCodeGenerator::CreateBuildSettings(cmGeneratorTarget* gtgt, // Handle settings for each target type. switch (gtgt->GetType()) { - case cmStateEnums::OBJECT_LIBRARY: - case cmStateEnums::STATIC_LIBRARY: { + case cmStateEnums::STATIC_LIBRARY: + if (gtgt->GetPropertyAsBool("FRAMEWORK")) { + std::string fw_version = gtgt->GetFrameworkVersion(); + buildSettings->AddAttribute("FRAMEWORK_VERSION", + this->CreateString(fw_version)); + const char* ext = gtgt->GetProperty("BUNDLE_EXTENSION"); + if (ext) { + buildSettings->AddAttribute("WRAPPER_EXTENSION", + this->CreateString(ext)); + } + + std::string plist = this->ComputeInfoPListLocation(gtgt); + // Xcode will create the final version of Info.plist at build time, + // so let it replace the framework name. This avoids creating + // a per-configuration Info.plist file. + this->CurrentLocalGenerator->GenerateFrameworkInfoPList( + gtgt, "$(EXECUTABLE_NAME)", plist.c_str()); + buildSettings->AddAttribute("INFOPLIST_FILE", + this->CreateString(plist)); + buildSettings->AddAttribute("MACH_O_TYPE", + this->CreateString("staticlib")); + } else { + buildSettings->AddAttribute("LIBRARY_STYLE", + this->CreateString("STATIC")); + } + break; + + case cmStateEnums::OBJECT_LIBRARY: { buildSettings->AddAttribute("LIBRARY_STYLE", this->CreateString("STATIC")); break; @@ -2336,8 +2362,10 @@ const char* cmGlobalXCodeGenerator::GetTargetFileType( switch (target->GetType()) { case cmStateEnums::OBJECT_LIBRARY: - case cmStateEnums::STATIC_LIBRARY: return "archive.ar"; + case cmStateEnums::STATIC_LIBRARY: + return (target->GetPropertyAsBool("FRAMEWORK") ? "wrapper.framework" + : "archive.ar"); case cmStateEnums::MODULE_LIBRARY: if (target->IsXCTestOnApple()) return "wrapper.cfbundle"; @@ -2367,8 +2395,11 @@ const char* cmGlobalXCodeGenerator::GetTargetProductType( switch (target->GetType()) { case cmStateEnums::OBJECT_LIBRARY: - case cmStateEnums::STATIC_LIBRARY: return "com.apple.product-type.library.static"; + case cmStateEnums::STATIC_LIBRARY: + return (target->GetPropertyAsBool("FRAMEWORK") + ? "com.apple.product-type.framework" + : "com.apple.product-type.library.static"); case cmStateEnums::MODULE_LIBRARY: if (target->IsXCTestOnApple()) return "com.apple.product-type.bundle.unit-test"; diff --git a/Source/cmInstallCommand.cxx b/Source/cmInstallCommand.cxx index fadebb4..4c331c7 100644 --- a/Source/cmInstallCommand.cxx +++ b/Source/cmInstallCommand.cxx @@ -471,17 +471,39 @@ bool cmInstallCommand::HandleTargetsMode(std::vector<std::string> const& args) } } break; case cmStateEnums::STATIC_LIBRARY: { - // Static libraries use ARCHIVE properties. - if (!archiveArgs.GetDestination().empty()) { - archiveGenerator = - CreateInstallTargetGenerator(target, archiveArgs, false); + // If it is marked with FRAMEWORK property use the FRAMEWORK set of + // INSTALL properties. Otherwise, use the LIBRARY properties. + if (target.IsFrameworkOnApple()) { + // When in namelink only mode skip frameworks. + if (namelinkMode == cmInstallTargetGenerator::NamelinkModeOnly) { + continue; + } + + // Use the FRAMEWORK properties. + if (!frameworkArgs.GetDestination().empty()) { + frameworkGenerator = + CreateInstallTargetGenerator(target, frameworkArgs, false); + } else { + std::ostringstream e; + e << "TARGETS given no FRAMEWORK DESTINATION for static library " + "FRAMEWORK target \"" + << target.GetName() << "\"."; + this->SetError(e.str()); + return false; + } } else { - std::ostringstream e; - e << "TARGETS given no ARCHIVE DESTINATION for static library " - "target \"" - << target.GetName() << "\"."; - this->SetError(e.str()); - return false; + // Static libraries use ARCHIVE properties. + if (!archiveArgs.GetDestination().empty()) { + archiveGenerator = + CreateInstallTargetGenerator(target, archiveArgs, false); + } else { + std::ostringstream e; + e << "TARGETS given no ARCHIVE DESTINATION for static library " + "target \"" + << target.GetName() << "\"."; + this->SetError(e.str()); + return false; + } } } break; case cmStateEnums::MODULE_LIBRARY: { diff --git a/Source/cmTarget.cxx b/Source/cmTarget.cxx index 8c62c48..fe3472d 100644 --- a/Source/cmTarget.cxx +++ b/Source/cmTarget.cxx @@ -451,7 +451,8 @@ bool cmTarget::HasImportLibrary() const bool cmTarget::IsFrameworkOnApple() const { - return (this->GetType() == cmStateEnums::SHARED_LIBRARY && + return ((this->GetType() == cmStateEnums::SHARED_LIBRARY || + this->GetType() == cmStateEnums::STATIC_LIBRARY) && this->Makefile->IsOn("APPLE") && this->GetPropertyAsBool("FRAMEWORK")); } |