From 3737860a383b1020f44a31be9ac5536e9913fc71 Mon Sep 17 00:00:00 2001 From: Brad King Date: Mon, 24 Feb 2014 14:09:30 -0500 Subject: 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. --- Source/cmTarget.cxx | 46 ++++++++++++++++++++++++++++++++++++++++++++++ Source/cmTarget.h | 4 ++++ 2 files changed, 50 insertions(+) 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 { TargetConfigPair(cmTarget const* tgt, const std::string &config) : std::pair(tgt, config) {} @@ -116,6 +121,9 @@ public: ImportInfoMapType; ImportInfoMapType ImportInfoMap; + typedef std::map CompileInfoMapType; + CompileInfoMapType CompileInfoMap; + // Cache link implementation computation from each configuration. typedef std::map 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; -- cgit v0.12