diff options
author | Brad King <brad.king@kitware.com> | 2015-07-28 14:08:50 (GMT) |
---|---|---|
committer | CMake Topic Stage <kwrobot@kitware.com> | 2015-07-28 14:08:50 (GMT) |
commit | 98d6e9ec2dd0a935b1ebfed50b6e9ecab719557d (patch) | |
tree | 96a5cdb8bc99c5949a4f4570a4cd0e34f41190f0 /Source/cmGeneratorTarget.cxx | |
parent | 16dffb313697d175ed76701f4a06ecbbeedcb627 (diff) | |
parent | 57f03e59ba92989aaf3600399f11ffb308cc663e (diff) | |
download | CMake-98d6e9ec2dd0a935b1ebfed50b6e9ecab719557d.zip CMake-98d6e9ec2dd0a935b1ebfed50b6e9ecab719557d.tar.gz CMake-98d6e9ec2dd0a935b1ebfed50b6e9ecab719557d.tar.bz2 |
Merge topic 'use-generator-target'
57f03e59 Port some of the cmExportFileGenerator API to cmGeneratorTarget.
57ab0f70 Port cmExportBuildFileGenerator to cmGeneratorTarget.
570938cb cmExportTryCompileFileGenerator: Create cmGeneratorTargets.
ec38e4c8 Move GetFullPath to cmGeneratorTarget
dfb025bf Move GetLocationForBuild to cmGeneratorTarget.
9f2dca80 Move GetLocation to cmGeneratorTarget.
c7a8e74b Always access target location from a cmGeneratorTarget instance.
5b60eaf6 cmTarget: Restore the ImportedGetLocation method.
50b17a61 cmIncludeCommand: Populate the cmGeneratorTargets in deprecated path.
ba266858 cmTarget: Create cmGeneratorTargets before reading deprecated LOCATION.
5ab3a946 cmTarget: Inline GetLocation into deprecated callers.
496f4cd0 cmGlobalGenerator: Create cmGeneratorTargets before QtAutomoc.
de80993a cmGlobalGenerator: Create cmGeneratorTargets earlier.
611220f7 cmTarget: Use reliable test for CMP0024 and CMP0026 OLD.
bbad6ba5 cmLocalGenerator: Remove unused AddCustomCommandToCreateObject method.
e4dc83ad cmLocalGenerator: Remove unused AddBuildTargetRule method.
...
Diffstat (limited to 'Source/cmGeneratorTarget.cxx')
-rw-r--r-- | Source/cmGeneratorTarget.cxx | 141 |
1 files changed, 139 insertions, 2 deletions
diff --git a/Source/cmGeneratorTarget.cxx b/Source/cmGeneratorTarget.cxx index e6f7a43..edd89e8 100644 --- a/Source/cmGeneratorTarget.cxx +++ b/Source/cmGeneratorTarget.cxx @@ -520,6 +520,61 @@ void cmGeneratorTarget } //---------------------------------------------------------------------------- +const char* cmGeneratorTarget::GetLocation(const std::string& config) const +{ + static std::string location; + if (this->Target->IsImported()) + { + location = this->Target->ImportedGetFullPath(config, false); + } + else + { + location = this->GetFullPath(config, false); + } + return location.c_str(); +} + +bool cmGeneratorTarget::IsImported() const +{ + return this->Target->IsImported(); +} + +//---------------------------------------------------------------------------- +const char* cmGeneratorTarget::GetLocationForBuild() const +{ + static std::string location; + if(this->IsImported()) + { + location = this->Target->ImportedGetFullPath("", false); + return location.c_str(); + } + + // Now handle the deprecated build-time configuration location. + location = this->Target->GetDirectory(); + const char* cfgid = this->Makefile->GetDefinition("CMAKE_CFG_INTDIR"); + if(cfgid && strcmp(cfgid, ".") != 0) + { + location += "/"; + location += cfgid; + } + + if(this->Target->IsAppBundleOnApple()) + { + std::string macdir = this->Target->BuildMacContentDirectory("", "", + false); + if(!macdir.empty()) + { + location += "/"; + location += macdir; + } + } + location += "/"; + location += this->Target->GetFullName("", false); + return location.c_str(); +} + + +//---------------------------------------------------------------------------- bool cmGeneratorTarget::IsSystemIncludeDirectory(const std::string& dir, const std::string& config) const { @@ -834,7 +889,8 @@ bool cmTargetTraceDependencies::IsUtility(std::string const& dep) } // Check for a target with this name. - if(cmTarget* t = this->Makefile->FindTargetToUse(util)) + if(cmGeneratorTarget* t + = this->Makefile->FindGeneratorTargetToUse(util)) { // If we find the target and the dep was given as a full path, // then make sure it was not a full path to something else, and @@ -938,7 +994,8 @@ void cmTargetTraceDependencies::FollowCommandDepends(cmCustomCommand const& cc, const std::string& config, std::set<std::string>& emitted) { - cmCustomCommandGenerator ccg(cc, config, this->Makefile); + cmCustomCommandGenerator ccg(cc, config, + this->GeneratorTarget->LocalGenerator); const std::vector<std::string>& depends = ccg.GetDepends(); @@ -1125,6 +1182,86 @@ void cmGeneratorTarget::GenerateTargetManifest( } } +//---------------------------------------------------------------------------- +std::string cmGeneratorTarget::GetFullPath(const std::string& config, + bool implib, bool realname) const +{ + if(this->Target->IsImported()) + { + return this->Target->ImportedGetFullPath(config, implib); + } + else + { + return this->NormalGetFullPath(config, implib, realname); + } +} + +std::string cmGeneratorTarget::NormalGetFullPath(const std::string& config, + bool implib, + bool realname) const +{ + std::string fpath = this->Target->GetDirectory(config, implib); + fpath += "/"; + if(this->Target->IsAppBundleOnApple()) + { + fpath = this->Target->BuildMacContentDirectory(fpath, config, false); + fpath += "/"; + } + + // Add the full name of the target. + if(implib) + { + fpath += this->Target->GetFullName(config, true); + } + else if(realname) + { + fpath += this->NormalGetRealName(config); + } + else + { + fpath += this->Target->GetFullName(config, false); + } + return fpath; +} + +//---------------------------------------------------------------------------- +std::string +cmGeneratorTarget::NormalGetRealName(const std::string& config) const +{ + // This should not be called for imported targets. + // TODO: Split cmTarget into a class hierarchy to get compile-time + // enforcement of the limited imported target API. + if(this->Target->IsImported()) + { + std::string msg = "NormalGetRealName called on imported target: "; + msg += this->GetName(); + this->Makefile->IssueMessage(cmake::INTERNAL_ERROR, msg); + } + + if(this->GetType() == cmTarget::EXECUTABLE) + { + // Compute the real name that will be built. + std::string name; + std::string realName; + std::string impName; + std::string pdbName; + this->Target->GetExecutableNames(name, realName, impName, pdbName, config); + return realName; + } + else + { + // Compute the real name that will be built. + std::string name; + std::string soName; + std::string realName; + std::string impName; + std::string pdbName; + this->Target->GetLibraryNames(name, soName, realName, + impName, pdbName, config); + return realName; + } +} + bool cmStrictTargetComparison::operator()(cmTarget const* t1, cmTarget const* t2) const { |