Make cmLocalGenerator::AddArchitectureFlags take a cmGeneratorTarget.

This commit is contained in:
Stephen Kelly 2012-09-16 01:16:43 +02:00
parent 4f5384e75c
commit 78bfee35d5
13 changed files with 56 additions and 49 deletions

View File

@ -315,3 +315,24 @@ cmGeneratorTarget::GetLinkInformation(const char* config)
}
return i->second;
}
//----------------------------------------------------------------------------
void cmGeneratorTarget::GetAppleArchs(const char* config,
std::vector<std::string>& archVec)
{
const char* archs = 0;
if(config && *config)
{
std::string defVarName = "OSX_ARCHITECTURES_";
defVarName += cmSystemTools::UpperCase(config);
archs = this->Target->GetProperty(defVarName.c_str());
}
if(!archs)
{
archs = this->Target->GetProperty("OSX_ARCHITECTURES");
}
if(archs)
{
cmSystemTools::ExpandListArgument(std::string(archs), archVec);
}
}

View File

@ -67,6 +67,8 @@ public:
cmComputeLinkInformation* GetLinkInformation(const char* config);
void GetAppleArchs(const char* config,
std::vector<std::string>& archVec);
private:
void ClassifySources();
void LookupObjectLibraries();

View File

@ -1713,7 +1713,10 @@ void cmGlobalXCodeGenerator::CreateBuildSettings(cmTarget& target,
// Set target-specific architectures.
std::vector<std::string> archs;
target.GetAppleArchs(configName, archs);
{
cmGeneratorTarget *gtgt = this->GetGeneratorTarget(&target);
gtgt->GetAppleArchs(configName, archs);
}
if(!archs.empty())
{
// Enable ARCHS attribute.

View File

@ -557,7 +557,7 @@ void cmLocalGenerator::GenerateTargetManifest()
void cmLocalGenerator::AddCustomCommandToCreateObject(const char* ofname,
const char* lang,
cmSourceFile& source,
cmTarget& target)
cmGeneratorTarget& target)
{
std::string objectDir = cmSystemTools::GetFilenamePath(std::string(ofname));
objectDir = this->Convert(objectDir.c_str(),START_OUTPUT,SHELL);
@ -577,7 +577,7 @@ void cmLocalGenerator::AddCustomCommandToCreateObject(const char* ofname,
flags += " ";
{
std::vector<std::string> includes;
this->GetIncludeDirectories(includes, &target, lang);
this->GetIncludeDirectories(includes, target.Target, lang);
flags += this->GetIncludeFlags(includes, lang);
}
flags += this->Makefile->GetDefineFlags();
@ -636,7 +636,8 @@ void cmLocalGenerator::AddCustomCommandToCreateObject(const char* ofname,
);
}
void cmLocalGenerator::AddBuildTargetRule(const char* llang, cmTarget& target)
void cmLocalGenerator::AddBuildTargetRule(const char* llang,
cmGeneratorTarget& target)
{
cmStdString objs;
std::vector<std::string> objVector;
@ -669,8 +670,8 @@ void cmLocalGenerator::AddBuildTargetRule(const char* llang, cmTarget& target)
}
std::string createRule = "CMAKE_";
createRule += llang;
createRule += target.GetCreateRuleVariable();
std::string targetName = target.GetFullName();
createRule += target.Target->GetCreateRuleVariable();
std::string targetName = target.Target->GetFullName();
// Executable :
// Shared Library:
// Static Library:
@ -678,7 +679,7 @@ void cmLocalGenerator::AddBuildTargetRule(const char* llang, cmTarget& target)
std::string linkLibs; // should be set
std::string flags; // should be set
std::string linkFlags; // should be set
this->GetTargetFlags(linkLibs, flags, linkFlags, target);
this->GetTargetFlags(linkLibs, flags, linkFlags, *target.Target);
cmLocalGenerator::RuleVariables vars;
vars.Language = llang;
vars.Objects = objs.c_str();
@ -715,7 +716,7 @@ void cmLocalGenerator::AddBuildTargetRule(const char* llang, cmTarget& target)
// Store this command line.
commandLines.push_back(commandLine);
}
std::string targetFullPath = target.GetFullPath();
std::string targetFullPath = target.Target->GetFullPath();
// Generate a meaningful comment for the command.
std::string comment = "Linking ";
comment += llang;
@ -729,7 +730,7 @@ void cmLocalGenerator::AddBuildTargetRule(const char* llang, cmTarget& target)
comment.c_str(),
this->Makefile->GetStartOutputDirectory()
);
target.AddSourceFile
target.Target->AddSourceFile
(this->Makefile->GetSource(targetFullPath.c_str()));
}
@ -737,11 +738,11 @@ void cmLocalGenerator::AddBuildTargetRule(const char* llang, cmTarget& target)
void cmLocalGenerator
::CreateCustomTargetsAndCommands(std::set<cmStdString> const& lang)
{
cmTargets &tgts = this->Makefile->GetTargets();
for(cmTargets::iterator l = tgts.begin();
cmGeneratorTargetsType tgts = this->Makefile->GetGeneratorTargets();
for(cmGeneratorTargetsType::iterator l = tgts.begin();
l != tgts.end(); l++)
{
cmTarget& target = l->second;
cmGeneratorTarget& target = *l->second;
switch(target.GetType())
{
case cmTarget::STATIC_LIBRARY:
@ -749,12 +750,12 @@ void cmLocalGenerator
case cmTarget::MODULE_LIBRARY:
case cmTarget::EXECUTABLE:
{
const char* llang = target.GetLinkerLanguage();
const char* llang = target.Target->GetLinkerLanguage();
if(!llang)
{
cmSystemTools::Error
("CMake can not determine linker language for target:",
target.GetName());
target.Target->GetName());
return;
}
// if the language is not in the set lang then create custom
@ -1780,7 +1781,7 @@ void cmLocalGenerator::OutputLinkLibraries(std::ostream& fout,
//----------------------------------------------------------------------------
void cmLocalGenerator::AddArchitectureFlags(std::string& flags,
cmTarget* target,
cmGeneratorTarget* target,
const char *lang,
const char* config)
{

View File

@ -16,6 +16,7 @@
class cmMakefile;
class cmGlobalGenerator;
class cmGeneratorTarget;
class cmTarget;
class cmTargetManifest;
class cmSourceFile;
@ -135,7 +136,7 @@ public:
std::vector<cmLocalGenerator*>& GetChildren() { return this->Children; };
void AddArchitectureFlags(std::string& flags, cmTarget* target,
void AddArchitectureFlags(std::string& flags, cmGeneratorTarget* target,
const char *lang, const char* config);
void AddLanguageFlags(std::string& flags, const char* lang,
@ -354,12 +355,12 @@ protected:
/** Convert a target to a utility target for unsupported
* languages of a generator */
void AddBuildTargetRule(const char* llang, cmTarget& target);
void AddBuildTargetRule(const char* llang, cmGeneratorTarget& target);
///! add a custom command to build a .o file that is part of a target
void AddCustomCommandToCreateObject(const char* ofname,
const char* lang,
cmSourceFile& source,
cmTarget& target);
cmGeneratorTarget& target);
// Create Custom Targets and commands for unsupported languages
// The set passed in should contain the languages supported by the
// generator directly. Any targets containing files that are not

View File

@ -210,7 +210,7 @@ void cmMakefileExecutableTargetGenerator::WriteExecutableRule(bool relink)
// Add language feature flags.
this->AddFeatureFlags(flags, linkLanguage);
this->LocalGenerator->AddArchitectureFlags(flags, this->Target,
this->LocalGenerator->AddArchitectureFlags(flags, this->GeneratorTarget,
linkLanguage, this->ConfigName);
// Add target-specific linker flags.

View File

@ -625,7 +625,7 @@ void cmMakefileLibraryTargetGenerator::WriteLibraryRules
std::string langFlags;
this->AddFeatureFlags(langFlags, linkLanguage);
this->LocalGenerator->AddArchitectureFlags(langFlags, this->Target,
this->LocalGenerator->AddArchitectureFlags(langFlags, this->GeneratorTarget,
linkLanguage, this->ConfigName);
// remove any language flags that might not work with the

View File

@ -259,7 +259,7 @@ std::string cmMakefileTargetGenerator::GetFlags(const std::string &l)
// Add language feature flags.
this->AddFeatureFlags(flags, lang);
this->LocalGenerator->AddArchitectureFlags(flags, this->Target,
this->LocalGenerator->AddArchitectureFlags(flags, this->GeneratorTarget,
lang, this->ConfigName);
// Fortran-specific flags computed for this target.

View File

@ -434,7 +434,7 @@ void cmNinjaNormalTargetGenerator::WriteLinkStatement()
? vars["FLAGS"]
: vars["ARCH_FLAGS"]);
this->GetLocalGenerator()->AddArchitectureFlags(flags,
this->GetTarget(),
this->GetGeneratorTarget(),
this->TargetLinkLanguage,
this->GetConfigName());
if (targetType == cmTarget::EXECUTABLE) {

View File

@ -134,7 +134,7 @@ cmNinjaTargetGenerator::ComputeFlagsForObject(cmSourceFile *source,
this->AddFeatureFlags(flags, language.c_str());
this->GetLocalGenerator()->AddArchitectureFlags(flags,
this->GetTarget(),
this->GeneratorTarget,
language.c_str(),
this->GetConfigName());

View File

@ -52,6 +52,9 @@ protected:
cmTarget* GetTarget() const
{ return this->Target; }
cmGeneratorTarget* GetGeneratorTarget() const
{ return this->GeneratorTarget; }
cmLocalNinjaGenerator* GetLocalGenerator() const
{ return this->LocalGenerator; }

View File

@ -3908,27 +3908,6 @@ void cmTarget::GetLanguages(std::set<cmStdString>& languages) const
}
}
//----------------------------------------------------------------------------
void cmTarget::GetAppleArchs(const char* config,
std::vector<std::string>& archVec)
{
const char* archs = 0;
if(config && *config)
{
std::string defVarName = "OSX_ARCHITECTURES_";
defVarName += cmSystemTools::UpperCase(config);
archs = this->GetProperty(defVarName.c_str());
}
if(!archs)
{
archs = this->GetProperty("OSX_ARCHITECTURES");
}
if(archs)
{
cmSystemTools::ExpandListArgument(std::string(archs), archVec);
}
}
//----------------------------------------------------------------------------
bool cmTarget::IsChrpathUsed(const char* config)
{

View File

@ -404,9 +404,6 @@ public:
// until we have per-target object file properties.
void GetLanguages(std::set<cmStdString>& languages) const;
/** Get the list of OS X target architectures to be built. */
void GetAppleArchs(const char* config, std::vector<std::string>& archVec);
/** Return whether this target is an executable with symbol exports
enabled. */
bool IsExecutableWithExports();