summaryrefslogtreecommitdiffstats
path: root/Source
diff options
context:
space:
mode:
authorBrad King <brad.king@kitware.com>2017-01-31 14:04:16 (GMT)
committerCMake Topic Stage <kwrobot@kitware.com>2017-01-31 14:04:16 (GMT)
commitf012a95836e14e12f5a445abd72fa79599736641 (patch)
tree5df5ea8174a7a1d35b7f383cd641bfb7644c5a7c /Source
parent8a76536e78e9084fb9636b2f0c57121522cfbbaf (diff)
parent071f8e78dda152d8759539fa390b25c7f58d3cc5 (diff)
downloadCMake-f012a95836e14e12f5a445abd72fa79599736641.zip
CMake-f012a95836e14e12f5a445abd72fa79599736641.tar.gz
CMake-f012a95836e14e12f5a445abd72fa79599736641.tar.bz2
Merge topic '16432-static-frameworks'
071f8e78 Apple: Add support for static frameworks d525754e Xcode: Refactor RunCMake.Framework test to prepare for static frameworks 45405f00 Xcode: Ignore Xcode project warning until issue is fixed 50e1c105 Makefile: For static libraries remove only the "real" lib before creating 8643ca75 Makefile: Re-order list of files to clean
Diffstat (limited to 'Source')
-rw-r--r--Source/cmGeneratorTarget.cxx3
-rw-r--r--Source/cmGlobalXCodeGenerator.cxx39
-rw-r--r--Source/cmInstallCommand.cxx42
-rw-r--r--Source/cmMakefileLibraryTargetGenerator.cxx35
-rw-r--r--Source/cmTarget.cxx3
5 files changed, 89 insertions, 33 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/cmMakefileLibraryTargetGenerator.cxx b/Source/cmMakefileLibraryTargetGenerator.cxx
index 27b7c21..ff8b604 100644
--- a/Source/cmMakefileLibraryTargetGenerator.cxx
+++ b/Source/cmMakefileLibraryTargetGenerator.cxx
@@ -597,12 +597,26 @@ void cmMakefileLibraryTargetGenerator::WriteLibraryRules(
// Clean files associated with this library.
std::vector<std::string> libCleanFiles;
libCleanFiles.push_back(this->LocalGenerator->MaybeConvertToRelativePath(
- this->LocalGenerator->GetCurrentBinaryDirectory(), targetFullPath));
- if (targetNameReal != targetName) {
+ this->LocalGenerator->GetCurrentBinaryDirectory(), targetFullPathReal));
+
+ std::vector<std::string> commands1;
+ // Add a command to remove any existing files for this library.
+ // for static libs only
+ if (this->GeneratorTarget->GetType() == cmStateEnums::STATIC_LIBRARY) {
+ this->LocalGenerator->AppendCleanCommand(commands1, libCleanFiles,
+ this->GeneratorTarget, "target");
+ this->LocalGenerator->CreateCDCommand(
+ commands1, this->Makefile->GetCurrentBinaryDirectory(),
+ this->LocalGenerator->GetBinaryDirectory());
+ commands.insert(commands.end(), commands1.begin(), commands1.end());
+ commands1.clear();
+ }
+
+ if (targetName != targetNameReal) {
libCleanFiles.push_back(this->LocalGenerator->MaybeConvertToRelativePath(
- this->LocalGenerator->GetCurrentBinaryDirectory(), targetFullPathReal));
+ this->LocalGenerator->GetCurrentBinaryDirectory(), targetFullPath));
}
- if (targetNameSO != targetName && targetNameSO != targetNameReal) {
+ if (targetNameSO != targetNameReal && targetNameSO != targetName) {
libCleanFiles.push_back(this->LocalGenerator->MaybeConvertToRelativePath(
this->LocalGenerator->GetCurrentBinaryDirectory(), targetFullPathSO));
}
@@ -634,19 +648,6 @@ void cmMakefileLibraryTargetGenerator::WriteLibraryRules(
}
#endif
- std::vector<std::string> commands1;
- // Add a command to remove any existing files for this library.
- // for static libs only
- if (this->GeneratorTarget->GetType() == cmStateEnums::STATIC_LIBRARY) {
- this->LocalGenerator->AppendCleanCommand(commands1, libCleanFiles,
- this->GeneratorTarget, "target");
- this->LocalGenerator->CreateCDCommand(
- commands1, this->Makefile->GetCurrentBinaryDirectory(),
- this->LocalGenerator->GetBinaryDirectory());
- commands.insert(commands.end(), commands1.begin(), commands1.end());
- commands1.clear();
- }
-
// Add the pre-build and pre-link rules building but not when relinking.
if (!relink) {
this->LocalGenerator->AppendCustomCommands(
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"));
}