diff options
author | Brad King <brad.king@kitware.com> | 2014-02-24 19:09:30 (GMT) |
---|---|---|
committer | Brad King <brad.king@kitware.com> | 2014-02-24 19:14:37 (GMT) |
commit | 3737860a383b1020f44a31be9ac5536e9913fc71 (patch) | |
tree | 83f18ce5c31d9d453a1564a54b2dee97bd2c93d3 | |
parent | 718a9532c6bfa8c68864dd5dadba9f55e0f1bcf3 (diff) | |
download | CMake-3737860a383b1020f44a31be9ac5536e9913fc71.zip CMake-3737860a383b1020f44a31be9ac5536e9913fc71.tar.gz CMake-3737860a383b1020f44a31be9ac5536e9913fc71.tar.bz2 |
cmTarget: Add per-config compilation info
Add a cmTarget::CompileInfo struct to hold per-configuration information
about the compilation settings in a target. This is different than
cmTarget::OutputInfo because it applies to any targets that can compile
sources even if they do not link or archive.
-rw-r--r-- | Source/cmTarget.cxx | 46 | ||||
-rw-r--r-- | Source/cmTarget.h | 4 |
2 files changed, 50 insertions, 0 deletions
diff --git a/Source/cmTarget.cxx b/Source/cmTarget.cxx index cf09269..a50d6ad 100644 --- a/Source/cmTarget.cxx +++ b/Source/cmTarget.cxx @@ -71,6 +71,11 @@ struct cmTarget::ImportInfo cmTarget::LinkInterface LinkInterface; }; +//---------------------------------------------------------------------------- +struct cmTarget::CompileInfo +{ +}; + struct TargetConfigPair : public std::pair<cmTarget const* , std::string> { TargetConfigPair(cmTarget const* tgt, const std::string &config) : std::pair<cmTarget const* , std::string>(tgt, config) {} @@ -116,6 +121,9 @@ public: ImportInfoMapType; ImportInfoMapType ImportInfoMap; + typedef std::map<std::string, cmTarget::CompileInfo> CompileInfoMapType; + CompileInfoMapType CompileInfoMap; + // Cache link implementation computation from each configuration. typedef std::map<TargetConfigPair, cmTarget::LinkImplementation> LinkImplMapType; @@ -2478,6 +2486,44 @@ cmTarget::OutputInfo const* cmTarget::GetOutputInfo(const char* config) const } //---------------------------------------------------------------------------- +cmTarget::CompileInfo const* cmTarget::GetCompileInfo(const char* config) const +{ + // There is no compile information for imported targets. + if(this->IsImported()) + { + return 0; + } + + if(this->GetType() > cmTarget::OBJECT_LIBRARY) + { + std::string msg = "cmTarget::GetCompileInfo called for "; + msg += this->GetName(); + msg += " which has type "; + msg += cmTarget::GetTargetTypeName(this->GetType()); + this->GetMakefile()->IssueMessage(cmake::INTERNAL_ERROR, msg); + abort(); + return 0; + } + + // Lookup/compute/cache the compile information for this configuration. + std::string config_upper; + if(config && *config) + { + config_upper = cmSystemTools::UpperCase(config); + } + typedef cmTargetInternals::CompileInfoMapType CompileInfoMapType; + CompileInfoMapType::const_iterator i = + this->Internal->CompileInfoMap.find(config_upper); + if(i == this->Internal->CompileInfoMap.end()) + { + CompileInfo info; + CompileInfoMapType::value_type entry(config_upper, info); + i = this->Internal->CompileInfoMap.insert(entry).first; + } + return &i->second; +} + +//---------------------------------------------------------------------------- std::string cmTarget::GetDirectory(const char* config, bool implib) const { if (this->IsImported()) diff --git a/Source/cmTarget.h b/Source/cmTarget.h index 7683253..6787706 100644 --- a/Source/cmTarget.h +++ b/Source/cmTarget.h @@ -720,6 +720,10 @@ private: void ComputeImportInfo(std::string const& desired_config, ImportInfo& info, cmTarget const* head) const; + // Cache target compile paths for each configuration. + struct CompileInfo; + CompileInfo const* GetCompileInfo(const char* config) const; + mutable cmTargetLinkInformationMap LinkInformation; void CheckPropertyCompatibility(cmComputeLinkInformation *info, const char* config) const; |