summaryrefslogtreecommitdiffstats
path: root/Source
diff options
context:
space:
mode:
authorNicolas Despres <nicolas.despres@gmail.com>2012-07-05 16:31:17 (GMT)
committerPeter Kümmel <syntheticpp@gmx.net>2012-07-17 12:03:05 (GMT)
commita7b4e3a57b418aa4569cf3bbd484212e9b9b5c77 (patch)
tree5d42f3b305edf34ad6d492f92b92a0d18ec3cfe3 /Source
parent21f156c03bec7595b58862a58a3446ec453f7d85 (diff)
downloadCMake-a7b4e3a57b418aa4569cf3bbd484212e9b9b5c77.zip
CMake-a7b4e3a57b418aa4569cf3bbd484212e9b9b5c77.tar.gz
CMake-a7b4e3a57b418aa4569cf3bbd484212e9b9b5c77.tar.bz2
Ninja: Add support for OX X library framework.
This patch fixes test ExportImport on Darwin.
Diffstat (limited to 'Source')
-rw-r--r--Source/cmNinjaNormalTargetGenerator.cxx120
-rw-r--r--Source/cmNinjaNormalTargetGenerator.h2
2 files changed, 122 insertions, 0 deletions
diff --git a/Source/cmNinjaNormalTargetGenerator.cxx b/Source/cmNinjaNormalTargetGenerator.cxx
index 7247ddc..6a5fd6b 100644
--- a/Source/cmNinjaNormalTargetGenerator.cxx
+++ b/Source/cmNinjaNormalTargetGenerator.cxx
@@ -35,6 +35,7 @@ cmNinjaNormalTargetGenerator(cmTarget* target)
, TargetNamePDB()
, TargetLinkLanguage(0)
, MacContentDirectory()
+ , FrameworkVersion()
{
this->TargetLinkLanguage = target->GetLinkerLanguage(this->GetConfigName());
if (target->GetType() == cmTarget::EXECUTABLE)
@@ -66,6 +67,31 @@ cmNinjaNormalTargetGenerator(cmTarget* target)
this->MacContentDirectory += this->TargetNameOut;
this->MacContentDirectory += ".app/Contents/";
}
+ // TODO: Factor with the cmMakefileLibraryTargetGenerator constructor.
+ else if(target->IsFrameworkOnApple())
+ {
+ this->FrameworkVersion = target->GetFrameworkVersion();
+ this->MacContentDirectory = target->GetDirectory(this->GetConfigName());
+ this->MacContentDirectory += "/";
+ this->MacContentDirectory += this->TargetNameOut;
+ this->MacContentDirectory += ".framework/Versions/";
+ this->MacContentDirectory += this->FrameworkVersion;
+ this->MacContentDirectory += "/";
+ }
+ else if(target->IsCFBundleOnApple())
+ {
+ this->MacContentDirectory = target->GetDirectory(this->GetConfigName());
+ this->MacContentDirectory += "/";
+ this->MacContentDirectory += this->TargetNameOut;
+ this->MacContentDirectory += ".";
+ const char *ext = target->GetProperty("BUNDLE_EXTENSION");
+ if (!ext)
+ {
+ ext = "bundle";
+ }
+ this->MacContentDirectory += ext;
+ this->MacContentDirectory += "/Contents/";
+ }
}
cmNinjaNormalTargetGenerator::~cmNinjaNormalTargetGenerator()
@@ -374,6 +400,11 @@ void cmNinjaNormalTargetGenerator::WriteLinkStatement()
targetOutputReal = outpath + this->TargetNameReal;
targetOutputReal = this->ConvertToNinjaPath(targetOutputReal.c_str());
}
+ else if (this->GetTarget()->IsFrameworkOnApple())
+ {
+ // Create the library framework.
+ this->CreateFramework(this->TargetNameOut);
+ }
// Write comments.
cmGlobalNinjaGenerator::WriteDivider(this->GetBuildFileStream());
@@ -621,3 +652,92 @@ cmNinjaNormalTargetGenerator::CreateAppBundle(const std::string& targetName,
plist.c_str());
this->GetMakefile()->AddCMakeOutputFile(plist.c_str());
}
+
+// TODO: Factor with cmMakefileLibraryTargetGenerator::CreateFramework().
+void
+cmNinjaNormalTargetGenerator::CreateFramework(std::string const& targetName)
+{
+ // Create the Resources directory.
+ std::string resources = this->MacContentDirectory + "Resources/";
+ cmSystemTools::MakeDirectory(resources.c_str());
+
+ // Configure the Info.plist file into the Resources directory.
+ std::set<cmStdString> macContentFolders;
+ macContentFolders.insert("Resources");
+ std::string plist = resources + "Info.plist";
+ this->GetLocalGenerator()->GenerateFrameworkInfoPList(this->GetTarget(),
+ targetName.c_str(),
+ plist.c_str());
+
+ // TODO: Use the cmMakefileTargetGenerator::ExtraFiles vector to
+ // drive rules to create these files at build time.
+ std::string oldName;
+ std::string newName;
+
+ // Compute the location of the top-level foo.framework directory.
+ std::string top = this->GetTarget()->GetDirectory(this->GetConfigName());
+ top += "/";
+ top += this->TargetNameOut;
+ top += ".framework/";
+
+ // Make foo.framework/Versions
+ std::string versions = top;
+ versions += "Versions";
+ cmSystemTools::MakeDirectory(versions.c_str());
+
+ // Make foo.framework/Versions/version
+ std::string version = versions;
+ version += "/";
+ version += this->FrameworkVersion;
+ cmSystemTools::MakeDirectory(version.c_str());
+
+ // Current -> version
+ oldName = this->FrameworkVersion;
+ newName = versions;
+ newName += "/Current";
+ cmSystemTools::RemoveFile(newName.c_str());
+ cmSystemTools::CreateSymlink(oldName.c_str(), newName.c_str());
+ this->GetMakefile()->AddCMakeOutputFile(newName.c_str());
+
+ // foo -> Versions/Current/foo
+ oldName = "Versions/Current/";
+ oldName += this->TargetNameOut;
+ newName = top;
+ newName += this->TargetNameOut;
+ cmSystemTools::RemoveFile(newName.c_str());
+ cmSystemTools::CreateSymlink(oldName.c_str(), newName.c_str());
+ this->GetMakefile()->AddCMakeOutputFile(newName.c_str());
+
+ // Resources -> Versions/Current/Resources
+ if(macContentFolders.find("Resources") != macContentFolders.end())
+ {
+ oldName = "Versions/Current/Resources";
+ newName = top;
+ newName += "Resources";
+ cmSystemTools::RemoveFile(newName.c_str());
+ cmSystemTools::CreateSymlink(oldName.c_str(), newName.c_str());
+ this->GetMakefile()->AddCMakeOutputFile(newName.c_str());
+ }
+
+ // Headers -> Versions/Current/Headers
+ if(macContentFolders.find("Headers") != macContentFolders.end())
+ {
+ oldName = "Versions/Current/Headers";
+ newName = top;
+ newName += "Headers";
+ cmSystemTools::RemoveFile(newName.c_str());
+ cmSystemTools::CreateSymlink(oldName.c_str(), newName.c_str());
+ this->GetMakefile()->AddCMakeOutputFile(newName.c_str());
+ }
+
+ // PrivateHeaders -> Versions/Current/PrivateHeaders
+ if(macContentFolders.find("PrivateHeaders") != macContentFolders.end())
+ {
+ oldName = "Versions/Current/PrivateHeaders";
+ newName = top;
+ newName += "PrivateHeaders";
+ cmSystemTools::RemoveFile(newName.c_str());
+ cmSystemTools::CreateSymlink(oldName.c_str(), newName.c_str());
+ this->GetMakefile()->AddCMakeOutputFile(newName.c_str());
+ }
+}
diff --git a/Source/cmNinjaNormalTargetGenerator.h b/Source/cmNinjaNormalTargetGenerator.h
index cee685d..c48a8ec 100644
--- a/Source/cmNinjaNormalTargetGenerator.h
+++ b/Source/cmNinjaNormalTargetGenerator.h
@@ -35,6 +35,7 @@ private:
void WriteObjectLibStatement();
std::vector<std::string> ComputeLinkCmd();
void CreateAppBundle(const std::string& targetName, std::string& outpath);
+ void CreateFramework(std::string const& targetName);
private:
// Target name info.
@@ -45,6 +46,7 @@ private:
std::string TargetNamePDB;
const char *TargetLinkLanguage;
std::string MacContentDirectory;
+ std::string FrameworkVersion;
};
#endif // ! cmNinjaNormalTargetGenerator_h