diff options
author | Nicolas Despres <nicolas.despres@gmail.com> | 2012-07-03 20:22:17 (GMT) |
---|---|---|
committer | Peter Kümmel <syntheticpp@gmx.net> | 2012-07-17 12:03:04 (GMT) |
commit | 21f156c03bec7595b58862a58a3446ec453f7d85 (patch) | |
tree | bff237ae139b271ebfd19373b57d62de11674d93 /Source/cmNinjaNormalTargetGenerator.cxx | |
parent | cdfa14a4f5a1432383c379baf741a713a198809a (diff) | |
download | CMake-21f156c03bec7595b58862a58a3446ec453f7d85.zip CMake-21f156c03bec7595b58862a58a3446ec453f7d85.tar.gz CMake-21f156c03bec7595b58862a58a3446ec453f7d85.tar.bz2 |
Ninja: Add support for OS X app bundles.
This patch fixes test Qt4Deploy on Darwin.
Thanks to Jamie Kirkpatrick <jkp@kirkconsulting.co.uk>
Diffstat (limited to 'Source/cmNinjaNormalTargetGenerator.cxx')
-rw-r--r-- | Source/cmNinjaNormalTargetGenerator.cxx | 65 |
1 files changed, 55 insertions, 10 deletions
diff --git a/Source/cmNinjaNormalTargetGenerator.cxx b/Source/cmNinjaNormalTargetGenerator.cxx index be7739e..7247ddc 100644 --- a/Source/cmNinjaNormalTargetGenerator.cxx +++ b/Source/cmNinjaNormalTargetGenerator.cxx @@ -33,6 +33,8 @@ cmNinjaNormalTargetGenerator(cmTarget* target) , TargetNameReal() , TargetNameImport() , TargetNamePDB() + , TargetLinkLanguage(0) + , MacContentDirectory() { this->TargetLinkLanguage = target->GetLinkerLanguage(this->GetConfigName()); if (target->GetType() == cmTarget::EXECUTABLE) @@ -55,6 +57,15 @@ cmNinjaNormalTargetGenerator(cmTarget* target) // ensure the directory exists (OutDir test) EnsureDirectoryExists(target->GetDirectory(this->GetConfigName())); } + + // TODO: Factor with the cmMakefileExecutableTargetGenerator constructor. + if(target->IsAppBundleOnApple()) + { + this->MacContentDirectory = target->GetDirectory(this->GetConfigName()); + this->MacContentDirectory += "/"; + this->MacContentDirectory += this->TargetNameOut; + this->MacContentDirectory += ".app/Contents/"; + } } cmNinjaNormalTargetGenerator::~cmNinjaNormalTargetGenerator() @@ -341,6 +352,29 @@ void cmNinjaNormalTargetGenerator::WriteLinkStatement() { cmTarget::TargetType targetType = this->GetTarget()->GetType(); + std::string targetOutput = ConvertToNinjaPath( + this->GetTarget()->GetFullPath(this->GetConfigName()).c_str()); + std::string targetOutputReal = ConvertToNinjaPath( + this->GetTarget()->GetFullPath(this->GetConfigName(), + /*implib=*/false, + /*realpath=*/true).c_str()); + std::string targetOutputImplib = ConvertToNinjaPath( + this->GetTarget()->GetFullPath(this->GetConfigName(), + /*implib=*/true).c_str()); + + if (this->GetTarget()->IsAppBundleOnApple()) + { + // Create the app bundle + std::string outpath; + this->CreateAppBundle(this->TargetNameOut, outpath); + + // Calculate the output path + targetOutput = outpath + this->TargetNameOut; + targetOutput = this->ConvertToNinjaPath(targetOutput.c_str()); + targetOutputReal = outpath + this->TargetNameReal; + targetOutputReal = this->ConvertToNinjaPath(targetOutputReal.c_str()); + } + // Write comments. cmGlobalNinjaGenerator::WriteDivider(this->GetBuildFileStream()); this->GetBuildFileStream() @@ -353,16 +387,6 @@ void cmNinjaNormalTargetGenerator::WriteLinkStatement() cmNinjaDeps emptyDeps; cmNinjaVars vars; - std::string targetOutput = ConvertToNinjaPath( - this->GetTarget()->GetFullPath(this->GetConfigName()).c_str()); - std::string targetOutputReal = ConvertToNinjaPath( - this->GetTarget()->GetFullPath(this->GetConfigName(), - /*implib=*/false, - /*realpath=*/true).c_str()); - std::string targetOutputImplib = ConvertToNinjaPath( - this->GetTarget()->GetFullPath(this->GetConfigName(), - /*implib=*/true).c_str()); - // Compute the comment. cmOStringStream comment; comment << "Link the " << this->GetVisibleTypeName() << " " @@ -576,3 +600,24 @@ void cmNinjaNormalTargetGenerator::WriteObjectLibStatement() this->GetGlobalGenerator()->AddTargetAlias(this->GetTargetName(), this->GetTarget()); } + +// TODO: Factor with cmMakefileExecutableTargetGenerator::CreateAppBundle(). +void +cmNinjaNormalTargetGenerator::CreateAppBundle(const std::string& targetName, + std::string& outpath) +{ + // Compute bundle directory names. + outpath = this->MacContentDirectory; + 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->MacContentDirectory + "Info.plist"; + this->GetLocalGenerator()->GenerateAppleInfoPList(this->GetTarget(), + targetName.c_str(), + plist.c_str()); + this->GetMakefile()->AddCMakeOutputFile(plist.c_str()); +} |