cmLocalGenerator: Port some API to cmGeneratorTarget.

This commit is contained in:
Stephen Kelly 2015-10-09 22:19:57 +02:00
parent cfb2f7508a
commit 3e8ef64273
18 changed files with 119 additions and 107 deletions

View File

@ -316,10 +316,11 @@ std::string cmCommonTargetGenerator::GetFlags(const std::string &l)
this->AddFortranFlags(flags); this->AddFortranFlags(flags);
} }
this->LocalGenerator->AddCMP0018Flags(flags, this->Target, this->LocalGenerator->AddCMP0018Flags(flags, this->GeneratorTarget,
lang, this->ConfigName); lang, this->ConfigName);
this->LocalGenerator->AddVisibilityPresetFlags(flags, this->Target, this->LocalGenerator->AddVisibilityPresetFlags(flags,
this->GeneratorTarget,
lang); lang);
// Append old-style preprocessor definition flags. // Append old-style preprocessor definition flags.
@ -331,7 +332,7 @@ std::string cmCommonTargetGenerator::GetFlags(const std::string &l)
AppendFlags(flags,this->GetFrameworkFlags(l)); AppendFlags(flags,this->GetFrameworkFlags(l));
// Add target-specific flags. // Add target-specific flags.
this->LocalGenerator->AddCompileOptions(flags, this->Target, this->LocalGenerator->AddCompileOptions(flags, this->GeneratorTarget,
lang, this->ConfigName); lang, this->ConfigName);
ByLanguageMap::value_type entry(l, flags); ByLanguageMap::value_type entry(l, flags);
@ -354,7 +355,7 @@ std::string cmCommonTargetGenerator::GetDefines(const std::string &l)
} }
// Add preprocessor definitions for this target and configuration. // Add preprocessor definitions for this target and configuration.
this->LocalGenerator->AddCompileDefinitions(defines, this->Target, this->LocalGenerator->AddCompileDefinitions(defines, this->GeneratorTarget,
this->LocalGenerator->GetConfigName(), l); this->LocalGenerator->GetConfigName(), l);
std::string definesString; std::string definesString;

View File

@ -388,7 +388,7 @@ cmExtraSublimeTextGenerator::ComputeFlagsForObject(cmSourceFile* source,
// } // }
// Add shared-library flags if needed. // Add shared-library flags if needed.
lg->AddCMP0018Flags(flags, gtgt->Target, language, config); lg->AddCMP0018Flags(flags, gtgt, language, config);
// Add include directory flags. // Add include directory flags.
{ {
@ -403,7 +403,7 @@ cmExtraSublimeTextGenerator::ComputeFlagsForObject(cmSourceFile* source,
lg->AppendFlags(flags, makefile->GetDefineFlags()); lg->AppendFlags(flags, makefile->GetDefineFlags());
// Add target-specific flags. // Add target-specific flags.
lg->AddCompileOptions(flags, gtgt->Target, language, config); lg->AddCompileOptions(flags, gtgt, language, config);
// Add source file specific flags. // Add source file specific flags.
lg->AppendFlags(flags, source->GetProperty("COMPILE_FLAGS")); lg->AppendFlags(flags, source->GetProperty("COMPILE_FLAGS"));
@ -433,7 +433,7 @@ ComputeDefines(cmSourceFile *source, cmLocalGenerator* lg,
} }
// Add preprocessor definitions for this target and configuration. // Add preprocessor definitions for this target and configuration.
lg->AddCompileDefinitions(defines, target->Target, config, language); lg->AddCompileDefinitions(defines, target, config, language);
lg->AppendDefines(defines, source->GetProperty("COMPILE_DEFINITIONS")); lg->AppendDefines(defines, source->GetProperty("COMPILE_DEFINITIONS"));
{ {
std::string defPropName = "COMPILE_DEFINITIONS_"; std::string defPropName = "COMPILE_DEFINITIONS_";

View File

@ -265,8 +265,11 @@ void cmGhsMultiTargetGenerator::SetCompilerFlags(std::string const &config,
this->LocalGenerator->AddLanguageFlags( this->LocalGenerator->AddLanguageFlags(
flags, lang + std::string("_GHS_KERNEL"), config); flags, lang + std::string("_GHS_KERNEL"), config);
} }
this->LocalGenerator->AddCMP0018Flags(flags, this->Target, lang, config); this->LocalGenerator->AddCMP0018Flags(flags, this->GeneratorTarget,
this->LocalGenerator->AddVisibilityPresetFlags(flags, this->Target, lang); lang, config);
this->LocalGenerator->AddVisibilityPresetFlags(flags,
this->GeneratorTarget,
lang);
// Append old-style preprocessor definition flags. // Append old-style preprocessor definition flags.
if (std::string(" ") != std::string(this->Makefile->GetDefineFlags())) if (std::string(" ") != std::string(this->Makefile->GetDefineFlags()))
@ -276,7 +279,8 @@ void cmGhsMultiTargetGenerator::SetCompilerFlags(std::string const &config,
} }
// Add target-specific flags. // Add target-specific flags.
this->LocalGenerator->AddCompileOptions(flags, this->Target, lang, config); this->LocalGenerator->AddCompileOptions(flags, this->GeneratorTarget,
lang, config);
std::map<std::string, std::string>::value_type entry(language, flags); std::map<std::string, std::string>::value_type entry(language, flags);
i = this->FlagsByLanguage.insert(entry).first; i = this->FlagsByLanguage.insert(entry).first;
@ -299,7 +303,8 @@ std::string cmGhsMultiTargetGenerator::GetDefines(const std::string &language,
} }
// Add preprocessor definitions for this target and configuration. // Add preprocessor definitions for this target and configuration.
this->LocalGenerator->AddCompileDefinitions(defines, this->Target, config, this->LocalGenerator->AddCompileDefinitions(defines,
this->GeneratorTarget, config,
language); language);
std::string definesString; std::string definesString;

View File

@ -1814,14 +1814,14 @@ void cmGlobalXCodeGenerator::CreateBuildSettings(cmTarget& target,
this->CurrentLocalGenerator->AddLanguageFlags(flags, lang, configName); this->CurrentLocalGenerator->AddLanguageFlags(flags, lang, configName);
// Add shared-library flags if needed. // Add shared-library flags if needed.
this->CurrentLocalGenerator->AddCMP0018Flags(flags, &target, this->CurrentLocalGenerator->AddCMP0018Flags(flags, gtgt,
lang, configName); lang, configName);
this->CurrentLocalGenerator->AddVisibilityPresetFlags(flags, &target, this->CurrentLocalGenerator->AddVisibilityPresetFlags(flags, gtgt,
lang); lang);
this->CurrentLocalGenerator-> this->CurrentLocalGenerator->
AddCompileOptions(flags, &target, lang, configName); AddCompileOptions(flags, gtgt, lang, configName);
} }
std::string llang = gtgt->GetLinkerLanguage(configName); std::string llang = gtgt->GetLinkerLanguage(configName);
@ -1884,7 +1884,7 @@ void cmGlobalXCodeGenerator::CreateBuildSettings(cmTarget& target,
this->CurrentLocalGenerator this->CurrentLocalGenerator
->GetStaticLibraryFlags(extraLinkOptions, ->GetStaticLibraryFlags(extraLinkOptions,
cmSystemTools::UpperCase(configName), cmSystemTools::UpperCase(configName),
&target); gtgt);
} }
else else
{ {

View File

@ -920,7 +920,7 @@ cmLocalGenerator::ExpandRuleVariables(std::string& s,
} }
//---------------------------------------------------------------------------- //----------------------------------------------------------------------------
const char* cmLocalGenerator::GetRuleLauncher(cmTarget* target, const char* cmLocalGenerator::GetRuleLauncher(cmGeneratorTarget* target,
const std::string& prop) const std::string& prop)
{ {
if(target) if(target)
@ -934,7 +934,8 @@ const char* cmLocalGenerator::GetRuleLauncher(cmTarget* target,
} }
//---------------------------------------------------------------------------- //----------------------------------------------------------------------------
void cmLocalGenerator::InsertRuleLauncher(std::string& s, cmTarget* target, void cmLocalGenerator::InsertRuleLauncher(std::string& s,
cmGeneratorTarget* target,
const std::string& prop) const std::string& prop)
{ {
if(const char* val = this->GetRuleLauncher(target, prop)) if(const char* val = this->GetRuleLauncher(target, prop))
@ -1087,27 +1088,23 @@ std::string cmLocalGenerator::GetIncludeFlags(
//---------------------------------------------------------------------------- //----------------------------------------------------------------------------
void cmLocalGenerator::AddCompileDefinitions(std::set<std::string>& defines, void cmLocalGenerator::AddCompileDefinitions(std::set<std::string>& defines,
cmTarget const* target, cmGeneratorTarget const* target,
const std::string& config, const std::string& config,
const std::string& lang) const std::string& lang)
{ {
std::vector<std::string> targetDefines; std::vector<std::string> targetDefines;
cmGeneratorTarget* gtgt = this->GlobalGenerator->GetGeneratorTarget(target); target->GetCompileDefinitions(targetDefines, config, lang);
gtgt->GetCompileDefinitions(targetDefines, config, lang);
this->AppendDefines(defines, targetDefines); this->AppendDefines(defines, targetDefines);
} }
//---------------------------------------------------------------------------- //----------------------------------------------------------------------------
void cmLocalGenerator::AddCompileOptions( void cmLocalGenerator::AddCompileOptions(
std::string& flags, cmTarget* target, std::string& flags, cmGeneratorTarget* target,
const std::string& lang, const std::string& config const std::string& lang, const std::string& config
) )
{ {
std::string langFlagRegexVar = std::string("CMAKE_")+lang+"_FLAG_REGEX"; std::string langFlagRegexVar = std::string("CMAKE_")+lang+"_FLAG_REGEX";
cmGeneratorTarget* gtgt =
this->GlobalGenerator->GetGeneratorTarget(target);
if(const char* langFlagRegexStr = if(const char* langFlagRegexStr =
this->Makefile->GetDefinition(langFlagRegexVar)) this->Makefile->GetDefinition(langFlagRegexVar))
{ {
@ -1118,7 +1115,7 @@ void cmLocalGenerator::AddCompileOptions(
{ {
cmSystemTools::ParseWindowsCommandLine(targetFlags, opts); cmSystemTools::ParseWindowsCommandLine(targetFlags, opts);
} }
gtgt->GetCompileOptions(opts, config, lang); target->GetCompileOptions(opts, config, lang);
for(std::vector<std::string>::const_iterator i = opts.begin(); for(std::vector<std::string>::const_iterator i = opts.begin();
i != opts.end(); ++i) i != opts.end(); ++i)
{ {
@ -1139,7 +1136,7 @@ void cmLocalGenerator::AddCompileOptions(
this->AppendFlags(flags, targetFlags); this->AppendFlags(flags, targetFlags);
} }
std::vector<std::string> opts; std::vector<std::string> opts;
gtgt->GetCompileOptions(opts, config, lang); target->GetCompileOptions(opts, config, lang);
for(std::vector<std::string>::const_iterator i = opts.begin(); for(std::vector<std::string>::const_iterator i = opts.begin();
i != opts.end(); ++i) i != opts.end(); ++i)
{ {
@ -1148,19 +1145,19 @@ void cmLocalGenerator::AddCompileOptions(
} }
} }
std::vector<std::string> features; std::vector<std::string> features;
gtgt->GetCompileFeatures(features, config); target->GetCompileFeatures(features, config);
for(std::vector<std::string>::const_iterator it = features.begin(); for(std::vector<std::string>::const_iterator it = features.begin();
it != features.end(); ++it) it != features.end(); ++it)
{ {
if (!this->Makefile->AddRequiredTargetFeature(target, *it)) if (!this->Makefile->AddRequiredTargetFeature(target->Target, *it))
{ {
return; return;
} }
} }
for(std::map<std::string, std::string>::const_iterator it for(std::map<std::string, std::string>::const_iterator it
= gtgt->GetMaxLanguageStandards().begin(); = target->GetMaxLanguageStandards().begin();
it != gtgt->GetMaxLanguageStandards().end(); ++it) it != target->GetMaxLanguageStandards().end(); ++it)
{ {
const char* standard = target->GetProperty(it->first + "_STANDARD"); const char* standard = target->GetProperty(it->first + "_STANDARD");
if(!standard) if(!standard)
@ -1314,7 +1311,7 @@ void cmLocalGenerator::GetIncludeDirectories(std::vector<std::string>& dirs,
void cmLocalGenerator::GetStaticLibraryFlags(std::string& flags, void cmLocalGenerator::GetStaticLibraryFlags(std::string& flags,
std::string const& config, std::string const& config,
cmTarget* target) cmGeneratorTarget* target)
{ {
this->AppendFlags(flags, this->AppendFlags(flags,
this->Makefile->GetSafeDefinition("CMAKE_STATIC_LINKER_FLAGS")); this->Makefile->GetSafeDefinition("CMAKE_STATIC_LINKER_FLAGS"));
@ -1348,7 +1345,7 @@ void cmLocalGenerator::GetTargetFlags(std::string& linkLibs,
switch(target->GetType()) switch(target->GetType())
{ {
case cmState::STATIC_LIBRARY: case cmState::STATIC_LIBRARY:
this->GetStaticLibraryFlags(linkFlags, buildType, target->Target); this->GetStaticLibraryFlags(linkFlags, buildType, target);
break; break;
case cmState::MODULE_LIBRARY: case cmState::MODULE_LIBRARY:
libraryLinkVariable = "CMAKE_MODULE_LINKER_FLAGS"; libraryLinkVariable = "CMAKE_MODULE_LINKER_FLAGS";
@ -1904,7 +1901,8 @@ void cmLocalGenerator::AddSharedFlags(std::string& flags,
//---------------------------------------------------------------------------- //----------------------------------------------------------------------------
void cmLocalGenerator:: void cmLocalGenerator::
AddCompilerRequirementFlag(std::string &flags, cmTarget const* target, AddCompilerRequirementFlag(std::string &flags,
cmGeneratorTarget const* target,
const std::string& lang) const std::string& lang)
{ {
if (lang.empty()) if (lang.empty())
@ -1942,7 +1940,8 @@ AddCompilerRequirementFlag(std::string &flags, cmTarget const* target,
"CMAKE_" + lang + standardProp "CMAKE_" + lang + standardProp
+ "_" + type + "_COMPILE_OPTION"; + "_" + type + "_COMPILE_OPTION";
const char *opt = target->GetMakefile()->GetDefinition(option_flag); const char *opt = target->Target->GetMakefile()
->GetDefinition(option_flag);
if (!opt) if (!opt)
{ {
std::ostringstream e; std::ostringstream e;
@ -1983,7 +1982,7 @@ AddCompilerRequirementFlag(std::string &flags, cmTarget const* target,
std::string e = std::string e =
lang + "_STANDARD is set to invalid value '" + standard + "'"; lang + "_STANDARD is set to invalid value '" + standard + "'";
this->GetGlobalGenerator()->GetCMakeInstance() this->GetGlobalGenerator()->GetCMakeInstance()
->IssueMessage(cmake::FATAL_ERROR, e, target->GetBacktrace()); ->IssueMessage(cmake::FATAL_ERROR, e, target->Target->GetBacktrace());
return; return;
} }
@ -2007,7 +2006,7 @@ AddCompilerRequirementFlag(std::string &flags, cmTarget const* target,
+ "_" + type + "_COMPILE_OPTION"; + "_" + type + "_COMPILE_OPTION";
const char *opt = const char *opt =
target->GetMakefile()->GetRequiredDefinition(option_flag); target->Target->GetMakefile()->GetRequiredDefinition(option_flag);
this->AppendFlagEscape(flags, opt); this->AppendFlagEscape(flags, opt);
return; return;
} }
@ -2018,7 +2017,8 @@ AddCompilerRequirementFlag(std::string &flags, cmTarget const* target,
"CMAKE_" + lang + *stdIt "CMAKE_" + lang + *stdIt
+ "_" + type + "_COMPILE_OPTION"; + "_" + type + "_COMPILE_OPTION";
if (const char *opt = target->GetMakefile()->GetDefinition(option_flag)) if (const char *opt = target->Target
->GetMakefile()->GetDefinition(option_flag))
{ {
this->AppendFlagEscape(flags, opt); this->AppendFlagEscape(flags, opt);
return; return;
@ -2094,7 +2094,7 @@ static void AddInlineVisibilityCompileOption(std::string &flags,
//---------------------------------------------------------------------------- //----------------------------------------------------------------------------
void cmLocalGenerator void cmLocalGenerator
::AddVisibilityPresetFlags(std::string &flags, cmTarget const* target, ::AddVisibilityPresetFlags(std::string &flags, cmGeneratorTarget const* target,
const std::string& lang) const std::string& lang)
{ {
if (lang.empty()) if (lang.empty())
@ -2106,9 +2106,9 @@ void cmLocalGenerator
std::string *pWarnCMP0063 = 0; std::string *pWarnCMP0063 = 0;
if (target->GetType() != cmState::SHARED_LIBRARY && if (target->GetType() != cmState::SHARED_LIBRARY &&
target->GetType() != cmState::MODULE_LIBRARY && target->GetType() != cmState::MODULE_LIBRARY &&
!target->IsExecutableWithExports()) !target->Target->IsExecutableWithExports())
{ {
switch (target->GetPolicyStatusCMP0063()) switch (target->Target->GetPolicyStatusCMP0063())
{ {
case cmPolicies::OLD: case cmPolicies::OLD:
return; return;
@ -2120,15 +2120,16 @@ void cmLocalGenerator
} }
} }
AddVisibilityCompileOption(flags, target, this, lang, pWarnCMP0063); AddVisibilityCompileOption(flags, target->Target, this, lang, pWarnCMP0063);
if(lang == "CXX") if(lang == "CXX")
{ {
AddInlineVisibilityCompileOption(flags, target, this, pWarnCMP0063); AddInlineVisibilityCompileOption(flags, target->Target,
this, pWarnCMP0063);
} }
if (!warnCMP0063.empty() && if (!warnCMP0063.empty() &&
this->WarnCMP0063.insert(target).second) this->WarnCMP0063.insert(target->Target).second)
{ {
std::ostringstream w; std::ostringstream w;
w << w <<
@ -2138,14 +2139,15 @@ void cmLocalGenerator
"has the following visibility properties set for " << lang << ":\n" << "has the following visibility properties set for " << lang << ":\n" <<
warnCMP0063 << warnCMP0063 <<
"For compatibility CMake is not honoring them for this target."; "For compatibility CMake is not honoring them for this target.";
target->GetMakefile()->GetCMakeInstance() target->Target->GetMakefile()->GetCMakeInstance()
->IssueMessage(cmake::AUTHOR_WARNING, w.str(), target->GetBacktrace()); ->IssueMessage(cmake::AUTHOR_WARNING, w.str(),
target->Target->GetBacktrace());
} }
} }
//---------------------------------------------------------------------------- //----------------------------------------------------------------------------
void cmLocalGenerator::AddCMP0018Flags(std::string &flags, void cmLocalGenerator::AddCMP0018Flags(std::string &flags,
cmTarget const* target, cmGeneratorTarget const* target,
std::string const& lang, std::string const& lang,
const std::string& config) const std::string& config)
{ {
@ -2169,9 +2171,7 @@ void cmLocalGenerator::AddCMP0018Flags(std::string &flags,
return; return;
} }
cmGeneratorTarget* gtgt = if (target->GetLinkInterfaceDependentBoolProperty(
this->GlobalGenerator->GetGeneratorTarget(target);
if (gtgt->GetLinkInterfaceDependentBoolProperty(
"POSITION_INDEPENDENT_CODE", "POSITION_INDEPENDENT_CODE",
config)) config))
{ {

View File

@ -20,7 +20,6 @@
class cmMakefile; class cmMakefile;
class cmGlobalGenerator; class cmGlobalGenerator;
class cmGeneratorTarget; class cmGeneratorTarget;
class cmTarget;
class cmTargetManifest; class cmTargetManifest;
class cmSourceFile; class cmSourceFile;
class cmCustomCommand; class cmCustomCommand;
@ -91,13 +90,15 @@ public:
void AddLanguageFlags(std::string& flags, const std::string& lang, void AddLanguageFlags(std::string& flags, const std::string& lang,
const std::string& config); const std::string& config);
void AddCMP0018Flags(std::string &flags, cmTarget const* target, void AddCMP0018Flags(std::string &flags, cmGeneratorTarget const* target,
std::string const& lang, const std::string& config); std::string const& lang, const std::string& config);
void AddVisibilityPresetFlags(std::string &flags, cmTarget const* target, void AddVisibilityPresetFlags(std::string &flags,
cmGeneratorTarget const* target,
const std::string& lang); const std::string& lang);
void AddConfigVariableFlags(std::string& flags, const std::string& var, void AddConfigVariableFlags(std::string& flags, const std::string& var,
const std::string& config); const std::string& config);
void AddCompilerRequirementFlag(std::string &flags, cmTarget const* target, void AddCompilerRequirementFlag(std::string &flags,
cmGeneratorTarget const* target,
const std::string& lang); const std::string& lang);
///! Append flags to a string. ///! Append flags to a string.
virtual void AppendFlags(std::string& flags, const std::string& newFlags); virtual void AppendFlags(std::string& flags, const std::string& newFlags);
@ -188,10 +189,10 @@ public:
const std::string& lang = "C", const std::string& lang = "C",
const std::string& config = "", const std::string& config = "",
bool stripImplicitInclDirs = true) const; bool stripImplicitInclDirs = true) const;
void AddCompileOptions(std::string& flags, cmTarget* target, void AddCompileOptions(std::string& flags, cmGeneratorTarget* target,
const std::string& lang, const std::string& config); const std::string& lang, const std::string& config);
void AddCompileDefinitions(std::set<std::string>& defines, void AddCompileDefinitions(std::set<std::string>& defines,
cmTarget const* target, cmGeneratorTarget const* target,
const std::string& config, const std::string& config,
const std::string& lang); const std::string& lang);
@ -212,7 +213,7 @@ public:
{ {
memset(this, 0, sizeof(*this)); memset(this, 0, sizeof(*this));
} }
cmTarget* CMTarget; cmGeneratorTarget* CMTarget;
const char* TargetPDB; const char* TargetPDB;
const char* TargetCompilePDB; const char* TargetCompilePDB;
const char* TargetVersionMajor; const char* TargetVersionMajor;
@ -298,7 +299,7 @@ public:
/** Fill out the static linker flags for the given target. */ /** Fill out the static linker flags for the given target. */
void GetStaticLibraryFlags(std::string& flags, void GetStaticLibraryFlags(std::string& flags,
std::string const& config, std::string const& config,
cmTarget* target); cmGeneratorTarget* target);
/** Fill out these strings for the given target. Libraries to link, /** Fill out these strings for the given target. Libraries to link,
* flags, and linkflags. */ * flags, and linkflags. */
@ -341,8 +342,9 @@ protected:
std::string ExpandRuleVariable(std::string const& variable, std::string ExpandRuleVariable(std::string const& variable,
const RuleVariables& replaceValues); const RuleVariables& replaceValues);
const char* GetRuleLauncher(cmTarget* target, const std::string& prop); const char* GetRuleLauncher(cmGeneratorTarget* target,
void InsertRuleLauncher(std::string& s, cmTarget* target, const std::string& prop);
void InsertRuleLauncher(std::string& s, cmGeneratorTarget* target,
const std::string& prop); const std::string& prop);
// Handle old-style install rules stored in the targets. // Handle old-style install rules stored in the targets.

View File

@ -1034,7 +1034,7 @@ void
cmLocalUnixMakefileGenerator3 cmLocalUnixMakefileGenerator3
::AppendCustomCommands(std::vector<std::string>& commands, ::AppendCustomCommands(std::vector<std::string>& commands,
const std::vector<cmCustomCommand>& ccs, const std::vector<cmCustomCommand>& ccs,
cmTarget* target, cmGeneratorTarget* target,
cmLocalGenerator::RelativeRoot relative) cmLocalGenerator::RelativeRoot relative)
{ {
for(std::vector<cmCustomCommand>::const_iterator i = ccs.begin(); for(std::vector<cmCustomCommand>::const_iterator i = ccs.begin();
@ -1050,7 +1050,7 @@ void
cmLocalUnixMakefileGenerator3 cmLocalUnixMakefileGenerator3
::AppendCustomCommand(std::vector<std::string>& commands, ::AppendCustomCommand(std::vector<std::string>& commands,
cmCustomCommandGenerator const& ccg, cmCustomCommandGenerator const& ccg,
cmTarget* target, cmGeneratorTarget* target,
bool echo_comment, bool echo_comment,
cmLocalGenerator::RelativeRoot relative, cmLocalGenerator::RelativeRoot relative,
std::ostream* content) std::ostream* content)
@ -1181,7 +1181,7 @@ cmLocalUnixMakefileGenerator3
std::string std::string
cmLocalUnixMakefileGenerator3::MakeLauncher( cmLocalUnixMakefileGenerator3::MakeLauncher(
cmCustomCommandGenerator const& ccg, cmCustomCommandGenerator const& ccg,
cmTarget* target, RelativeRoot relative) cmGeneratorTarget* target, RelativeRoot relative)
{ {
// Short-circuit if there is no launcher. // Short-circuit if there is no launcher.
const char* prop = "RULE_LAUNCH_CUSTOM"; const char* prop = "RULE_LAUNCH_CUSTOM";
@ -1788,6 +1788,9 @@ void cmLocalUnixMakefileGenerator3
this->AppendEcho(commands, text, this->AppendEcho(commands, text,
cmLocalUnixMakefileGenerator3::EchoGlobal); cmLocalUnixMakefileGenerator3::EchoGlobal);
cmGeneratorTarget* gt = this->GlobalGenerator
->GetGeneratorTarget(&glIt->second);
// Global targets store their rules in pre- and post-build commands. // Global targets store their rules in pre- and post-build commands.
this->AppendCustomDepends(depends, this->AppendCustomDepends(depends,
glIt->second.GetPreBuildCommands()); glIt->second.GetPreBuildCommands());
@ -1795,11 +1798,11 @@ void cmLocalUnixMakefileGenerator3
glIt->second.GetPostBuildCommands()); glIt->second.GetPostBuildCommands());
this->AppendCustomCommands(commands, this->AppendCustomCommands(commands,
glIt->second.GetPreBuildCommands(), glIt->second.GetPreBuildCommands(),
&glIt->second, gt,
cmLocalGenerator::START_OUTPUT); cmLocalGenerator::START_OUTPUT);
this->AppendCustomCommands(commands, this->AppendCustomCommands(commands,
glIt->second.GetPostBuildCommands(), glIt->second.GetPostBuildCommands(),
&glIt->second, gt,
cmLocalGenerator::START_OUTPUT); cmLocalGenerator::START_OUTPUT);
std::string targetName = glIt->second.GetName(); std::string targetName = glIt->second.GetName();
this->WriteMakeRule(ruleFileStream, targetString.c_str(), this->WriteMakeRule(ruleFileStream, targetString.c_str(),
@ -1976,10 +1979,11 @@ void cmLocalUnixMakefileGenerator3::ClearDependencies(cmMakefile* mf,
void cmLocalUnixMakefileGenerator3 void cmLocalUnixMakefileGenerator3
::WriteDependLanguageInfo(std::ostream& cmakefileStream, cmTarget &target) ::WriteDependLanguageInfo(std::ostream& cmakefileStream,
cmGeneratorTarget* target)
{ {
ImplicitDependLanguageMap const& implicitLangs = ImplicitDependLanguageMap const& implicitLangs =
this->GetImplicitDepends(target); this->GetImplicitDepends(*target->Target);
// list the languages // list the languages
cmakefileStream cmakefileStream
@ -2030,7 +2034,7 @@ void cmLocalUnixMakefileGenerator3
// Build a list of preprocessor definitions for the target. // Build a list of preprocessor definitions for the target.
std::set<std::string> defines; std::set<std::string> defines;
this->AddCompileDefinitions(defines, &target, this->AddCompileDefinitions(defines, target,
this->ConfigName, l->first); this->ConfigName, l->first);
if(!defines.empty()) if(!defines.empty())
{ {
@ -2056,12 +2060,10 @@ void cmLocalUnixMakefileGenerator3
<< "set(CMAKE_" << l->first << "_TARGET_INCLUDE_PATH\n"; << "set(CMAKE_" << l->first << "_TARGET_INCLUDE_PATH\n";
std::vector<std::string> includes; std::vector<std::string> includes;
cmGeneratorTarget* gt = this->GetGlobalGenerator()
->GetGeneratorTarget(&target);
const std::string& config = const std::string& config =
this->Makefile->GetSafeDefinition("CMAKE_BUILD_TYPE"); this->Makefile->GetSafeDefinition("CMAKE_BUILD_TYPE");
this->GetIncludeDirectories(includes, gt, this->GetIncludeDirectories(includes, target,
l->first, config); l->first, config);
for(std::vector<std::string>::iterator i = includes.begin(); for(std::vector<std::string>::iterator i = includes.begin();
i != includes.end(); ++i) i != includes.end(); ++i)
@ -2084,7 +2086,7 @@ void cmLocalUnixMakefileGenerator3
cmSystemTools::ExpandListArgument(xform, transformRules); cmSystemTools::ExpandListArgument(xform, transformRules);
} }
if(const char* xform = if(const char* xform =
target.GetProperty("IMPLICIT_DEPENDS_INCLUDE_TRANSFORM")) target->GetProperty("IMPLICIT_DEPENDS_INCLUDE_TRANSFORM"))
{ {
cmSystemTools::ExpandListArgument(xform, transformRules); cmSystemTools::ExpandListArgument(xform, transformRules);
} }

View File

@ -182,7 +182,8 @@ protected:
// write the depend info // write the depend info
void WriteDependLanguageInfo(std::ostream& cmakefileStream, cmTarget &tgt); void WriteDependLanguageInfo(std::ostream& cmakefileStream,
cmGeneratorTarget *tgt);
// write the local help rule // write the local help rule
void WriteHelpRule(std::ostream& ruleFileStream); void WriteHelpRule(std::ostream& ruleFileStream);
@ -215,12 +216,12 @@ protected:
cmCustomCommandGenerator const& cc); cmCustomCommandGenerator const& cc);
void AppendCustomCommands(std::vector<std::string>& commands, void AppendCustomCommands(std::vector<std::string>& commands,
const std::vector<cmCustomCommand>& ccs, const std::vector<cmCustomCommand>& ccs,
cmTarget* target, cmGeneratorTarget* target,
cmLocalGenerator::RelativeRoot relative = cmLocalGenerator::RelativeRoot relative =
cmLocalGenerator::HOME_OUTPUT); cmLocalGenerator::HOME_OUTPUT);
void AppendCustomCommand(std::vector<std::string>& commands, void AppendCustomCommand(std::vector<std::string>& commands,
cmCustomCommandGenerator const& ccg, cmCustomCommandGenerator const& ccg,
cmTarget* target, cmGeneratorTarget* target,
bool echo_comment=false, bool echo_comment=false,
cmLocalGenerator::RelativeRoot relative = cmLocalGenerator::RelativeRoot relative =
cmLocalGenerator::HOME_OUTPUT, cmLocalGenerator::HOME_OUTPUT,
@ -237,7 +238,7 @@ protected:
private: private:
std::string ConvertShellCommand(std::string const& cmd, RelativeRoot root); std::string ConvertShellCommand(std::string const& cmd, RelativeRoot root);
std::string MakeLauncher(cmCustomCommandGenerator const& ccg, std::string MakeLauncher(cmCustomCommandGenerator const& ccg,
cmTarget* target, RelativeRoot relative); cmGeneratorTarget* target, RelativeRoot relative);
virtual void ComputeObjectFilenames( virtual void ComputeObjectFilenames(
std::map<cmSourceFile const*, std::string>& mapping, std::map<cmSourceFile const*, std::string>& mapping,

View File

@ -1750,12 +1750,12 @@ void cmLocalVisualStudio6Generator
flagsRelWithDebInfo = this->Makefile->GetSafeDefinition(flagVar.c_str()); flagsRelWithDebInfo = this->Makefile->GetSafeDefinition(flagVar.c_str());
flagsRelWithDebInfo += " -DCMAKE_INTDIR=\\\"RelWithDebInfo\\\" "; flagsRelWithDebInfo += " -DCMAKE_INTDIR=\\\"RelWithDebInfo\\\" ";
this->AddCompileOptions(flags, &target, linkLanguage, ""); this->AddCompileOptions(flags, gt, linkLanguage, "");
this->AddCompileOptions(flagsDebug, &target, linkLanguage, "Debug"); this->AddCompileOptions(flagsDebug, gt, linkLanguage, "Debug");
this->AddCompileOptions(flagsRelease, &target, linkLanguage, "Release"); this->AddCompileOptions(flagsRelease, gt, linkLanguage, "Release");
this->AddCompileOptions(flagsMinSizeRel, &target, linkLanguage, this->AddCompileOptions(flagsMinSizeRel, gt, linkLanguage,
"MinSizeRel"); "MinSizeRel");
this->AddCompileOptions(flagsRelWithDebInfo, &target, linkLanguage, this->AddCompileOptions(flagsRelWithDebInfo, gt, linkLanguage,
"RelWithDebInfo"); "RelWithDebInfo");
// if _UNICODE and _SBCS are not found, then add -D_MBCS // if _UNICODE and _SBCS are not found, then add -D_MBCS
@ -1775,14 +1775,14 @@ void cmLocalVisualStudio6Generator
std::set<std::string> minsizeDefinesSet; std::set<std::string> minsizeDefinesSet;
std::set<std::string> debugrelDefinesSet; std::set<std::string> debugrelDefinesSet;
this->AddCompileDefinitions(definesSet, &target, "", linkLanguage); this->AddCompileDefinitions(definesSet, gt, "", linkLanguage);
this->AddCompileDefinitions(debugDefinesSet, &target, this->AddCompileDefinitions(debugDefinesSet, gt,
"DEBUG", linkLanguage); "DEBUG", linkLanguage);
this->AddCompileDefinitions(releaseDefinesSet, &target, this->AddCompileDefinitions(releaseDefinesSet, gt,
"RELEASE", linkLanguage); "RELEASE", linkLanguage);
this->AddCompileDefinitions(minsizeDefinesSet, &target, this->AddCompileDefinitions(minsizeDefinesSet, gt,
"MINSIZEREL", linkLanguage); "MINSIZEREL", linkLanguage);
this->AddCompileDefinitions(debugrelDefinesSet, &target, this->AddCompileDefinitions(debugrelDefinesSet, gt,
"RELWITHDEBINFO", linkLanguage); "RELWITHDEBINFO", linkLanguage);
std::string defines = " "; std::string defines = " ";

View File

@ -733,7 +733,7 @@ void cmLocalVisualStudio7Generator::WriteConfiguration(std::ostream& fout,
} }
// Add the target-specific flags. // Add the target-specific flags.
this->AddCompileOptions(flags, &target, linkLanguage, configName); this->AddCompileOptions(flags, gt, linkLanguage, configName);
} }
if(this->FortranProject) if(this->FortranProject)
@ -1152,7 +1152,7 @@ void cmLocalVisualStudio7Generator::OutputBuildTool(std::ostream& fout,
} }
} }
std::string libflags; std::string libflags;
this->GetStaticLibraryFlags(libflags, configTypeUpper, &target); this->GetStaticLibraryFlags(libflags, configTypeUpper, gt);
if(!libflags.empty()) if(!libflags.empty())
{ {
fout << "\t\t\t\tAdditionalOptions=\"" << libflags << "\"\n"; fout << "\t\t\t\tAdditionalOptions=\"" << libflags << "\"\n";

View File

@ -280,10 +280,10 @@ void cmMakefileExecutableTargetGenerator::WriteExecutableRule(bool relink)
{ {
this->LocalGenerator this->LocalGenerator
->AppendCustomCommands(commands, this->Target->GetPreBuildCommands(), ->AppendCustomCommands(commands, this->Target->GetPreBuildCommands(),
this->Target); this->GeneratorTarget);
this->LocalGenerator this->LocalGenerator
->AppendCustomCommands(commands, this->Target->GetPreLinkCommands(), ->AppendCustomCommands(commands, this->Target->GetPreLinkCommands(),
this->Target); this->GeneratorTarget);
} }
// Determine whether a link script will be used. // Determine whether a link script will be used.
@ -358,7 +358,7 @@ void cmMakefileExecutableTargetGenerator::WriteExecutableRule(bool relink)
cmLocalGenerator::RuleVariables vars; cmLocalGenerator::RuleVariables vars;
vars.RuleLauncher = "RULE_LAUNCH_LINK"; vars.RuleLauncher = "RULE_LAUNCH_LINK";
vars.CMTarget = this->Target; vars.CMTarget = this->GeneratorTarget;
vars.Language = linkLanguage.c_str(); vars.Language = linkLanguage.c_str();
vars.Objects = buildObjs.c_str(); vars.Objects = buildObjs.c_str();
std::string objectDir = this->GeneratorTarget->GetSupportDirectory(); std::string objectDir = this->GeneratorTarget->GetSupportDirectory();
@ -449,7 +449,7 @@ void cmMakefileExecutableTargetGenerator::WriteExecutableRule(bool relink)
{ {
this->LocalGenerator-> this->LocalGenerator->
AppendCustomCommands(commands, this->Target->GetPostBuildCommands(), AppendCustomCommands(commands, this->Target->GetPostBuildCommands(),
this->Target); this->GeneratorTarget);
} }
// Write the build rule. // Write the build rule.

View File

@ -115,7 +115,7 @@ void cmMakefileLibraryTargetGenerator::WriteObjectLibraryRules()
// Add post-build rules. // Add post-build rules.
this->LocalGenerator-> this->LocalGenerator->
AppendCustomCommands(commands, this->Target->GetPostBuildCommands(), AppendCustomCommands(commands, this->Target->GetPostBuildCommands(),
this->Target); this->GeneratorTarget);
// Depend on the object files. // Depend on the object files.
this->AppendObjectDepends(depends); this->AppendObjectDepends(depends);
@ -146,7 +146,7 @@ void cmMakefileLibraryTargetGenerator::WriteStaticLibraryRules()
std::string extraFlags; std::string extraFlags;
this->LocalGenerator->GetStaticLibraryFlags(extraFlags, this->LocalGenerator->GetStaticLibraryFlags(extraFlags,
cmSystemTools::UpperCase(this->ConfigName), this->Target); cmSystemTools::UpperCase(this->ConfigName), this->GeneratorTarget);
this->WriteLibraryRules(linkRuleVar, extraFlags, false); this->WriteLibraryRules(linkRuleVar, extraFlags, false);
} }
@ -458,10 +458,10 @@ void cmMakefileLibraryTargetGenerator::WriteLibraryRules
{ {
this->LocalGenerator this->LocalGenerator
->AppendCustomCommands(commands, this->Target->GetPreBuildCommands(), ->AppendCustomCommands(commands, this->Target->GetPreBuildCommands(),
this->Target); this->GeneratorTarget);
this->LocalGenerator this->LocalGenerator
->AppendCustomCommands(commands, this->Target->GetPreLinkCommands(), ->AppendCustomCommands(commands, this->Target->GetPreLinkCommands(),
this->Target); this->GeneratorTarget);
} }
// Determine whether a link script will be used. // Determine whether a link script will be used.
@ -640,7 +640,7 @@ void cmMakefileLibraryTargetGenerator::WriteLibraryRules
vars.TargetVersionMinor = targetVersionMinor.c_str(); vars.TargetVersionMinor = targetVersionMinor.c_str();
vars.RuleLauncher = "RULE_LAUNCH_LINK"; vars.RuleLauncher = "RULE_LAUNCH_LINK";
vars.CMTarget = this->Target; vars.CMTarget = this->GeneratorTarget;
vars.Language = linkLanguage.c_str(); vars.Language = linkLanguage.c_str();
vars.Objects = buildObjs.c_str(); vars.Objects = buildObjs.c_str();
std::string objectDir = this->GeneratorTarget->GetSupportDirectory(); std::string objectDir = this->GeneratorTarget->GetSupportDirectory();
@ -811,7 +811,7 @@ void cmMakefileLibraryTargetGenerator::WriteLibraryRules
{ {
this->LocalGenerator-> this->LocalGenerator->
AppendCustomCommands(commands, this->Target->GetPostBuildCommands(), AppendCustomCommands(commands, this->Target->GetPostBuildCommands(),
this->Target); this->GeneratorTarget);
} }
// Compute the list of outputs. // Compute the list of outputs.

View File

@ -589,7 +589,7 @@ cmMakefileTargetGenerator
} }
cmLocalGenerator::RuleVariables vars; cmLocalGenerator::RuleVariables vars;
vars.RuleLauncher = "RULE_LAUNCH_COMPILE"; vars.RuleLauncher = "RULE_LAUNCH_COMPILE";
vars.CMTarget = this->Target; vars.CMTarget = this->GeneratorTarget;
vars.Language = lang.c_str(); vars.Language = lang.c_str();
vars.Target = targetOutPathReal.c_str(); vars.Target = targetOutPathReal.c_str();
vars.TargetPDB = targetOutPathPDB.c_str(); vars.TargetPDB = targetOutPathPDB.c_str();
@ -1040,7 +1040,7 @@ void cmMakefileTargetGenerator::WriteTargetDependRules()
return; return;
} }
this->LocalGenerator-> this->LocalGenerator->
WriteDependLanguageInfo(*this->InfoFileStream,*this->Target); WriteDependLanguageInfo(*this->InfoFileStream, this->GeneratorTarget);
// Store multiple output pairs in the depend info file. // Store multiple output pairs in the depend info file.
if(!this->MultipleOutputPairs.empty()) if(!this->MultipleOutputPairs.empty())
@ -1211,7 +1211,8 @@ void cmMakefileTargetGenerator
// Now append the actual user-specified commands. // Now append the actual user-specified commands.
std::ostringstream content; std::ostringstream content;
this->LocalGenerator->AppendCustomCommand(commands, ccg, this->Target, false, this->LocalGenerator->AppendCustomCommand(commands, ccg,
this->GeneratorTarget, false,
cmLocalGenerator::HOME_OUTPUT, cmLocalGenerator::HOME_OUTPUT,
&content); &content);

View File

@ -74,13 +74,13 @@ void cmMakefileUtilityTargetGenerator::WriteRuleFiles()
(depends, this->Target->GetPostBuildCommands()); (depends, this->Target->GetPostBuildCommands());
this->LocalGenerator->AppendCustomCommands this->LocalGenerator->AppendCustomCommands
(commands, this->Target->GetPreBuildCommands(), this->Target); (commands, this->Target->GetPreBuildCommands(), this->GeneratorTarget);
// Depend on all custom command outputs for sources // Depend on all custom command outputs for sources
this->DriveCustomCommands(depends); this->DriveCustomCommands(depends);
this->LocalGenerator->AppendCustomCommands this->LocalGenerator->AppendCustomCommands
(commands, this->Target->GetPostBuildCommands(), this->Target); (commands, this->Target->GetPostBuildCommands(), this->GeneratorTarget);
// Add dependencies on targets that must be built first. // Add dependencies on targets that must be built first.
this->AppendTargetDepends(depends); this->AppendTargetDepends(depends);

View File

@ -178,7 +178,7 @@ cmNinjaNormalTargetGenerator
if (!this->GetGlobalGenerator()->HasRule(ruleName)) { if (!this->GetGlobalGenerator()->HasRule(ruleName)) {
cmLocalGenerator::RuleVariables vars; cmLocalGenerator::RuleVariables vars;
vars.RuleLauncher = "RULE_LAUNCH_LINK"; vars.RuleLauncher = "RULE_LAUNCH_LINK";
vars.CMTarget = this->GetTarget(); vars.CMTarget = this->GetGeneratorTarget();
vars.Language = this->TargetLinkLanguage.c_str(); vars.Language = this->TargetLinkLanguage.c_str();
std::string responseFlag; std::string responseFlag;

View File

@ -335,7 +335,7 @@ cmNinjaTargetGenerator
{ {
cmLocalGenerator::RuleVariables vars; cmLocalGenerator::RuleVariables vars;
vars.RuleLauncher = "RULE_LAUNCH_COMPILE"; vars.RuleLauncher = "RULE_LAUNCH_COMPILE";
vars.CMTarget = this->GetTarget(); vars.CMTarget = this->GetGeneratorTarget();
vars.Language = lang.c_str(); vars.Language = lang.c_str();
vars.Source = "$in"; vars.Source = "$in";
vars.Object = "$out"; vars.Object = "$out";

View File

@ -120,7 +120,7 @@ static void GetCompileDefinitionsAndDirectories(
incs = cmJoin(includeDirs, ";"); incs = cmJoin(includeDirs, ";");
std::set<std::string> defines; std::set<std::string> defines;
localGen->AddCompileDefinitions(defines, target->Target, config, "CXX"); localGen->AddCompileDefinitions(defines, target, config, "CXX");
defs += cmJoin(defines, ";"); defs += cmJoin(defines, ";");
} }

View File

@ -1932,7 +1932,7 @@ bool cmVisualStudio10TargetGenerator::ComputeClOptions(
{ {
clOptions.AddFlag("CompileAs", "CompileAsCpp"); clOptions.AddFlag("CompileAs", "CompileAsCpp");
} }
this->LocalGenerator->AddCompileOptions(flags, this->Target, this->LocalGenerator->AddCompileOptions(flags, this->GeneratorTarget,
linkLanguage, configName.c_str()); linkLanguage, configName.c_str());
// Get preprocessor definitions for this directory. // Get preprocessor definitions for this directory.
@ -2189,7 +2189,7 @@ cmVisualStudio10TargetGenerator::WriteLibOptions(std::string const& config)
} }
std::string libflags; std::string libflags;
this->LocalGenerator->GetStaticLibraryFlags(libflags, this->LocalGenerator->GetStaticLibraryFlags(libflags,
cmSystemTools::UpperCase(config), this->Target); cmSystemTools::UpperCase(config), this->GeneratorTarget);
if(!libflags.empty()) if(!libflags.empty())
{ {
this->WriteString("<Lib>\n", 2); this->WriteString("<Lib>\n", 2);