cmLocalGenerator: Port GetTargetDirectory to cmGeneratorTarget.

This commit is contained in:
Stephen Kelly 2015-10-09 22:27:46 +02:00
parent 06f56d3bf5
commit 7f5ec9f109
22 changed files with 65 additions and 59 deletions

View File

@ -403,7 +403,7 @@ cmCommonTargetGenerator::GetLinkedTargetDirectories() const
cmMakefile* mf = linkee->Target->GetMakefile();
std::string di = mf->GetCurrentBinaryDirectory();
di += "/";
di += lg->GetTargetDirectory(*linkee->Target);
di += lg->GetTargetDirectory(linkee);
dirs.push_back(di);
}
}

View File

@ -358,11 +358,13 @@ void cmExtraCodeBlocksGenerator
case cmTarget::MODULE_LIBRARY:
case cmTarget::OBJECT_LIBRARY:
{
this->AppendTarget(fout, ti->first, &ti->second,
cmGeneratorTarget* gt =
this->GlobalGenerator->GetGeneratorTarget(&ti->second);
this->AppendTarget(fout, ti->first, gt,
make.c_str(), *lg, compiler.c_str());
std::string fastTarget = ti->first;
fastTarget += "/fast";
this->AppendTarget(fout, fastTarget, &ti->second,
this->AppendTarget(fout, fastTarget, gt,
make.c_str(), *lg, compiler.c_str());
}
break;
@ -521,14 +523,14 @@ void cmExtraCodeBlocksGenerator
// Write a dummy file for OBJECT libraries, so C::B can reference some file
std::string cmExtraCodeBlocksGenerator::CreateDummyTargetFile(
cmLocalGenerator* lg,
cmTarget* target) const
cmGeneratorTarget* target) const
{
// this file doesn't seem to be used by C::B in custom makefile mode,
// but we generate a unique file for each OBJECT library so in case
// C::B uses it in some way, the targets don't interfere with each other.
std::string filename = lg->GetCurrentBinaryDirectory();
filename += "/";
filename += lg->GetTargetDirectory(*target);
filename += lg->GetTargetDirectory(target);
filename += "/";
filename += target->GetName();
filename += ".objlib";
@ -547,7 +549,7 @@ std::string cmExtraCodeBlocksGenerator::CreateDummyTargetFile(
// Generate the xml code for one target.
void cmExtraCodeBlocksGenerator::AppendTarget(cmGeneratedFileStream& fout,
const std::string& targetName,
cmTarget* target,
cmGeneratorTarget* target,
const char* make,
const cmLocalGenerator* lg,
const char* compiler)
@ -559,7 +561,7 @@ void cmExtraCodeBlocksGenerator::AppendTarget(cmGeneratedFileStream& fout,
fout<<" <Target title=\"" << targetName << "\">\n";
if (target!=0)
{
int cbTargetType = this->GetCBTargetType(target);
int cbTargetType = this->GetCBTargetType(target->Target);
std::string workingDir = lg->GetCurrentBinaryDirectory();
if ( target->GetType()==cmTarget::EXECUTABLE)
{
@ -591,9 +593,7 @@ void cmExtraCodeBlocksGenerator::AppendTarget(cmGeneratedFileStream& fout,
}
else
{
cmGeneratorTarget* gt =
this->GlobalGenerator->GetGeneratorTarget(target);
location = gt->GetLocation(buildType);
location = target->GetLocation(buildType);
}
fout<<" <Option output=\"" << location
@ -604,12 +604,9 @@ void cmExtraCodeBlocksGenerator::AppendTarget(cmGeneratedFileStream& fout,
" <Option compiler=\"" << compiler << "\" />\n"
" <Compiler>\n";
cmGeneratorTarget *gtgt = this->GlobalGenerator
->GetGeneratorTarget(target);
// the compilerdefines for this target
std::vector<std::string> cdefs;
gtgt->GetCompileDefinitions(cdefs, buildType, "C");
target->GetCompileDefinitions(cdefs, buildType, "C");
// Expand the list.
for(std::vector<std::string>::const_iterator di = cdefs.begin();
@ -623,7 +620,7 @@ void cmExtraCodeBlocksGenerator::AppendTarget(cmGeneratedFileStream& fout,
std::set<std::string> uniqIncludeDirs;
std::vector<std::string> includes;
lg->GetIncludeDirectories(includes, gtgt, "C", buildType);
lg->GetIncludeDirectories(includes, target, "C", buildType);
uniqIncludeDirs.insert(includes.begin(), includes.end());

View File

@ -17,6 +17,7 @@
class cmLocalGenerator;
class cmMakefile;
class cmGeneratorTarget;
class cmTarget;
class cmGeneratedFileStream;
@ -49,7 +50,7 @@ private:
void CreateNewProjectFile(const std::vector<cmLocalGenerator*>& lgs,
const std::string& filename);
std::string CreateDummyTargetFile(cmLocalGenerator* lg,
cmTarget* target) const;
cmGeneratorTarget* target) const;
std::string GetCBCompilerId(const cmMakefile* mf);
int GetCBTargetType(cmTarget* target);
@ -57,7 +58,7 @@ private:
const std::string& target);
void AppendTarget(cmGeneratedFileStream& fout,
const std::string& targetName,
cmTarget* target,
cmGeneratorTarget* target,
const char* make,
const cmLocalGenerator* lg,
const char* compiler);

View File

@ -1100,7 +1100,9 @@ void cmExtraEclipseCDT4Generator::CreateCProjectFile() const
cleanArgs += "\" \"";
cleanArgs += cmSystemTools::GetCMakeCommand();
cleanArgs += "\" -P \"";
cleanArgs += (*it)->GetTargetDirectory(ti->second);
cmGeneratorTarget* gt =
this->GlobalGenerator->GetGeneratorTarget(&ti->second);
cleanArgs += (*it)->GetTargetDirectory(gt);
cleanArgs += "/cmake_clean.cmake\"";
this->AppendTarget(fout, "Clean", cmSystemTools::GetCMakeCommand(),
cleanArgs, virtDir, "", "");

View File

@ -717,13 +717,11 @@ std::string cmGlobalNinjaGenerator::GetEditCacheCommand() const
void cmGlobalNinjaGenerator
::ComputeTargetObjectDirectory(cmGeneratorTarget* gt) const
{
cmTarget* target = gt->Target;
// Compute full path to object file directory for this target.
std::string dir;
dir += gt->Makefile->GetCurrentBinaryDirectory();
dir += "/";
dir += gt->LocalGenerator->GetTargetDirectory(*target);
dir += gt->LocalGenerator->GetTargetDirectory(gt);
dir += "/";
gt->ObjectDirectory = dir;
}

View File

@ -114,13 +114,11 @@ void
cmGlobalUnixMakefileGenerator3
::ComputeTargetObjectDirectory(cmGeneratorTarget* gt) const
{
cmTarget* target = gt->Target;
// Compute full path to object file directory for this target.
std::string dir;
dir += gt->Makefile->GetCurrentBinaryDirectory();
dir += "/";
dir += gt->LocalGenerator->GetTargetDirectory(*target);
dir += gt->LocalGenerator->GetTargetDirectory(gt);
dir += "/";
gt->ObjectDirectory = dir;
}

View File

@ -147,7 +147,7 @@ void cmGlobalVisualStudioGenerator
{
std::string dir = gt->Makefile->GetCurrentBinaryDirectory();
dir += "/";
std::string tgtDir = gt->LocalGenerator->GetTargetDirectory(*gt->Target);
std::string tgtDir = gt->LocalGenerator->GetTargetDirectory(gt);
if(!tgtDir.empty())
{
dir += tgtDir;

View File

@ -2908,7 +2908,7 @@ const char* cmLocalGenerator::GetCurrentSourceDirectory() const
//----------------------------------------------------------------------------
std::string
cmLocalGenerator::GetTargetDirectory(cmTarget const&) const
cmLocalGenerator::GetTargetDirectory(const cmGeneratorTarget*) const
{
cmSystemTools::Error("GetTargetDirectory"
" called on cmLocalGenerator");

View File

@ -247,7 +247,8 @@ public:
* Get the relative path from the generator output directory to a
* per-target support directory.
*/
virtual std::string GetTargetDirectory(cmTarget const& target) const;
virtual std::string
GetTargetDirectory(cmGeneratorTarget const* target) const;
/**
* Get the level of backwards compatibility requested by the project

View File

@ -100,10 +100,10 @@ void cmLocalNinjaGenerator::Generate()
// TODO: Picked up from cmLocalUnixMakefileGenerator3. Refactor it.
std::string cmLocalNinjaGenerator
::GetTargetDirectory(cmTarget const& target) const
::GetTargetDirectory(cmGeneratorTarget const* target) const
{
std::string dir = cmake::GetCMakeFilesDirectoryPostSlash();
dir += target.GetName();
dir += target->GetName();
#if defined(__VMS)
dir += "_dir";
#else

View File

@ -37,7 +37,8 @@ public:
virtual void Generate();
virtual std::string GetTargetDirectory(cmTarget const& target) const;
virtual
std::string GetTargetDirectory(cmGeneratorTarget const* target) const;
const cmGlobalNinjaGenerator* GetGlobalNinjaGenerator() const;
cmGlobalNinjaGenerator* GetGlobalNinjaGenerator();

View File

@ -191,7 +191,7 @@ GetLocalObjectFiles(std::map<std::string, LocalObjectInfo> &localObjectFiles)
std::string dir;
dir += gt->Makefile->GetCurrentBinaryDirectory();
dir += "/";
dir += this->GetTargetDirectory(*gt->Target);
dir += this->GetTargetDirectory(gt);
dir += "/";
// Compute the name of each object file.
for(std::vector<cmSourceFile const*>::iterator
@ -936,7 +936,7 @@ cmLocalUnixMakefileGenerator3
::GetRelativeTargetDirectory(cmGeneratorTarget* target)
{
std::string dir = this->HomeRelativeOutputPath;
dir += this->GetTargetDirectory(*target->Target);
dir += this->GetTargetDirectory(target);
return this->Convert(dir,NONE,UNCHANGED);
}
@ -1222,7 +1222,7 @@ cmLocalUnixMakefileGenerator3
{
std::string cleanfile = this->Makefile->GetCurrentBinaryDirectory();
cleanfile += "/";
cleanfile += this->GetTargetDirectory(target->Target);
cleanfile += this->GetTargetDirectory(target);
cleanfile += "/cmake_clean";
if(filename)
{
@ -1261,7 +1261,7 @@ cmLocalUnixMakefileGenerator3
fout << "\n"
<< "# Per-language clean rules from dependency scanning.\n"
<< "foreach(lang " << cmJoin(languages, " ") << ")\n"
<< " include(" << this->GetTargetDirectory(target->Target)
<< " include(" << this->GetTargetDirectory(target)
<< "/cmake_clean_${lang}.cmake OPTIONAL)\n"
<< "endforeach()\n";
}
@ -2282,10 +2282,10 @@ cmLocalUnixMakefileGenerator3::ConvertToQuotedOutputPath(const char* p,
//----------------------------------------------------------------------------
std::string
cmLocalUnixMakefileGenerator3
::GetTargetDirectory(cmTarget const& target) const
::GetTargetDirectory(cmGeneratorTarget const* target) const
{
std::string dir = cmake::GetCMakeFilesDirectoryPostSlash();
dir += target.GetName();
dir += target->GetName();
#if defined(__VMS)
dir += "_dir";
#else

View File

@ -106,7 +106,8 @@ public:
/** Get whether the makefile is to have color. */
bool GetColorMakefile() const { return this->ColorMakefile; }
virtual std::string GetTargetDirectory(cmTarget const& target) const;
virtual
std::string GetTargetDirectory(cmGeneratorTarget const* target) const;
// create a command that cds to the start dir then runs the commands
void CreateCDCommand(std::vector<std::string>& commands,

View File

@ -1939,7 +1939,7 @@ void cmLocalVisualStudio6Generator
std::string
cmLocalVisualStudio6Generator
::GetTargetDirectory(cmTarget const&) const
::GetTargetDirectory(cmGeneratorTarget const*) const
{
// No per-target directory for this generator (yet).
return "";

View File

@ -49,7 +49,8 @@ public:
*/
void SetBuildType(BuildType, const std::string& libName, cmTarget&);
virtual std::string GetTargetDirectory(cmTarget const& target) const;
virtual
std::string GetTargetDirectory(cmGeneratorTarget const* target) const;
virtual std::string ComputeLongestObjectDirectory(cmTarget&) const;
private:
std::string DSPHeaderTemplate;

View File

@ -784,7 +784,7 @@ void cmLocalVisualStudio7Generator::WriteConfiguration(std::ostream& fout,
// The intermediate directory name consists of a directory for the
// target and a subdirectory for the configuration name.
std::string intermediateDir = this->GetTargetDirectory(target);
std::string intermediateDir = this->GetTargetDirectory(gt);
intermediateDir += "/";
intermediateDir += configName;
@ -1113,7 +1113,7 @@ void cmLocalVisualStudio7Generator::OutputBuildTool(std::ostream& fout,
break;
case cmTarget::OBJECT_LIBRARY:
{
std::string libpath = this->GetTargetDirectory(target);
std::string libpath = this->GetTargetDirectory(gt);
libpath += "/";
libpath += configName;
libpath += "/";
@ -1725,7 +1725,9 @@ cmLocalVisualStudio7Generator
std::string dir_max;
dir_max += this->GetCurrentBinaryDirectory();
dir_max += "/";
dir_max += this->GetTargetDirectory(target);
cmGeneratorTarget* gt =
this->GlobalGenerator->GetGeneratorTarget(&target);
dir_max += this->GetTargetDirectory(gt);
dir_max += "/";
dir_max += config_max;
dir_max += "/";
@ -2369,10 +2371,10 @@ void cmLocalVisualStudio7Generator::ReadAndStoreExternalGUID(
//----------------------------------------------------------------------------
std::string cmLocalVisualStudio7Generator
::GetTargetDirectory(cmTarget const& target) const
::GetTargetDirectory(cmGeneratorTarget const* target) const
{
std::string dir;
dir += target.GetName();
dir += target->GetName();
dir += ".dir";
return dir;
}

View File

@ -53,7 +53,8 @@ public:
*/
void SetBuildType(BuildType,const std::string& name);
virtual std::string GetTargetDirectory(cmTarget const&) const;
virtual
std::string GetTargetDirectory(cmGeneratorTarget const* target) const;
cmSourceFile* CreateVCProjBuildRule();
void WriteStampFiles();
virtual std::string ComputeLongestObjectDirectory(cmTarget&) const;

View File

@ -31,7 +31,7 @@ cmLocalXCodeGenerator::~cmLocalXCodeGenerator()
//----------------------------------------------------------------------------
std::string
cmLocalXCodeGenerator::GetTargetDirectory(cmTarget const&) const
cmLocalXCodeGenerator::GetTargetDirectory(cmGeneratorTarget const*) const
{
// No per-target directory for this generator (yet).
return "";

View File

@ -28,7 +28,8 @@ public:
cmMakefile* mf);
virtual ~cmLocalXCodeGenerator();
virtual std::string GetTargetDirectory(cmTarget const& target) const;
virtual
std::string GetTargetDirectory(cmGeneratorTarget const* target) const;
virtual void AppendFlagEscape(std::string& flags,
const std::string& rawFlag);
virtual void Generate();

View File

@ -92,7 +92,7 @@ void cmMakefileTargetGenerator::CreateRuleFile()
{
// Create a directory for this target.
this->TargetBuildDirectory =
this->LocalGenerator->GetTargetDirectory(*this->Target);
this->LocalGenerator->GetTargetDirectory(this->GeneratorTarget);
this->TargetBuildDirectoryFull =
this->LocalGenerator->ConvertToFullPath(this->TargetBuildDirectory);
cmSystemTools::MakeDirectory(this->TargetBuildDirectoryFull.c_str());
@ -378,7 +378,8 @@ void cmMakefileTargetGenerator
// Get the full path name of the object file.
std::string const& objectName = this->GeneratorTarget
->GetObjectName(&source);
std::string obj = this->LocalGenerator->GetTargetDirectory(*this->Target);
std::string obj =
this->LocalGenerator->GetTargetDirectory(this->GeneratorTarget);
obj += "/";
obj += objectName;
@ -1024,7 +1025,8 @@ bool cmMakefileTargetGenerator::WriteMakeRule(
void cmMakefileTargetGenerator::WriteTargetDependRules()
{
// must write the targets depend info file
std::string dir = this->LocalGenerator->GetTargetDirectory(*this->Target);
std::string dir =
this->LocalGenerator->GetTargetDirectory(this->GeneratorTarget);
this->InfoFileNameFull = dir;
this->InfoFileNameFull += "/DependInfo.cmake";
this->InfoFileNameFull =

View File

@ -245,7 +245,7 @@ cmNinjaTargetGenerator
path += "/";
std::string const& objectName = this->GeneratorTarget
->GetObjectName(source);
path += this->LocalGenerator->GetTargetDirectory(*this->Target);
path += this->LocalGenerator->GetTargetDirectory(this->GeneratorTarget);
path += "/";
path += objectName;
return path;

View File

@ -196,7 +196,7 @@ cmVisualStudio10TargetGenerator(cmTarget* target,
this->IsMissingFiles = false;
this->DefaultArtifactDir =
this->LocalGenerator->GetCurrentBinaryDirectory() + std::string("/") +
this->LocalGenerator->GetTargetDirectory(*this->Target);
this->LocalGenerator->GetTargetDirectory(this->GeneratorTarget);
}
cmVisualStudio10TargetGenerator::~cmVisualStudio10TargetGenerator()
@ -1765,7 +1765,7 @@ void cmVisualStudio10TargetGenerator::WritePathAndIncrementalLinkOptions()
else
{
std::string intermediateDir = this->LocalGenerator->
GetTargetDirectory(*this->Target);
GetTargetDirectory(this->GeneratorTarget);
intermediateDir += "/";
intermediateDir += *config;
intermediateDir += "/";
@ -3021,7 +3021,7 @@ void cmVisualStudio10TargetGenerator::WriteWinRTPackageCertificateKeyFile()
{
// Move the manifest to a project directory to avoid clashes
std::string artifactDir =
this->LocalGenerator->GetTargetDirectory(*this->Target);
this->LocalGenerator->GetTargetDirectory(this->GeneratorTarget);
this->ConvertToWindowsSlash(artifactDir);
this->WriteString("<PropertyGroup>\n", 1);
this->WriteString("<AppxPackageArtifactsDir>", 2);
@ -3320,7 +3320,7 @@ void cmVisualStudio10TargetGenerator::WriteMissingFilesWP80()
this->LocalGenerator->GetCurrentBinaryDirectory() +
std::string("/WMAppManifest.xml");
std::string artifactDir =
this->LocalGenerator->GetTargetDirectory(*this->Target);
this->LocalGenerator->GetTargetDirectory(this->GeneratorTarget);
this->ConvertToWindowsSlash(artifactDir);
std::string artifactDirXML = cmVS10EscapeXML(artifactDir);
std::string targetNameXML = cmVS10EscapeXML(this->Target->GetName());
@ -3403,7 +3403,7 @@ void cmVisualStudio10TargetGenerator::WriteMissingFilesWP81()
std::string manifestFile =
this->DefaultArtifactDir + "/package.appxManifest";
std::string artifactDir =
this->LocalGenerator->GetTargetDirectory(*this->Target);
this->LocalGenerator->GetTargetDirectory(this->GeneratorTarget);
this->ConvertToWindowsSlash(artifactDir);
std::string artifactDirXML = cmVS10EscapeXML(artifactDir);
std::string targetNameXML = cmVS10EscapeXML(this->Target->GetName());
@ -3463,7 +3463,7 @@ void cmVisualStudio10TargetGenerator::WriteMissingFilesWS80()
std::string manifestFile =
this->DefaultArtifactDir + "/package.appxManifest";
std::string artifactDir =
this->LocalGenerator->GetTargetDirectory(*this->Target);
this->LocalGenerator->GetTargetDirectory(this->GeneratorTarget);
this->ConvertToWindowsSlash(artifactDir);
std::string artifactDirXML = cmVS10EscapeXML(artifactDir);
std::string targetNameXML = cmVS10EscapeXML(this->Target->GetName());
@ -3515,7 +3515,7 @@ void cmVisualStudio10TargetGenerator::WriteMissingFilesWS81()
std::string manifestFile =
this->DefaultArtifactDir + "/package.appxManifest";
std::string artifactDir =
this->LocalGenerator->GetTargetDirectory(*this->Target);
this->LocalGenerator->GetTargetDirectory(this->GeneratorTarget);
this->ConvertToWindowsSlash(artifactDir);
std::string artifactDirXML = cmVS10EscapeXML(artifactDir);
std::string targetNameXML = cmVS10EscapeXML(this->Target->GetName());
@ -3572,7 +3572,7 @@ void cmVisualStudio10TargetGenerator::WriteMissingFilesWS10_0()
std::string manifestFile =
this->DefaultArtifactDir + "/package.appxManifest";
std::string artifactDir =
this->LocalGenerator->GetTargetDirectory(*this->Target);
this->LocalGenerator->GetTargetDirectory(this->GeneratorTarget);
this->ConvertToWindowsSlash(artifactDir);
std::string artifactDirXML = cmVS10EscapeXML(artifactDir);
std::string targetNameXML = cmVS10EscapeXML(this->Target->GetName());