summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--Source/cmOSXBundleGenerator.cxx60
-rw-r--r--Source/cmOSXBundleGenerator.h3
-rw-r--r--Source/cmTarget.cxx107
-rw-r--r--Source/cmTarget.h13
4 files changed, 106 insertions, 77 deletions
diff --git a/Source/cmOSXBundleGenerator.cxx b/Source/cmOSXBundleGenerator.cxx
index 8788d42..c5a8d5f 100644
--- a/Source/cmOSXBundleGenerator.cxx
+++ b/Source/cmOSXBundleGenerator.cxx
@@ -39,49 +39,36 @@ cmOSXBundleGenerator(cmTarget* target,
, FrameworkVersion()
, MacContentFolders(0)
{
- if(this->Target->IsAppBundleOnApple())
- {
- this->MacContentDirectory = this->Target->GetDirectory(this->ConfigName);
- this->MacContentDirectory += "/";
- this->MacContentDirectory += this->TargetNameOut;
- this->MacContentDirectory += ".app/Contents/";
- }
- else if(this->Target->IsFrameworkOnApple())
- {
+ if (this->MustSkip())
+ return;
+
+ this->MacContentDirectory =
+ this->Target->GetMacContentDirectory(this->ConfigName,
+ /*implib*/ false,
+ /*includeMacOS*/ false);
+ if(this->Target->IsFrameworkOnApple())
this->FrameworkVersion = this->Target->GetFrameworkVersion();
- this->MacContentDirectory = this->Target->GetDirectory(this->ConfigName);
- this->MacContentDirectory += "/";
- this->MacContentDirectory += this->TargetNameOut;
- this->MacContentDirectory += ".framework/Versions/";
- this->MacContentDirectory += this->FrameworkVersion;
- this->MacContentDirectory += "/";
- }
- else if(this->Target->IsCFBundleOnApple())
- {
- this->MacContentDirectory = this->Target->GetDirectory(this->ConfigName);
- this->MacContentDirectory += "/";
- this->MacContentDirectory += this->TargetNameOut;
- this->MacContentDirectory += ".";
- const char *ext = this->Target->GetProperty("BUNDLE_EXTENSION");
- if (!ext)
- {
- ext = "bundle";
- }
- this->MacContentDirectory += ext;
- this->MacContentDirectory += "/Contents/";
- }
+}
+
+//----------------------------------------------------------------------------
+bool cmOSXBundleGenerator::MustSkip()
+{
+ return !this->Target->HaveWellDefinedOutputFiles();
}
//----------------------------------------------------------------------------
void cmOSXBundleGenerator::CreateAppBundle(std::string& targetName,
std::string& outpath)
{
+ if (this->MustSkip())
+ return;
+
// Compute bundle directory names.
outpath = this->MacContentDirectory;
outpath += "MacOS";
cmSystemTools::MakeDirectory(outpath.c_str());
- this->Makefile->AddCMakeOutputFile(outpath.c_str());
outpath += "/";
+ this->Makefile->AddCMakeOutputFile(outpath.c_str());
// Configure the Info.plist file. Note that it needs the executable name
// to be set.
@@ -95,6 +82,9 @@ void cmOSXBundleGenerator::CreateAppBundle(std::string& targetName,
//----------------------------------------------------------------------------
void cmOSXBundleGenerator::CreateFramework(std::string const& targetName)
{
+ if (this->MustSkip())
+ return;
+
assert(this->MacContentFolders);
// Configure the Info.plist file into the Resources directory.
@@ -184,12 +174,15 @@ void cmOSXBundleGenerator::CreateFramework(std::string const& targetName)
void cmOSXBundleGenerator::CreateCFBundle(std::string& targetName,
std::string& outpath)
{
+ if (this->MustSkip())
+ return;
+
// Compute bundle directory names.
outpath = this->MacContentDirectory;
outpath += "MacOS";
cmSystemTools::MakeDirectory(outpath.c_str());
- this->Makefile->AddCMakeOutputFile(outpath.c_str());
outpath += "/";
+ this->Makefile->AddCMakeOutputFile(outpath.c_str());
// Configure the Info.plist file. Note that it needs the executable name
// to be set.
@@ -207,6 +200,9 @@ cmOSXBundleGenerator::
GenerateMacOSXContentStatements(std::vector<cmSourceFile*> const& sources,
MacOSXContentGeneratorType* generator)
{
+ if (this->MustSkip())
+ return;
+
for(std::vector<cmSourceFile*>::const_iterator
si = sources.begin(); si != sources.end(); ++si)
{
diff --git a/Source/cmOSXBundleGenerator.h b/Source/cmOSXBundleGenerator.h
index dc6a8ae..c13ca36 100644
--- a/Source/cmOSXBundleGenerator.h
+++ b/Source/cmOSXBundleGenerator.h
@@ -53,6 +53,9 @@ public:
{ this->MacContentFolders = macContentFolders; }
private:
+ bool MustSkip();
+
+private:
cmTarget* Target;
cmMakefile* Makefile;
cmLocalGenerator* LocalGenerator;
diff --git a/Source/cmTarget.cxx b/Source/cmTarget.cxx
index aaa622f..490acb6 100644
--- a/Source/cmTarget.cxx
+++ b/Source/cmTarget.cxx
@@ -2483,6 +2483,16 @@ void cmTarget::MarkAsImported()
}
//----------------------------------------------------------------------------
+bool cmTarget::HaveWellDefinedOutputFiles()
+{
+ return
+ this->GetType() == cmTarget::STATIC_LIBRARY ||
+ this->GetType() == cmTarget::SHARED_LIBRARY ||
+ this->GetType() == cmTarget::MODULE_LIBRARY ||
+ this->GetType() == cmTarget::EXECUTABLE;
+}
+
+//----------------------------------------------------------------------------
cmTarget::OutputInfo const* cmTarget::GetOutputInfo(const char* config)
{
// There is no output information for imported targets.
@@ -2492,10 +2502,7 @@ cmTarget::OutputInfo const* cmTarget::GetOutputInfo(const char* config)
}
// Only libraries and executables have well-defined output files.
- if(this->GetType() != cmTarget::STATIC_LIBRARY &&
- this->GetType() != cmTarget::SHARED_LIBRARY &&
- this->GetType() != cmTarget::MODULE_LIBRARY &&
- this->GetType() != cmTarget::EXECUTABLE)
+ if(!this->HaveWellDefinedOutputFiles())
{
std::string msg = "cmTarget::GetOutputInfo called for ";
msg += this->GetName();
@@ -2586,18 +2593,7 @@ const char* cmTarget::NormalGetLocation(const char* config)
this->Location += cfgid;
this->Location += "/";
}
- if(this->IsAppBundleOnApple())
- {
- this->Location += this->GetFullName(config, false);
- this->Location += ".app/Contents/MacOS/";
- }
- if(this->IsFrameworkOnApple())
- {
- this->Location += this->GetFullName(config, false);
- this->Location += ".framework/Versions/";
- this->Location += this->GetFrameworkVersion();
- this->Location += "/";
- }
+ this->Location = this->BuildMacContentDirectory(this->Location, config);
this->Location += this->GetFullName(config, false);
return this->Location.c_str();
}
@@ -3169,35 +3165,7 @@ std::string cmTarget::GetFullPath(const char* config, bool implib,
std::string cmTarget::NormalGetFullPath(const char* config, bool implib,
bool realname)
{
- // TODO: Re-factor with cmOSXBundleGenerator's constructor.
- // Start with the output directory for the target.
- std::string fpath = this->GetDirectory(config, implib);
- fpath += "/";
-
- if(this->IsAppBundleOnApple())
- {
- fpath += this->GetFullName(config, false);
- fpath += ".app/Contents/MacOS/";
- }
- if(this->IsFrameworkOnApple())
- {
- fpath += this->GetFullName(config, false);
- fpath += ".framework/Versions/";
- fpath += this->GetFrameworkVersion();
- fpath += "/";
- }
- if(this->IsCFBundleOnApple())
- {
- fpath += this->GetFullName(config, false);
- fpath += ".";
- const char *ext = this->GetProperty("BUNDLE_EXTENSION");
- if (!ext)
- {
- ext = "bundle";
- }
- fpath += ext;
- fpath += "/Contents/MacOS/";
- }
+ std::string fpath = this->GetMacContentDirectory(config, implib);
// Add the full name of the target.
if(implib)
@@ -4747,6 +4715,55 @@ std::vector<std::string> cmTarget::GetIncludeDirectories()
}
//----------------------------------------------------------------------------
+std::string cmTarget::BuildMacContentDirectory(const std::string& base,
+ const char* config,
+ bool includeMacOS)
+{
+ std::string fpath = base;
+ if(this->IsAppBundleOnApple())
+ {
+ fpath += this->GetFullName(config, false);
+ fpath += ".app/Contents/";
+ if(includeMacOS)
+ fpath += "MacOS/";
+ }
+ if(this->IsFrameworkOnApple())
+ {
+ fpath += this->GetFullName(config, false);
+ fpath += ".framework/Versions/";
+ fpath += this->GetFrameworkVersion();
+ fpath += "/";
+ }
+ if(this->IsCFBundleOnApple())
+ {
+ fpath += this->GetFullName(config, false);
+ fpath += ".";
+ const char *ext = this->GetProperty("BUNDLE_EXTENSION");
+ if (!ext)
+ {
+ ext = "bundle";
+ }
+ fpath += ext;
+ fpath += "/Contents/";
+ if(includeMacOS)
+ fpath += "MacOS/";
+ }
+ return fpath;
+}
+
+//----------------------------------------------------------------------------
+std::string cmTarget::GetMacContentDirectory(const char* config,
+ bool implib,
+ bool includeMacOS)
+{
+ // Start with the output directory for the target.
+ std::string fpath = this->GetDirectory(config, implib);
+ fpath += "/";
+ fpath = this->BuildMacContentDirectory(fpath, config, includeMacOS);
+ return fpath;
+}
+
+//----------------------------------------------------------------------------
cmTargetLinkInformationMap
::cmTargetLinkInformationMap(cmTargetLinkInformationMap const& r): derived()
{
diff --git a/Source/cmTarget.h b/Source/cmTarget.h
index d70cacd..aa14049 100644
--- a/Source/cmTarget.h
+++ b/Source/cmTarget.h
@@ -465,6 +465,19 @@ public:
/** Get the include directories for this target. */
std::vector<std::string> GetIncludeDirectories();
+ /** Append to @a base the mac content directory and return it. */
+ std::string BuildMacContentDirectory(const std::string& base,
+ const char* config = 0,
+ bool includeMacOS = true);
+
+ /** @return the mac content directory for this target. */
+ std::string GetMacContentDirectory(const char* config = 0,
+ bool implib = false,
+ bool includeMacOS = true);
+
+ /** @return whether this target have a well defined output file name. */
+ bool HaveWellDefinedOutputFiles();
+
private:
/**
* A list of direct dependencies. Use in conjunction with DependencyMap.