diff options
author | Nicolas Despres <nicolas.despres@gmail.com> | 2012-07-16 17:42:56 (GMT) |
---|---|---|
committer | Peter Kümmel <syntheticpp@gmx.net> | 2012-07-17 12:03:11 (GMT) |
commit | f36c7b0bbe79592c7540740fe9cef747346ae2a4 (patch) | |
tree | 33b02165f26ba3ed9111f1018f6e7b29a4918e14 /Source/cmTarget.cxx | |
parent | 5d885db416a4cec236ba6422868dc3db3d766bc4 (diff) | |
download | CMake-f36c7b0bbe79592c7540740fe9cef747346ae2a4.zip CMake-f36c7b0bbe79592c7540740fe9cef747346ae2a4.tar.gz CMake-f36c7b0bbe79592c7540740fe9cef747346ae2a4.tar.bz2 |
Re-factor Mac OS X content directory computation.
Diffstat (limited to 'Source/cmTarget.cxx')
-rw-r--r-- | Source/cmTarget.cxx | 107 |
1 files changed, 62 insertions, 45 deletions
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() { |