cmGlobalGenerator: Add ComputeHomeRelativeOutputPath method.

Fix generation of tgt/fast build targets.

Commit 363caa2f (cmLocalGenerator: De-virtualize Configure().,
2015-05-30) moved the computation of HomeRelativeOutputPath from
Configure-time to Generate-time, because it is only used at
Generate-time.  However, that commit caused the member for one
local generator to be computed immediately before generating with
that local generator, whereas previously the members of all local
generators were computed before generating any of them.

The HomeRelativeOutputPath is used by the GetRelativeTargetDirectory
method, which is called by the
cmGlobalUnixMakefileGenerator3::WriteConvenienceRules method.  That
method is called by the
cmLocalUnixMakefileGenerator3::WriteLocalMakefile method when generating
for the top-most (ie, the first) local generator.  At that point,
the HomeRelativeOutputPath is not yet computed.

Fix that by computing the member just before generating anything.
This will eventually be done in the cmLocalUnixMakefileGenerator3
constructor instead, but further refactoring is needed to make
that possible.
This commit is contained in:
Stephen Kelly 2015-06-13 08:38:27 +02:00
parent bc1211fa7d
commit 0efe4944e1
4 changed files with 25 additions and 13 deletions

View File

@ -1273,6 +1273,11 @@ void cmGlobalGenerator::Generate()
// it builds by default.
this->FillLocalGeneratorToTargetMap();
for (i = 0; i < this->LocalGenerators.size(); ++i)
{
this->LocalGenerators[i]->ComputeHomeRelativeOutputPath();
}
// Generate project files
for (i = 0; i < this->LocalGenerators.size(); ++i)
{

View File

@ -47,6 +47,8 @@ public:
*/
virtual void Generate() {}
virtual void ComputeHomeRelativeOutputPath() {}
/**
* Calls TraceVSDependencies() on all targets of this generator.
*/

View File

@ -100,19 +100,6 @@ cmLocalUnixMakefileGenerator3::~cmLocalUnixMakefileGenerator3()
//----------------------------------------------------------------------------
void cmLocalUnixMakefileGenerator3::Generate()
{
// Compute the path to use when referencing the current output
// directory from the top output directory.
this->HomeRelativeOutputPath =
this->Convert(this->Makefile->GetCurrentBinaryDirectory(), HOME_OUTPUT);
if(this->HomeRelativeOutputPath == ".")
{
this->HomeRelativeOutputPath = "";
}
if(!this->HomeRelativeOutputPath.empty())
{
this->HomeRelativeOutputPath += "/";
}
// Store the configuration name that will be generated.
if(const char* config = this->Makefile->GetDefinition("CMAKE_BUILD_TYPE"))
{
@ -164,6 +151,22 @@ void cmLocalUnixMakefileGenerator3::Generate()
this->WriteDirectoryInformationFile();
}
void cmLocalUnixMakefileGenerator3::ComputeHomeRelativeOutputPath()
{
// Compute the path to use when referencing the current output
// directory from the top output directory.
this->HomeRelativeOutputPath =
this->Convert(this->Makefile->GetCurrentBinaryDirectory(), HOME_OUTPUT);
if(this->HomeRelativeOutputPath == ".")
{
this->HomeRelativeOutputPath = "";
}
if(!this->HomeRelativeOutputPath.empty())
{
this->HomeRelativeOutputPath += "/";
}
}
//----------------------------------------------------------------------------
void cmLocalUnixMakefileGenerator3::ComputeObjectFilenames(
std::map<cmSourceFile const*, std::string>& mapping,

View File

@ -39,6 +39,8 @@ public:
cmState::Snapshot snapshot);
virtual ~cmLocalUnixMakefileGenerator3();
virtual void ComputeHomeRelativeOutputPath();
/**
* Generate the makefile for this directory.
*/