summaryrefslogtreecommitdiffstats
path: root/Source/cmLocalUnixMakefileGenerator3.cxx
diff options
context:
space:
mode:
authorBrad King <brad.king@kitware.com>2008-10-09 19:30:07 (GMT)
committerBrad King <brad.king@kitware.com>2008-10-09 19:30:07 (GMT)
commitad44a41a187fc3a1b829397e1c9f7c5f305c084b (patch)
tree39e49f9e554aa602fae42ff084cf628a81f9166a /Source/cmLocalUnixMakefileGenerator3.cxx
parent416bf5730f33b5760bbcea9b4fb871cc9d717c6a (diff)
downloadCMake-ad44a41a187fc3a1b829397e1c9f7c5f305c084b.zip
CMake-ad44a41a187fc3a1b829397e1c9f7c5f305c084b.tar.gz
CMake-ad44a41a187fc3a1b829397e1c9f7c5f305c084b.tar.bz2
ENH: Fix optional use of relative paths.
These changes refactor cmLocalGenerator methods Convert and ConvertToOutputForExisting to support references inside the build tree using relative paths. After this commit, all tests pass with Makefile generators when relative paths are enabled by default. See issue #7779.
Diffstat (limited to 'Source/cmLocalUnixMakefileGenerator3.cxx')
-rw-r--r--Source/cmLocalUnixMakefileGenerator3.cxx55
1 files changed, 27 insertions, 28 deletions
diff --git a/Source/cmLocalUnixMakefileGenerator3.cxx b/Source/cmLocalUnixMakefileGenerator3.cxx
index a2595d9..aae96ab 100644
--- a/Source/cmLocalUnixMakefileGenerator3.cxx
+++ b/Source/cmLocalUnixMakefileGenerator3.cxx
@@ -361,7 +361,7 @@ cmLocalUnixMakefileGenerator3
}
this->CreateCDCommand(commands,
this->Makefile->GetHomeOutputDirectory(),
- this->Makefile->GetStartOutputDirectory());
+ cmLocalGenerator::START_OUTPUT);
// Write the rule to the makefile.
std::vector<std::string> no_depends;
@@ -404,7 +404,7 @@ void cmLocalUnixMakefileGenerator3
(makefile2.c_str(),localName.c_str()));
this->CreateCDCommand(commands,
this->Makefile->GetHomeOutputDirectory(),
- this->Makefile->GetStartOutputDirectory());
+ cmLocalGenerator::START_OUTPUT);
this->WriteMakeRule(ruleFileStream, "Convenience name for target.",
localName.c_str(), depends, commands, true);
@@ -432,7 +432,7 @@ void cmLocalUnixMakefileGenerator3
(makefileName.c_str(), makeTargetName.c_str()));
this->CreateCDCommand(commands,
this->Makefile->GetHomeOutputDirectory(),
- this->Makefile->GetStartOutputDirectory());
+ cmLocalGenerator::START_OUTPUT);
this->WriteMakeRule(ruleFileStream, "fast build rule for target.",
localName.c_str(), depends, commands, true);
@@ -450,7 +450,7 @@ void cmLocalUnixMakefileGenerator3
(makefile2.c_str(), makeTargetName.c_str()));
this->CreateCDCommand(commands,
this->Makefile->GetHomeOutputDirectory(),
- this->Makefile->GetStartOutputDirectory());
+ cmLocalGenerator::START_OUTPUT);
this->WriteMakeRule(ruleFileStream,
"Manual pre-install relink rule for target.",
localName.c_str(), depends, commands, true);
@@ -835,7 +835,7 @@ void cmLocalUnixMakefileGenerator3
{
this->CreateCDCommand(commands,
this->Makefile->GetHomeOutputDirectory(),
- this->Makefile->GetStartOutputDirectory());
+ cmLocalGenerator::START_OUTPUT);
}
this->WriteMakeRule(makefileStream,
"Special rule to run CMake to check the build system "
@@ -953,12 +953,13 @@ cmLocalUnixMakefileGenerator3
void
cmLocalUnixMakefileGenerator3
::AppendCustomCommands(std::vector<std::string>& commands,
- const std::vector<cmCustomCommand>& ccs)
+ const std::vector<cmCustomCommand>& ccs,
+ cmLocalGenerator::RelativeRoot relative)
{
for(std::vector<cmCustomCommand>::const_iterator i = ccs.begin();
i != ccs.end(); ++i)
{
- this->AppendCustomCommand(commands, *i, true);
+ this->AppendCustomCommand(commands, *i, true, relative);
}
}
@@ -966,7 +967,8 @@ cmLocalUnixMakefileGenerator3
void
cmLocalUnixMakefileGenerator3
::AppendCustomCommand(std::vector<std::string>& commands,
- const cmCustomCommand& cc, bool echo_comment)
+ const cmCustomCommand& cc, bool echo_comment,
+ cmLocalGenerator::RelativeRoot relative)
{
// Optionally create a command to display the custom command's
// comment text. This is used for pre-build, pre-link, and
@@ -1072,8 +1074,7 @@ cmLocalUnixMakefileGenerator3
}
// Setup the proper working directory for the commands.
- this->CreateCDCommand(commands1, dir,
- this->Makefile->GetHomeOutputDirectory());
+ this->CreateCDCommand(commands1, dir, relative);
// push back the custom commands
commands.insert(commands.end(), commands1.begin(), commands1.end());
@@ -1610,9 +1611,11 @@ void cmLocalUnixMakefileGenerator3
this->AppendCustomDepends(depends,
glIt->second.GetPostBuildCommands());
this->AppendCustomCommands(commands,
- glIt->second.GetPreBuildCommands());
+ glIt->second.GetPreBuildCommands(),
+ cmLocalGenerator::START_OUTPUT);
this->AppendCustomCommands(commands,
- glIt->second.GetPostBuildCommands());
+ glIt->second.GetPostBuildCommands(),
+ cmLocalGenerator::START_OUTPUT);
std::string targetName = glIt->second.GetName();
this->WriteMakeRule(ruleFileStream, targetString.c_str(),
targetName.c_str(), depends, commands, true);
@@ -1674,7 +1677,7 @@ void cmLocalUnixMakefileGenerator3
recursiveTarget.c_str()));
this->CreateCDCommand(commands,
this->Makefile->GetHomeOutputDirectory(),
- this->Makefile->GetStartOutputDirectory());
+ cmLocalGenerator::START_OUTPUT);
{
cmOStringStream progCmd;
progCmd << "$(CMAKE_COMMAND) -E cmake_progress_start "; // # 0
@@ -1696,7 +1699,7 @@ void cmLocalUnixMakefileGenerator3
recursiveTarget.c_str()));
this->CreateCDCommand(commands,
this->Makefile->GetHomeOutputDirectory(),
- this->Makefile->GetStartOutputDirectory());
+ cmLocalGenerator::START_OUTPUT);
this->WriteMakeRule(ruleFileStream, "The main clean target", "clean",
depends, commands, true);
commands.clear();
@@ -1726,7 +1729,7 @@ void cmLocalUnixMakefileGenerator3
(this->GetRecursiveMakeCall(mf2Dir.c_str(), recursiveTarget.c_str()));
this->CreateCDCommand(commands,
this->Makefile->GetHomeOutputDirectory(),
- this->Makefile->GetStartOutputDirectory());
+ cmLocalGenerator::START_OUTPUT);
this->WriteMakeRule(ruleFileStream, "Prepare targets for installation.",
"preinstall", depends, commands, true);
depends.clear();
@@ -1747,7 +1750,7 @@ void cmLocalUnixMakefileGenerator3
commands.push_back(runRule);
this->CreateCDCommand(commands,
this->Makefile->GetHomeOutputDirectory(),
- this->Makefile->GetStartOutputDirectory());
+ cmLocalGenerator::START_OUTPUT);
this->WriteMakeRule(ruleFileStream, "clear depends",
"depend",
depends, commands, true);
@@ -2126,8 +2129,10 @@ cmLocalUnixMakefileGenerator3::AddImplicitDepends(cmTarget const& tgt,
//----------------------------------------------------------------------------
void cmLocalUnixMakefileGenerator3
::CreateCDCommand(std::vector<std::string>& commands, const char *tgtDir,
- const char *retDir)
+ cmLocalGenerator::RelativeRoot relRetDir)
{
+ const char* retDir = this->GetRelativeRootPath(relRetDir);
+
// do we need to cd?
if (!strcmp(tgtDir,retDir))
{
@@ -2140,18 +2145,12 @@ void cmLocalUnixMakefileGenerator3
// back because the shell keeps the working directory between
// commands.
std::string cmd = "cd ";
- cmd += this->ConvertToOutputForExisting(tgtDir);
+ cmd += this->ConvertToOutputForExisting(tgtDir, relRetDir);
commands.insert(commands.begin(),cmd);
-
- // Change back to the starting directory. Any trailing slash must be
- // removed to avoid problems with Borland Make.
- std::string back = retDir;
- if(back.size() && back[back.size()-1] == '/')
- {
- back = back.substr(0, back.size()-1);
- }
+
+ // Change back to the starting directory.
cmd = "cd ";
- cmd += this->ConvertToOutputForExisting(back.c_str());
+ cmd += this->ConvertToOutputForExisting(relRetDir, tgtDir);
commands.push_back(cmd);
}
else
@@ -2163,7 +2162,7 @@ void cmLocalUnixMakefileGenerator3
for (; i != commands.end(); ++i)
{
std::string cmd = "cd ";
- cmd += this->ConvertToOutputForExisting(tgtDir);
+ cmd += this->ConvertToOutputForExisting(tgtDir, relRetDir);
cmd += " && ";
cmd += *i;
*i = cmd;