From 853b1bb4ba176e886e3682a2475f1de1932ee890 Mon Sep 17 00:00:00 2001 From: Brad King Date: Fri, 10 Jun 2016 09:23:14 -0400 Subject: [PATCH 1/2] cmLocalGenerator: Constify AppendDefines and AddCompileDefinitions --- Source/cmLocalGenerator.cxx | 7 ++++--- Source/cmLocalGenerator.h | 10 ++++++---- 2 files changed, 10 insertions(+), 7 deletions(-) diff --git a/Source/cmLocalGenerator.cxx b/Source/cmLocalGenerator.cxx index f543ec42a..3f957f06f 100644 --- a/Source/cmLocalGenerator.cxx +++ b/Source/cmLocalGenerator.cxx @@ -943,7 +943,7 @@ std::string cmLocalGenerator::GetIncludeFlags( void cmLocalGenerator::AddCompileDefinitions(std::set& defines, cmGeneratorTarget const* target, const std::string& config, - const std::string& lang) + const std::string& lang) const { std::vector targetDefines; target->GetCompileDefinitions(targetDefines, config, lang); @@ -2051,7 +2051,7 @@ void cmLocalGenerator::AppendFlagEscape(std::string& flags, } void cmLocalGenerator::AppendDefines(std::set& defines, - const char* defines_list) + const char* defines_list) const { // Short-circuit if there are no definitions. if (!defines_list) { @@ -2065,7 +2065,8 @@ void cmLocalGenerator::AppendDefines(std::set& defines, } void cmLocalGenerator::AppendDefines( - std::set& defines, const std::vector& defines_vec) + std::set& defines, + const std::vector& defines_vec) const { for (std::vector::const_iterator di = defines_vec.begin(); di != defines_vec.end(); ++di) { diff --git a/Source/cmLocalGenerator.h b/Source/cmLocalGenerator.h index ac2ebce97..ad77c1fcf 100644 --- a/Source/cmLocalGenerator.h +++ b/Source/cmLocalGenerator.h @@ -138,13 +138,15 @@ public: * Encode a list of preprocessor definitions for the compiler * command line. */ - void AppendDefines(std::set& defines, const char* defines_list); - void AppendDefines(std::set& defines, std::string defines_list) + void AppendDefines(std::set& defines, + const char* defines_list) const; + void AppendDefines(std::set& defines, + std::string defines_list) const { this->AppendDefines(defines, defines_list.c_str()); } void AppendDefines(std::set& defines, - const std::vector& defines_vec); + const std::vector& defines_vec) const; /** * Join a set of defines into a definesString with a space separator. @@ -200,7 +202,7 @@ public: void AddCompileDefinitions(std::set& defines, cmGeneratorTarget const* target, const std::string& config, - const std::string& lang); + const std::string& lang) const; std::string GetProjectName() const; From f62ed322dc0d859f595be5ddeff40904ee478f50 Mon Sep 17 00:00:00 2001 From: Tobias Hunger Date: Wed, 8 Jun 2016 13:23:25 +0200 Subject: [PATCH 2/2] cmLocalGenerator: Add GetTargetDefines to get all defines for a target --- Source/cmCommonTargetGenerator.cxx | 14 +++----------- Source/cmLocalGenerator.cxx | 14 ++++++++++++++ Source/cmLocalGenerator.h | 3 +++ 3 files changed, 20 insertions(+), 11 deletions(-) diff --git a/Source/cmCommonTargetGenerator.cxx b/Source/cmCommonTargetGenerator.cxx index 131b490d6..b893dd3ab 100644 --- a/Source/cmCommonTargetGenerator.cxx +++ b/Source/cmCommonTargetGenerator.cxx @@ -246,19 +246,11 @@ std::string cmCommonTargetGenerator::GetDefines(const std::string& l) ByLanguageMap::iterator i = this->DefinesByLanguage.find(l); if (i == this->DefinesByLanguage.end()) { std::set defines; - const char* lang = l.c_str(); - // Add the export symbol definition for shared library objects. - if (const char* exportMacro = this->GeneratorTarget->GetExportMacro()) { - this->LocalGenerator->AppendDefines(defines, exportMacro); - } - - // Add preprocessor definitions for this target and configuration. - this->LocalGenerator->AddCompileDefinitions( - defines, this->GeneratorTarget, this->LocalGenerator->GetConfigName(), - l); + this->LocalGenerator->GetTargetDefines(this->GeneratorTarget, + this->ConfigName, l, defines); std::string definesString; - this->LocalGenerator->JoinDefines(defines, definesString, lang); + this->LocalGenerator->JoinDefines(defines, definesString, l); ByLanguageMap::value_type entry(l, definesString); i = this->DefinesByLanguage.insert(entry).first; diff --git a/Source/cmLocalGenerator.cxx b/Source/cmLocalGenerator.cxx index 3f957f06f..2ccaa82fe 100644 --- a/Source/cmLocalGenerator.cxx +++ b/Source/cmLocalGenerator.cxx @@ -1329,6 +1329,20 @@ std::string cmLocalGenerator::GetFrameworkFlags(std::string const& l, return ::GetFrameworkFlags(l, config, target); } +void cmLocalGenerator::GetTargetDefines(cmGeneratorTarget const* target, + std::string const& config, + std::string const& lang, + std::set& defines) const +{ + // Add the export symbol definition for shared library objects. + if (const char* exportMacro = target->GetExportMacro()) { + this->AppendDefines(defines, exportMacro); + } + + // Add preprocessor definitions for this target and configuration. + this->AddCompileDefinitions(defines, target, config, lang.c_str()); +} + std::string cmLocalGenerator::ConvertToLinkReference(std::string const& lib, OutputFormat format) { diff --git a/Source/cmLocalGenerator.h b/Source/cmLocalGenerator.h index ad77c1fcf..55b8794c9 100644 --- a/Source/cmLocalGenerator.h +++ b/Source/cmLocalGenerator.h @@ -314,6 +314,9 @@ public: std::string& flags, std::string& linkFlags, std::string& frameworkPath, std::string& linkPath, cmGeneratorTarget* target, bool useWatcomQuote); + void GetTargetDefines(cmGeneratorTarget const* target, + std::string const& config, std::string const& lang, + std::set& defines) const; std::string GetFrameworkFlags(std::string const& l, std::string const& config,