diff options
author | Nicolas Despres <nicolas.despres@gmail.com> | 2012-07-16 14:00:40 (GMT) |
---|---|---|
committer | Peter Kümmel <syntheticpp@gmx.net> | 2012-07-17 12:03:09 (GMT) |
commit | 7bb56c511eaabf2071cd311b6cf14453651127e4 (patch) | |
tree | c9c9d4938652d59af72835c68dcdc1e3f51306da | |
parent | 03bdaf545369d4438a8aece8d3cec603d3a99727 (diff) | |
download | CMake-7bb56c511eaabf2071cd311b6cf14453651127e4.zip CMake-7bb56c511eaabf2071cd311b6cf14453651127e4.tar.gz CMake-7bb56c511eaabf2071cd311b6cf14453651127e4.tar.bz2 |
Re-factor CFBundle generation.
-rw-r--r-- | Source/cmMakefileLibraryTargetGenerator.cxx | 29 | ||||
-rw-r--r-- | Source/cmMakefileLibraryTargetGenerator.h | 1 | ||||
-rw-r--r-- | Source/cmNinjaNormalTargetGenerator.cxx | 35 | ||||
-rw-r--r-- | Source/cmNinjaNormalTargetGenerator.h | 1 | ||||
-rw-r--r-- | Source/cmOSXBundleGenerator.cxx | 31 | ||||
-rw-r--r-- | Source/cmOSXBundleGenerator.h | 3 |
6 files changed, 39 insertions, 61 deletions
diff --git a/Source/cmMakefileLibraryTargetGenerator.cxx b/Source/cmMakefileLibraryTargetGenerator.cxx index 4331af6..a655504 100644 --- a/Source/cmMakefileLibraryTargetGenerator.cxx +++ b/Source/cmMakefileLibraryTargetGenerator.cxx @@ -28,11 +28,7 @@ cmMakefileLibraryTargetGenerator cmMakefileTargetGenerator(target), OSXBundleGenerator(0) { - if(this->Target->IsCFBundleOnApple()) - { - target->SetProperty("PREFIX", ""); - target->SetProperty("SUFFIX", ""); - } + cmOSXBundleGenerator::PrepareTargetProperties(this->Target); this->CustomCommandDriver = OnDepends; this->Target->GetLibraryNames( @@ -250,27 +246,6 @@ void cmMakefileLibraryTargetGenerator::WriteFrameworkRules(bool relink) } //---------------------------------------------------------------------------- -void -cmMakefileLibraryTargetGenerator::CreateCFBundle(std::string& targetName, - std::string& outpath) -{ - // Compute bundle directory names. - outpath = this->MacContentDirectory; - outpath += "MacOS"; - cmSystemTools::MakeDirectory(outpath.c_str()); - this->Makefile->AddCMakeOutputFile(outpath.c_str()); - outpath += "/"; - - // Configure the Info.plist file. Note that it needs the executable name - // to be set. - std::string plist = this->MacContentDirectory + "Info.plist"; - this->LocalGenerator->GenerateAppleInfoPList(this->Target, - targetName.c_str(), - plist.c_str()); - this->Makefile->AddCMakeOutputFile(plist.c_str()); -} - -//---------------------------------------------------------------------------- void cmMakefileLibraryTargetGenerator::WriteLibraryRules (const char* linkRuleVar, const char* extraFlags, bool relink) { @@ -328,7 +303,7 @@ void cmMakefileLibraryTargetGenerator::WriteLibraryRules { outpath = this->Target->GetDirectory(this->ConfigName); outpath += "/"; - this->CreateCFBundle(targetName, outpath); + this->OSXBundleGenerator->CreateCFBundle(targetName, outpath); } else if(relink) { diff --git a/Source/cmMakefileLibraryTargetGenerator.h b/Source/cmMakefileLibraryTargetGenerator.h index 0d4d777..ee56f6c 100644 --- a/Source/cmMakefileLibraryTargetGenerator.h +++ b/Source/cmMakefileLibraryTargetGenerator.h @@ -36,7 +36,6 @@ protected: bool relink); // MacOSX Framework support methods void WriteFrameworkRules(bool relink); - void CreateCFBundle(std::string& targetName, std::string& outpath); // Store the computd framework version for OS X Frameworks. std::string FrameworkVersion; diff --git a/Source/cmNinjaNormalTargetGenerator.cxx b/Source/cmNinjaNormalTargetGenerator.cxx index d4fc02b..8d0493f 100644 --- a/Source/cmNinjaNormalTargetGenerator.cxx +++ b/Source/cmNinjaNormalTargetGenerator.cxx @@ -36,12 +36,7 @@ cmNinjaNormalTargetGenerator(cmTarget* target) , TargetNamePDB() , TargetLinkLanguage(0) { - // TODO: Re-factor with cmMakefileLibraryTargetGenerator's constructor. - if(target->IsCFBundleOnApple()) - { - target->SetProperty("PREFIX", ""); - target->SetProperty("SUFFIX", ""); - } + cmOSXBundleGenerator::PrepareTargetProperties(target); this->TargetLinkLanguage = target->GetLinkerLanguage(this->GetConfigName()); if (target->GetType() == cmTarget::EXECUTABLE) @@ -383,13 +378,11 @@ void cmNinjaNormalTargetGenerator::WriteLinkStatement() // Create the library framework. this->OSXBundleGenerator->CreateFramework(this->TargetNameOut); } - // TODO: Re-factor with cmMakefileLibraryTargetGenerator::WriteLibraryRules. else if(this->GetTarget()->IsCFBundleOnApple()) { + // Create the core foundation bundle. std::string outpath; - outpath = this->GetTarget()->GetDirectory(this->GetConfigName()); - outpath += "/"; - this->CreateCFBundle(this->TargetNameOut, outpath); + this->OSXBundleGenerator->CreateCFBundle(this->TargetNameOut, outpath); } // Write comments. @@ -617,25 +610,3 @@ void cmNinjaNormalTargetGenerator::WriteObjectLibStatement() this->GetGlobalGenerator()->AddTargetAlias(this->GetTargetName(), this->GetTarget()); } - -//---------------------------------------------------------------------------- -// TODO: Re-factor with cmMakefileLibraryTargetGenerator::CreateCFBundle. -void cmNinjaNormalTargetGenerator::CreateCFBundle(std::string& targetName, - std::string& outpath) -{ - // Compute bundle directory names. - outpath = this->OSXBundleGenerator->GetMacContentDirectory(); - outpath += "MacOS"; - cmSystemTools::MakeDirectory(outpath.c_str()); - this->GetMakefile()->AddCMakeOutputFile(outpath.c_str()); - outpath += "/"; - - // Configure the Info.plist file. Note that it needs the executable name - // to be set. - std::string plist = this->OSXBundleGenerator->GetMacContentDirectory(); - plist += "Info.plist"; - this->GetLocalGenerator()->GenerateAppleInfoPList(this->GetTarget(), - targetName.c_str(), - plist.c_str()); - this->GetMakefile()->AddCMakeOutputFile(plist.c_str()); -} diff --git a/Source/cmNinjaNormalTargetGenerator.h b/Source/cmNinjaNormalTargetGenerator.h index 74e10cf..284804b 100644 --- a/Source/cmNinjaNormalTargetGenerator.h +++ b/Source/cmNinjaNormalTargetGenerator.h @@ -38,7 +38,6 @@ private: void WriteLinkStatement(); void WriteObjectLibStatement(); std::vector<std::string> ComputeLinkCmd(); - void CreateCFBundle(std::string& targetName, std::string& outpath); private: // Target name info. diff --git a/Source/cmOSXBundleGenerator.cxx b/Source/cmOSXBundleGenerator.cxx index d7afcd6..b3210eb 100644 --- a/Source/cmOSXBundleGenerator.cxx +++ b/Source/cmOSXBundleGenerator.cxx @@ -16,6 +16,16 @@ #include <cassert> +void cmOSXBundleGenerator::PrepareTargetProperties(cmTarget* target) +{ + if(target->IsCFBundleOnApple()) + { + target->SetProperty("PREFIX", ""); + target->SetProperty("SUFFIX", ""); + } +} + +//---------------------------------------------------------------------------- cmOSXBundleGenerator:: cmOSXBundleGenerator(cmTarget* target, std::string targetNameOut, @@ -169,3 +179,24 @@ void cmOSXBundleGenerator::CreateFramework(std::string const& targetName) this->Makefile->AddCMakeOutputFile(newName.c_str()); } } + +//---------------------------------------------------------------------------- +void cmOSXBundleGenerator::CreateCFBundle(std::string& targetName, + std::string& outpath) +{ + // Compute bundle directory names. + outpath = this->MacContentDirectory; + outpath += "MacOS"; + cmSystemTools::MakeDirectory(outpath.c_str()); + this->Makefile->AddCMakeOutputFile(outpath.c_str()); + outpath += "/"; + + // Configure the Info.plist file. Note that it needs the executable name + // to be set. + std::string plist = this->MacContentDirectory; + plist += "Info.plist"; + this->LocalGenerator->GenerateAppleInfoPList(this->Target, + targetName.c_str(), + plist.c_str()); + this->Makefile->AddCMakeOutputFile(plist.c_str()); +} diff --git a/Source/cmOSXBundleGenerator.h b/Source/cmOSXBundleGenerator.h index 29ce7c4..38092b9 100644 --- a/Source/cmOSXBundleGenerator.h +++ b/Source/cmOSXBundleGenerator.h @@ -24,12 +24,15 @@ class cmLocalGenerator; class cmOSXBundleGenerator { public: + static void PrepareTargetProperties(cmTarget* target); + cmOSXBundleGenerator(cmTarget* target, std::string targetNameOut, const char* configName); void CreateAppBundle(std::string& targetName, std::string& outpath); void CreateFramework(std::string const& targetName); + void CreateCFBundle(std::string& targetName, std::string& outpath); std::string GetMacContentDirectory() const { return this->MacContentDirectory; } |