ENH: warning fixes and some first steps in cleaning up the convert code

This commit is contained in:
Ken Martin 2005-05-13 09:54:30 -04:00
parent 9e5315fb54
commit 8c65179339
7 changed files with 152 additions and 142 deletions

View File

@ -491,12 +491,6 @@ void cmGlobalGenerator::ClearEnabledLanguages()
void cmGlobalGenerator::Configure() void cmGlobalGenerator::Configure()
{ {
// Setup the current output directory components for use by
// ConvertToRelativePath.
std::string outdir =
cmSystemTools::CollapseFullPath(m_CMakeInstance->GetHomeOutputDirectory());
cmSystemTools::SplitPath(outdir.c_str(), m_HomeOutputDirectoryComponents);
// Delete any existing cmLocalGenerators // Delete any existing cmLocalGenerators
unsigned int i; unsigned int i;
for (i = 0; i < m_LocalGenerators.size(); ++i) for (i = 0; i < m_LocalGenerators.size(); ++i)
@ -1094,19 +1088,3 @@ void cmGlobalGenerator::SetupTests()
} }
} }
} }
//----------------------------------------------------------------------------
std::string cmGlobalGenerator::ConvertToHomeRelativePath(const char* remote)
{
return (this->ConvertToRelativePath(m_HomeOutputDirectoryComponents,remote));
}
//----------------------------------------------------------------------------
std::string
cmGlobalGenerator::ConvertToHomeRelativeOutputPath(const char* remote)
{
return cmSystemTools::ConvertToOutputPath
(this->ConvertToRelativePath(m_HomeOutputDirectoryComponents,remote).c_str());
}

View File

@ -138,20 +138,6 @@ public:
std::string ConvertToRelativePath(const std::vector<std::string>& local, std::string ConvertToRelativePath(const std::vector<std::string>& local,
const char* remote); const char* remote);
/**
* Convert the given remote path to a relative path with respect to
* this generator's output directory. The remote path must use
* forward slashes and not already be escaped or quoted.
*/
std::string ConvertToHomeRelativePath(const char* remote);
/**
* Convert to an output path that is relative to the output
* directory. The remote path must use forward slashes and not
* already be escaped or quoted.
*/
std::string ConvertToHomeRelativeOutputPath(const char* remote);
/* /*
* Determine what program to use for building the project. * Determine what program to use for building the project.
*/ */
@ -165,8 +151,6 @@ protected:
void ConfigureRelativePaths(); void ConfigureRelativePaths();
void SetupTests(); void SetupTests();
std::vector<std::string> m_HomeOutputDirectoryComponents;
bool m_ForceUnixPaths; bool m_ForceUnixPaths;
cmStdString m_FindMakeProgramFile; cmStdString m_FindMakeProgramFile;
cmStdString m_ConfiguredFilesPath; cmStdString m_ConfiguredFilesPath;

View File

@ -193,9 +193,8 @@ void cmGlobalUnixMakefileGenerator3::WriteMainCMakefile()
<< "SET(CMAKE_DEPENDS_GENERATOR \"" << this->GetName() << "\")\n\n"; << "SET(CMAKE_DEPENDS_GENERATOR \"" << this->GetName() << "\")\n\n";
// for each cmMakefile get its list of dependencies // for each cmMakefile get its list of dependencies
unsigned int i;
std::vector<std::string> lfiles; std::vector<std::string> lfiles;
for (i = 0; i < m_LocalGenerators.size(); ++i) for (unsigned int i = 0; i < m_LocalGenerators.size(); ++i)
{ {
lg = static_cast<cmLocalUnixMakefileGenerator3 *>(m_LocalGenerators[i]); lg = static_cast<cmLocalUnixMakefileGenerator3 *>(m_LocalGenerators[i]);
@ -244,13 +243,13 @@ void cmGlobalUnixMakefileGenerator3::WriteMainCMakefile()
// add in all the directory information files // add in all the directory information files
std::string tmpStr; std::string tmpStr;
for (i = 0; i < m_LocalGenerators.size(); ++i) for (unsigned int i = 0; i < m_LocalGenerators.size(); ++i)
{ {
lg = static_cast<cmLocalUnixMakefileGenerator3 *>(m_LocalGenerators[i]); lg = static_cast<cmLocalUnixMakefileGenerator3 *>(m_LocalGenerators[i]);
tmpStr = lg->GetMakefile()->GetStartOutputDirectory(); tmpStr = lg->GetMakefile()->GetStartOutputDirectory();
tmpStr += "/CMakeDirectoryInformation.cmake"; tmpStr += "/CMakeDirectoryInformation.cmake";
cmakefileStream cmakefileStream << " \"" <<
<< " \"" << this->ConvertToHomeRelativePath(tmpStr.c_str()).c_str() << "\"\n"; lg->Convert(tmpStr.c_str(),cmLocalGenerator::HOME_OUTPUT).c_str() << "\"\n";
} }
cmakefileStream << " )\n\n"; cmakefileStream << " )\n\n";
@ -309,8 +308,8 @@ void cmGlobalUnixMakefileGenerator3
iCheckSet.begin(); iCheckSet.begin();
csIter != iCheckSet.end(); ++csIter) csIter != iCheckSet.end(); ++csIter)
{ {
cmakefileStream cmakefileStream << " \"" <<
<< " \"" << this->ConvertToHomeRelativePath(csIter->c_str()).c_str() << "\"\n"; lg->Convert(csIter->c_str(),cmLocalGenerator::HOME_OUTPUT).c_str() << "\"\n";
} }
} }
cmakefileStream << " )\n"; cmakefileStream << " )\n";
@ -511,7 +510,7 @@ cmGlobalUnixMakefileGenerator3
depends.push_back("cmake_check_build_system"); depends.push_back("cmake_check_build_system");
std::string dir = lg->GetMakefile()->GetStartOutputDirectory(); std::string dir = lg->GetMakefile()->GetStartOutputDirectory();
dir = this->ConvertToHomeRelativeOutputPath(dir.c_str()); dir = lg->Convert(dir.c_str(),cmLocalGenerator::HOME_OUTPUT,cmLocalGenerator::MAKEFILE);
localName = dir; localName = dir;
localName += "/directory"; localName += "/directory";

View File

@ -63,10 +63,20 @@ void cmLocalGenerator::Configure()
} }
// Setup the current output directory components for use by // Setup the current output directory components for use by
// ConvertToRelativePath. // Convert
std::string outdir = std::string outdir;
cmSystemTools::CollapseFullPath(m_Makefile->GetCurrentOutputDirectory()); outdir =
cmSystemTools::SplitPath(outdir.c_str(), m_CurrentOutputDirectoryComponents); cmSystemTools::CollapseFullPath(m_Makefile->GetHomeDirectory());
cmSystemTools::SplitPath(outdir.c_str(), m_HomeDirectoryComponents);
outdir =
cmSystemTools::CollapseFullPath(m_Makefile->GetStartDirectory());
cmSystemTools::SplitPath(outdir.c_str(), m_StartDirectoryComponents);
outdir =
cmSystemTools::CollapseFullPath(m_Makefile->GetHomeOutputDirectory());
cmSystemTools::SplitPath(outdir.c_str(), m_HomeOutputDirectoryComponents);
outdir =
cmSystemTools::CollapseFullPath(m_Makefile->GetStartOutputDirectory());
cmSystemTools::SplitPath(outdir.c_str(), m_StartOutputDirectoryComponents);
// Check whether relative paths should be used for optionally // Check whether relative paths should be used for optionally
// relative paths. // relative paths.
@ -466,8 +476,10 @@ void cmLocalGenerator::AddCustomCommandToCreateObject(const char* ofname,
cmSourceFile& source, cmSourceFile& source,
cmTarget& ) cmTarget& )
{ {
std::string objectFile = this->ConvertToRelativeOutputPath(ofname); // std::string objectFile = this->ConvertToRelativeOutputPath(ofname);
std::string sourceFile = this->ConvertToOptionallyRelativeOutputPath(source.GetFullPath().c_str()); std::string objectFile = this->Convert(ofname,START_OUTPUT,SHELL);
std::string sourceFile =
this->Convert(source.GetFullPath().c_str(),START_OUTPUT,SHELL,true);
std::string varString = "CMAKE_"; std::string varString = "CMAKE_";
varString += lang; varString += lang;
varString += "_COMPILE_OBJECT"; varString += "_COMPILE_OBJECT";
@ -509,7 +521,7 @@ void cmLocalGenerator::AddCustomCommandToCreateObject(const char* ofname,
for(std::vector<std::string>::iterator i = depends.begin(); for(std::vector<std::string>::iterator i = depends.begin();
i != depends.end(); ++i) i != depends.end(); ++i)
{ {
sourceAndDeps.push_back(this->ConvertToRelativeOutputPath(i->c_str())); sourceAndDeps.push_back(this->Convert(i->c_str(),START_OUTPUT,SHELL));
} }
} }
#if 0 #if 0
@ -549,7 +561,7 @@ void cmLocalGenerator::AddBuildTargetRule(const char* llang, cmTarget& target)
ofname += (*i)->GetSourceName() + outExt; ofname += (*i)->GetSourceName() + outExt;
objVector.push_back(ofname); objVector.push_back(ofname);
this->AddCustomCommandToCreateObject(ofname.c_str(), llang, *(*i), target); this->AddCustomCommandToCreateObject(ofname.c_str(), llang, *(*i), target);
objs += this->ConvertToRelativeOutputPath(ofname.c_str()); objs += this->Convert(ofname.c_str(),START_OUTPUT,MAKEFILE);
objs += " "; objs += " ";
} }
} }
@ -878,7 +890,7 @@ cmLocalGenerator::ExpandRuleVariables(std::string& s,
std::string std::string
cmLocalGenerator::ConvertToOutputForExisting(const char* p) cmLocalGenerator::ConvertToOutputForExisting(const char* p)
{ {
std::string ret = this->ConvertToOptionallyRelativeOutputPath(p); std::string ret = this->Convert(p, START_OUTPUT, SHELL, true);
// if there are spaces in the path, then get the short path version // if there are spaces in the path, then get the short path version
// if there is one // if there is one
if(ret.find(' ') != std::string::npos) if(ret.find(' ') != std::string::npos)
@ -887,7 +899,7 @@ cmLocalGenerator::ConvertToOutputForExisting(const char* p)
{ {
if(!cmSystemTools::GetShortPath(ret.c_str(), ret)) if(!cmSystemTools::GetShortPath(ret.c_str(), ret))
{ {
ret = this->ConvertToOptionallyRelativeOutputPath(p); ret = this->Convert(p,START_OUTPUT,MAKEFILE,true);
} }
} }
} }
@ -1063,7 +1075,7 @@ void cmLocalGenerator::GetTargetFlags(std::string& linkLibs,
if((*i)->GetSourceExtension() == "def") if((*i)->GetSourceExtension() == "def")
{ {
linkFlags += m_Makefile->GetSafeDefinition("CMAKE_LINK_DEF_FILE_FLAG"); linkFlags += m_Makefile->GetSafeDefinition("CMAKE_LINK_DEF_FILE_FLAG");
linkFlags += this->ConvertToRelativeOutputPath((*i)->GetFullPath().c_str()); linkFlags += this->Convert((*i)->GetFullPath().c_str(),START_OUTPUT,MAKEFILE);
linkFlags += " "; linkFlags += " ";
} }
} }
@ -1407,7 +1419,7 @@ cmLocalGenerator::ConstructScript(const cmCustomCommandLines& commandLines,
{ {
// Start with the command name. // Start with the command name.
const cmCustomCommandLine& commandLine = *cl; const cmCustomCommandLine& commandLine = *cl;
script += this->ConvertToRelativeOutputPath(commandLine[0].c_str()); script += this->Convert(commandLine[0].c_str(),START_OUTPUT,SHELL);
// Add the arguments. // Add the arguments.
for(unsigned int j=1;j < commandLine.size(); ++j) for(unsigned int j=1;j < commandLine.size(); ++j)
@ -1425,9 +1437,7 @@ cmLocalGenerator::ConstructScript(const cmCustomCommandLines& commandLines,
//---------------------------------------------------------------------------- //----------------------------------------------------------------------------
std::string cmLocalGenerator::ConvertToRelativePath(const char* remote) std::string cmLocalGenerator::ConvertToRelativePath(const char* remote)
{ {
return (m_GlobalGenerator return this->Convert(remote,START_OUTPUT);
->ConvertToRelativePath(m_CurrentOutputDirectoryComponents,
remote));
} }
//---------------------------------------------------------------------------- //----------------------------------------------------------------------------
@ -1444,23 +1454,60 @@ cmLocalGenerator::ConvertToRelativeOutputPath(const char* remote)
std::string std::string
cmLocalGenerator::ConvertToOptionallyRelativePath(const char* remote) cmLocalGenerator::ConvertToOptionallyRelativePath(const char* remote)
{ {
if(m_UseRelativePaths) return this->Convert(remote, START_OUTPUT, UNCHANGED, true);
{
return this->ConvertToRelativePath(remote);
}
else
{
return remote;
}
} }
//---------------------------------------------------------------------------- //----------------------------------------------------------------------------
std::string std::string
cmLocalGenerator::ConvertToOptionallyRelativeOutputPath(const char* remote) cmLocalGenerator::ConvertToOptionallyRelativeOutputPath(const char* remote)
{ {
// Convert the path to a relative path. return this->Convert(remote, START_OUTPUT, SHELL, true);
std::string relative = this->ConvertToOptionallyRelativePath(remote); }
// Now convert it to an output path. //----------------------------------------------------------------------------
return cmSystemTools::ConvertToOutputPath(relative.c_str()); std::string cmLocalGenerator::Convert(const char* source,
RelativeRoot relative,
OutputFormat output,
bool optional)
{
// Convert the path to a relative path.
std::string result = source;
if (!optional || m_UseRelativePaths)
{
switch (relative)
{
case HOME:
//result = cmSystemTools::CollapseFullPath(result.c_str());
result = m_GlobalGenerator->
ConvertToRelativePath(m_HomeDirectoryComponents, result.c_str());
break;
case START:
//result = cmSystemTools::CollapseFullPath(result.c_str());
result = m_GlobalGenerator->
ConvertToRelativePath(m_StartDirectoryComponents, result.c_str());
break;
case HOME_OUTPUT:
//result = cmSystemTools::CollapseFullPath(result.c_str());
result = m_GlobalGenerator->
ConvertToRelativePath(m_HomeOutputDirectoryComponents, result.c_str());
break;
case START_OUTPUT:
//result = cmSystemTools::CollapseFullPath(result.c_str());
result = m_GlobalGenerator->
ConvertToRelativePath(m_StartOutputDirectoryComponents, result.c_str());
break;
case FULL:
result = cmSystemTools::CollapseFullPath(result.c_str());
break;
}
}
// Now convert it to an output path.
if (output == MAKEFILE || output == SHELL)
{
result = cmSystemTools::ConvertToOutputPath(result.c_str());
}
return result;
} }

View File

@ -76,6 +76,27 @@ public:
///! Set the Global Generator, done on creation by the GlobalGenerator ///! Set the Global Generator, done on creation by the GlobalGenerator
void SetGlobalGenerator(cmGlobalGenerator *gg); void SetGlobalGenerator(cmGlobalGenerator *gg);
/**
* Convert something to something else. This is a centralized coversion
* routine used by the generators to handle relative paths and the like.
* The flags determine what is actually done.
*
* relative: treat the argument as a directory and convert it to make it
* relative or full or unchanged. If relative (HOME, START etc) then that
* specifies what it should be relative to.
*
* output: make the result suitable for output to a...
*
* optional: should any relative path operation be controlled by the rel
* path setting
*/
enum RelativeRoot { NONE, FULL, HOME, START, HOME_OUTPUT, START_OUTPUT };
enum OutputFormat { UNCHANGED, MAKEFILE, SHELL };
std::string Convert(const char* source,
RelativeRoot relative,
OutputFormat output = UNCHANGED,
bool optional = false);
/** /**
* Convert the given remote path to a relative path with respect to * Convert the given remote path to a relative path with respect to
* this generator's output directory. The remote path must use * this generator's output directory. The remote path must use
@ -206,7 +227,10 @@ protected:
// members used for relative path function ConvertToMakefilePath // members used for relative path function ConvertToMakefilePath
std::string m_RelativePathToSourceDir; std::string m_RelativePathToSourceDir;
std::string m_RelativePathToBinaryDir; std::string m_RelativePathToBinaryDir;
std::vector<std::string> m_CurrentOutputDirectoryComponents; std::vector<std::string> m_HomeDirectoryComponents;
std::vector<std::string> m_StartDirectoryComponents;
std::vector<std::string> m_HomeOutputDirectoryComponents;
std::vector<std::string> m_StartOutputDirectoryComponents;
bool m_ExcludeFromAll; bool m_ExcludeFromAll;
cmLocalGenerator* m_Parent; cmLocalGenerator* m_Parent;
std::vector<cmLocalGenerator*> Children; std::vector<cmLocalGenerator*> Children;

View File

@ -205,8 +205,9 @@ void cmLocalUnixMakefileGenerator3::WriteCustomCommands()
this->AppendCleanCommand(commands, cleanFiles); this->AppendCleanCommand(commands, cleanFiles);
std::string dir = m_Makefile->GetStartOutputDirectory(); std::string dir = m_Makefile->GetStartOutputDirectory();
dir += "/CMakeCustomRules.dir/clean"; dir += "/CMakeCustomRules.dir/clean";
dir = cmSystemTools::RelativePath(m_Makefile->GetHomeOutputDirectory(), dir.c_str()); //dir = cmSystemTools::RelativePath(m_Makefile->GetHomeOutputDirectory(), dir.c_str());
dir = cmSystemTools::ConvertToOutputPath(dir.c_str()); //dir = cmSystemTools::ConvertToOutputPath(dir.c_str());
dir = this->Convert(dir.c_str(),HOME_OUTPUT,SHELL,false);
this->WriteMakeRule(ruleFileStream2, this->WriteMakeRule(ruleFileStream2,
"Clean the output of this custom command.", "Clean the output of this custom command.",
dir.c_str(), depends, commands); dir.c_str(), depends, commands);
@ -255,7 +256,7 @@ void cmLocalUnixMakefileGenerator3::WriteDirectoryInformationFile()
i != includeDirs.end(); ++i) i != includeDirs.end(); ++i)
{ {
infoFileStream infoFileStream
<< " \"" << this->ConvertToRelativePath(i->c_str()).c_str() << "\"\n"; << " \"" << this->Convert(i->c_str(),START_OUTPUT).c_str() << "\"\n";
} }
infoFileStream infoFileStream
<< " )\n"; << " )\n";
@ -481,7 +482,7 @@ cmLocalUnixMakefileGenerator3
std::string depEcho = "Scanning "; std::string depEcho = "Scanning ";
depEcho += lang; depEcho += lang;
depEcho += " dependencies of "; depEcho += " dependencies of ";
depEcho += this->ConvertToRelativeOutputPath(relativeObj.c_str()); depEcho += this->Convert(relativeObj.c_str(),NONE,SHELL);
this->AppendEcho(commands, depEcho.c_str()); this->AppendEcho(commands, depEcho.c_str());
// Add a command to call CMake to scan dependencies. CMake will // Add a command to call CMake to scan dependencies. CMake will
@ -493,8 +494,7 @@ cmLocalUnixMakefileGenerator3
<< m_GlobalGenerator->GetName() << "\" " << m_GlobalGenerator->GetName() << "\" "
<< lang << " " << lang << " "
<< relativeObj.c_str() << " " << relativeObj.c_str() << " "
<< m_GlobalGenerator->ConvertToHomeRelativeOutputPath << this->Convert(source.GetFullPath().c_str(),HOME_OUTPUT,SHELL);
(source.GetFullPath().c_str());
commands.push_back(depCmd.str()); commands.push_back(depCmd.str());
// compute the target // compute the target
@ -535,7 +535,7 @@ cmLocalUnixMakefileGenerator3
// Include the dependencies for the target. // Include the dependencies for the target.
std::string depPath = this->GetHomeRelativeOutputPath(); std::string depPath = this->GetHomeRelativeOutputPath();
depPath += depMakeFile; depPath += depMakeFile;
depMakeFile = m_GlobalGenerator->ConvertToHomeRelativeOutputPath(depPath.c_str()); depMakeFile = this->Convert(depPath.c_str(),HOME_OUTPUT,MAKEFILE);
ruleFileStream ruleFileStream
<< "# Include any dependencies generated for this rule.\n" << "# Include any dependencies generated for this rule.\n"
<< m_IncludeDirective << " " << m_IncludeDirective << " "
@ -581,11 +581,10 @@ cmLocalUnixMakefileGenerator3
std::string sourceFile = source.GetFullPath(); std::string sourceFile = source.GetFullPath();
if(m_UseRelativePaths) if(m_UseRelativePaths)
{ {
sourceFile = m_GlobalGenerator->ConvertToHomeRelativePath(sourceFile.c_str()); sourceFile = this->Convert(sourceFile.c_str(),HOME_OUTPUT);
} }
sourceFile = cmSystemTools::ConvertToOutputPath(sourceFile.c_str()); sourceFile = this->Convert(sourceFile.c_str(),NONE,SHELL);
std::string objectFile = std::string objectFile = this->Convert(obj.c_str(),START_OUTPUT,SHELL);
this->ConvertToRelativeOutputPath(obj.c_str());
// Construct the build message. // Construct the build message.
std::string relativeObj = this->GetHomeRelativeOutputPath(); std::string relativeObj = this->GetHomeRelativeOutputPath();
@ -741,7 +740,7 @@ cmLocalUnixMakefileGenerator3
cmSystemTools::MakeDirectory(this->ConvertToFullPath(dir).c_str()); cmSystemTools::MakeDirectory(this->ConvertToFullPath(dir).c_str());
// Convert the output name to a relative path if possible. // Convert the output name to a relative path if possible.
std::string output = this->ConvertToRelativePath(cc.GetOutput()); std::string output = this->Convert(cc.GetOutput(),START_OUTPUT);
// Construct the name of the rule file by transforming the output // Construct the name of the rule file by transforming the output
// name to a valid file name. Since the output is already a file // name to a valid file name. Since the output is already a file
@ -862,7 +861,7 @@ cmLocalUnixMakefileGenerator3
std::string buildTargetRuleName = dir; std::string buildTargetRuleName = dir;
buildTargetRuleName += "/build"; buildTargetRuleName += "/build";
buildTargetRuleName = buildTargetRuleName =
m_GlobalGenerator->ConvertToHomeRelativeOutputPath(buildTargetRuleName.c_str()); this->Convert(buildTargetRuleName.c_str(),HOME_OUTPUT,MAKEFILE);
this->WriteConvenienceRule(ruleFileStream, target.GetName(), this->WriteConvenienceRule(ruleFileStream, target.GetName(),
buildTargetRuleName.c_str()); buildTargetRuleName.c_str());
} }
@ -928,7 +927,7 @@ cmLocalUnixMakefileGenerator3
// Construct the left hand side of the rule. // Construct the left hand side of the rule.
replace = target; replace = target;
std::string tgt = m_GlobalGenerator->ConvertToHomeRelativeOutputPath(replace.c_str()); std::string tgt = this->Convert(replace.c_str(),HOME_OUTPUT,MAKEFILE);
tgt = this->ConvertToMakeTarget(tgt.c_str()); tgt = this->ConvertToMakeTarget(tgt.c_str());
const char* space = ""; const char* space = "";
if(tgt.size() == 1) if(tgt.size() == 1)
@ -952,7 +951,7 @@ cmLocalUnixMakefileGenerator3
dep != depends.end(); ++dep) dep != depends.end(); ++dep)
{ {
replace = *dep; replace = *dep;
replace = m_GlobalGenerator->ConvertToHomeRelativeOutputPath(replace.c_str()); replace = this->Convert(replace.c_str(),HOME_OUTPUT,MAKEFILE);
replace = this->ConvertToMakeTarget(replace.c_str()); replace = this->ConvertToMakeTarget(replace.c_str());
os << tgt.c_str() << space << ": " << replace.c_str() << "\n"; os << tgt.c_str() << space << ": " << replace.c_str() << "\n";
} }
@ -1016,13 +1015,12 @@ cmLocalUnixMakefileGenerator3
makefileStream makefileStream
<< "# The CMake executable.\n" << "# The CMake executable.\n"
<< "CMAKE_COMMAND = " << "CMAKE_COMMAND = "
<< m_GlobalGenerator->ConvertToHomeRelativeOutputPath << this->Convert(cmakecommand.c_str(),HOME_OUTPUT,MAKEFILE).c_str() << "\n"
(cmakecommand.c_str()).c_str() << "\n"
<< "\n"; << "\n";
makefileStream makefileStream
<< "# The command to remove a file.\n" << "# The command to remove a file.\n"
<< "RM = " << "RM = "
<< this->ConvertToRelativeOutputPath(cmakecommand.c_str()).c_str() << this->Convert(cmakecommand.c_str(),HOME_OUTPUT,SHELL).c_str()
<< " -E remove -f\n" << " -E remove -f\n"
<< "\n"; << "\n";
@ -1039,13 +1037,12 @@ cmLocalUnixMakefileGenerator3
makefileStream makefileStream
<< "# The top-level source directory on which CMake was run.\n" << "# The top-level source directory on which CMake was run.\n"
<< "CMAKE_SOURCE_DIR = " << "CMAKE_SOURCE_DIR = "
<< this->ConvertToRelativeOutputPath(m_Makefile->GetHomeDirectory()) << this->Convert(m_Makefile->GetHomeDirectory(), HOME_OUTPUT, SHELL)
<< "\n" << "\n"
<< "\n"; << "\n";
makefileStream makefileStream
<< "# The top-level build directory on which CMake was run.\n" << "# The top-level build directory on which CMake was run.\n"
<< "CMAKE_BINARY_DIR = " << "CMAKE_BINARY_DIR = ."
<< this->ConvertToRelativeOutputPath(m_Makefile->GetHomeOutputDirectory())
<< "\n" << "\n"
<< "\n"; << "\n";
} }
@ -1064,8 +1061,7 @@ void cmLocalUnixMakefileGenerator3::WriteMainTargetIncludes(std::ostream& makefi
// do the include // do the include
std::string dir = m_Makefile->GetStartOutputDirectory(); std::string dir = m_Makefile->GetStartOutputDirectory();
dir += "/CMakeCustomRules.dir/build.make"; dir += "/CMakeCustomRules.dir/build.make";
dir = cmSystemTools::RelativePath(m_Makefile->GetHomeOutputDirectory(), dir.c_str()); dir = this->Convert(dir.c_str(),HOME_OUTPUT,MAKEFILE);
dir = cmSystemTools::ConvertToOutputPath(dir.c_str());
makefileStream makefileStream
<< m_IncludeDirective << " " << m_IncludeDirective << " "
<< this->ConvertToOutputForExisting(dir.c_str()).c_str() << this->ConvertToOutputForExisting(dir.c_str()).c_str()
@ -1080,8 +1076,7 @@ void cmLocalUnixMakefileGenerator3::WriteMainTargetIncludes(std::ostream& makefi
// do the include // do the include
std::string dir = m_Makefile->GetStartOutputDirectory(); std::string dir = m_Makefile->GetStartOutputDirectory();
dir += "/CMakeCustomRules.dir/clean.make"; dir += "/CMakeCustomRules.dir/clean.make";
dir = cmSystemTools::RelativePath(m_Makefile->GetHomeOutputDirectory(), dir.c_str()); dir = this->Convert(dir.c_str(),HOME_OUTPUT,MAKEFILE);
dir = cmSystemTools::ConvertToOutputPath(dir.c_str());
makefileStream makefileStream
<< m_IncludeDirective << " " << m_IncludeDirective << " "
<< this->ConvertToOutputForExisting(dir.c_str()).c_str() << this->ConvertToOutputForExisting(dir.c_str()).c_str()
@ -1162,14 +1157,14 @@ void cmLocalUnixMakefileGenerator3::WriteMainTargetRules(std::ostream& makefileS
dir = lg->GetMakefile()->GetStartOutputDirectory(); dir = lg->GetMakefile()->GetStartOutputDirectory();
dir += "/"; dir += "/";
dir += rule; dir += rule;
dir = m_GlobalGenerator->ConvertToHomeRelativeOutputPath(dir.c_str()); dir = this->Convert(dir.c_str(),HOME_OUTPUT,MAKEFILE);
all_tgts.push_back(dir); all_tgts.push_back(dir);
} }
dir = m_Makefile->GetStartOutputDirectory(); dir = m_Makefile->GetStartOutputDirectory();
dir += "/"; dir += "/";
dir += rule; dir += rule;
dir = m_GlobalGenerator->ConvertToHomeRelativeOutputPath(dir.c_str()); dir = this->Convert(dir.c_str(),HOME_OUTPUT,MAKEFILE);
this->WriteMakeRule(makefileStream, 0, this->WriteMakeRule(makefileStream, 0,
dir.c_str(), all_tgts, no_commands); dir.c_str(), all_tgts, no_commands);
@ -1249,7 +1244,7 @@ cmLocalUnixMakefileGenerator3
ctest = m_ExecutableOutputPath; ctest = m_ExecutableOutputPath;
ctest += "ctest"; ctest += "ctest";
ctest += cmSystemTools::GetExecutableExtension(); ctest += cmSystemTools::GetExecutableExtension();
ctest = this->ConvertToRelativeOutputPath(ctest.c_str()); ctest = this->Convert(ctest.c_str(),START_OUTPUT,SHELL);
} }
else else
{ {
@ -1284,7 +1279,7 @@ cmLocalUnixMakefileGenerator3
// executable to install over itself. // executable to install over itself.
cmd = m_ExecutableOutputPath; cmd = m_ExecutableOutputPath;
cmd += "cmake"; cmd += "cmake";
cmd = this->ConvertToRelativeOutputPath(cmd.c_str()); cmd = this->Convert(cmd.c_str(),START_OUTPUT,SHELL);
} }
else else
{ {
@ -1363,12 +1358,11 @@ cmLocalUnixMakefileGenerator3
// the --check-build-system flag. // the --check-build-system flag.
{ {
// Build command to run CMake to check if anything needs regenerating. // Build command to run CMake to check if anything needs regenerating.
std::string cmakefileName = m_Makefile->GetStartOutputDirectory(); std::string cmakefileName = "Makefile.cmake";
cmakefileName += "/Makefile.cmake";
std::string runRule = std::string runRule =
"$(CMAKE_COMMAND) -H$(CMAKE_SOURCE_DIR) -B$(CMAKE_BINARY_DIR)"; "$(CMAKE_COMMAND) -H$(CMAKE_SOURCE_DIR) -B$(CMAKE_BINARY_DIR)";
runRule += " --check-build-system "; runRule += " --check-build-system ";
runRule += this->ConvertToRelativeOutputPath(cmakefileName.c_str()); runRule += this->Convert(cmakefileName.c_str(),NONE,SHELL);
std::vector<std::string> no_depends; std::vector<std::string> no_depends;
std::vector<std::string> commands; std::vector<std::string> commands;
@ -1449,13 +1443,11 @@ cmLocalUnixMakefileGenerator3
dir += this->GetTargetDirectory(target); dir += this->GetTargetDirectory(target);
std::string targetRequires = dir; std::string targetRequires = dir;
targetRequires += "/requires"; targetRequires += "/requires";
targetRequires = targetRequires = this->Convert(targetRequires.c_str(),HOME_OUTPUT,MAKEFILE);
m_GlobalGenerator->ConvertToHomeRelativeOutputPath(targetRequires.c_str());
std::string buildTarget = dir; std::string buildTarget = dir;
buildTarget += "/build"; buildTarget += "/build";
buildTarget = buildTarget = this->Convert(buildTarget.c_str(),HOME_OUTPUT,MAKEFILE);
m_GlobalGenerator->ConvertToHomeRelativeOutputPath(buildTarget.c_str());
std::string comment = "Directory-level requires rule for this target."; std::string comment = "Directory-level requires rule for this target.";
if(provides_requires.empty()) if(provides_requires.empty())
@ -1474,8 +1466,7 @@ cmLocalUnixMakefileGenerator3
// provides-requires mode to build the target itself. // provides-requires mode to build the target itself.
std::string targetProvides = dir; std::string targetProvides = dir;
targetProvides += "/provides"; targetProvides += "/provides";
targetProvides = targetProvides = this->Convert(targetProvides.c_str(),HOME_OUTPUT,MAKEFILE);
m_GlobalGenerator->ConvertToHomeRelativeOutputPath(targetProvides.c_str());
{ {
std::vector<std::string> no_commands; std::vector<std::string> no_commands;
std::vector<std::string> depends; std::vector<std::string> depends;
@ -1559,8 +1550,7 @@ cmLocalUnixMakefileGenerator3
targetFullPath += cmSystemTools::GetExecutableExtension(); targetFullPath += cmSystemTools::GetExecutableExtension();
// Convert to the output path to use in constructing commands. // Convert to the output path to use in constructing commands.
std::string targetOutPath = std::string targetOutPath = this->Convert(targetFullPath.c_str(),HOME_OUTPUT,MAKEFILE);
m_GlobalGenerator->ConvertToHomeRelativeOutputPath(targetFullPath.c_str());
// Get the language to use for linking this executable. // Get the language to use for linking this executable.
const char* linkLanguage = const char* linkLanguage =
@ -1671,7 +1661,7 @@ cmLocalUnixMakefileGenerator3
std::string buildTargetRuleName = dir; std::string buildTargetRuleName = dir;
buildTargetRuleName += "/build"; buildTargetRuleName += "/build";
buildTargetRuleName = buildTargetRuleName =
m_GlobalGenerator->ConvertToHomeRelativeOutputPath(buildTargetRuleName.c_str()); this->Convert(buildTargetRuleName.c_str(),HOME_OUTPUT,MAKEFILE);
this->WriteConvenienceRule(ruleFileStream, targetFullPath.c_str(), this->WriteConvenienceRule(ruleFileStream, targetFullPath.c_str(),
buildTargetRuleName.c_str()); buildTargetRuleName.c_str());
@ -1738,7 +1728,7 @@ cmLocalUnixMakefileGenerator3
extraFlags += " "; extraFlags += " ";
extraFlags += m_Makefile->GetSafeDefinition("CMAKE_LINK_DEF_FILE_FLAG"); extraFlags += m_Makefile->GetSafeDefinition("CMAKE_LINK_DEF_FILE_FLAG");
extraFlags += extraFlags +=
m_GlobalGenerator->ConvertToHomeRelativeOutputPath((*i)->GetFullPath().c_str()); this->Convert((*i)->GetFullPath().c_str(),HOME_OUTPUT,MAKEFILE);
} }
} }
} }
@ -1864,13 +1854,13 @@ cmLocalUnixMakefileGenerator3
// Construct the output path version of the names for use in command // Construct the output path version of the names for use in command
// arguments. // arguments.
std::string targetOutPath = std::string targetOutPath =
m_GlobalGenerator->ConvertToHomeRelativeOutputPath(targetFullPath.c_str()); this->Convert(targetFullPath.c_str(),HOME_OUTPUT,MAKEFILE);
std::string targetOutPathSO = std::string targetOutPathSO =
m_GlobalGenerator->ConvertToHomeRelativeOutputPath(targetFullPathSO.c_str()); this->Convert(targetFullPathSO.c_str(),HOME_OUTPUT,MAKEFILE);
std::string targetOutPathReal = std::string targetOutPathReal =
m_GlobalGenerator->ConvertToHomeRelativeOutputPath(targetFullPathReal.c_str()); this->Convert(targetFullPathReal.c_str(),HOME_OUTPUT,MAKEFILE);
std::string targetOutPathBase = std::string targetOutPathBase =
m_GlobalGenerator->ConvertToHomeRelativeOutputPath(targetFullPathBase.c_str()); this->Convert(targetFullPathBase.c_str(),HOME_OUTPUT,MAKEFILE);
// Add the link message. // Add the link message.
std::string buildEcho = "Linking "; std::string buildEcho = "Linking ";
@ -1996,7 +1986,7 @@ cmLocalUnixMakefileGenerator3
std::string buildTargetRuleName = dir; std::string buildTargetRuleName = dir;
buildTargetRuleName += "/build"; buildTargetRuleName += "/build";
buildTargetRuleName = buildTargetRuleName =
m_GlobalGenerator->ConvertToHomeRelativeOutputPath(buildTargetRuleName.c_str()); this->Convert(buildTargetRuleName.c_str(),HOME_OUTPUT,MAKEFILE);
this->WriteConvenienceRule(ruleFileStream, targetFullPath.c_str(), this->WriteConvenienceRule(ruleFileStream, targetFullPath.c_str(),
buildTargetRuleName.c_str()); buildTargetRuleName.c_str());
@ -2050,7 +2040,7 @@ cmLocalUnixMakefileGenerator3
for(std::vector<std::string>::const_iterator i = external_objects.begin(); for(std::vector<std::string>::const_iterator i = external_objects.begin();
i != external_objects.end(); ++i) i != external_objects.end(); ++i)
{ {
std::string object = m_GlobalGenerator->ConvertToHomeRelativePath(i->c_str()); object = this->Convert(i->c_str(),HOME_OUTPUT);
ruleFileStream ruleFileStream
<< " \\\n" << " \\\n"
<< this->ConvertToQuotedOutputPath(object.c_str()); << this->ConvertToQuotedOutputPath(object.c_str());
@ -2213,7 +2203,7 @@ cmLocalUnixMakefileGenerator3::GetRelativeTargetDirectory(const cmTarget& target
dir += "/"; dir += "/";
dir += this->GetTargetDirectory(target); dir += this->GetTargetDirectory(target);
dir = cmSystemTools::RelativePath(m_Makefile->GetHomeOutputDirectory(), dir.c_str()); dir = cmSystemTools::RelativePath(m_Makefile->GetHomeOutputDirectory(), dir.c_str());
return cmSystemTools::ConvertToOutputPath(dir.c_str()); return this->Convert(dir.c_str(),NONE,MAKEFILE);
} }
//---------------------------------------------------------------------------- //----------------------------------------------------------------------------
@ -2222,7 +2212,7 @@ cmLocalUnixMakefileGenerator3
::GetSubdirTargetName(const char* pass, const char* subdir) ::GetSubdirTargetName(const char* pass, const char* subdir)
{ {
// Convert the subdirectory name to a relative path to keep it short. // Convert the subdirectory name to a relative path to keep it short.
std::string reldir = this->ConvertToRelativePath(subdir); std::string reldir = this->Convert(subdir,START_OUTPUT);
// Convert the subdirectory name to a valid make target name. // Convert the subdirectory name to a valid make target name.
std::string s = pass; std::string s = pass;
@ -2301,17 +2291,6 @@ cmLocalUnixMakefileGenerator3
->GetLanguageFromExtension(source.GetSourceExtension().c_str())); ->GetLanguageFromExtension(source.GetSourceExtension().c_str()));
} }
//----------------------------------------------------------------------------
std::string
cmLocalUnixMakefileGenerator3::ConvertToRelativeOutputPath(const char* p)
{
// Convert the path to a relative path.
std::string relative = this->ConvertToRelativePath(p);
// Now convert it to an output path.
return cmSystemTools::ConvertToOutputPath(relative.c_str());
}
//---------------------------------------------------------------------------- //----------------------------------------------------------------------------
std::string std::string
cmLocalUnixMakefileGenerator3::ConvertToQuotedOutputPath(const char* p) cmLocalUnixMakefileGenerator3::ConvertToQuotedOutputPath(const char* p)
@ -2587,14 +2566,14 @@ cmLocalUnixMakefileGenerator3
const cmCustomCommandLine& commandLine = *cl; const cmCustomCommandLine& commandLine = *cl;
std::string cmd = commandLine[0]; std::string cmd = commandLine[0];
cmSystemTools::ReplaceString(cmd, "/./", "/"); cmSystemTools::ReplaceString(cmd, "/./", "/");
cmd = m_GlobalGenerator->ConvertToHomeRelativePath(cmd.c_str()); cmd = this->Convert(cmd.c_str(),HOME_OUTPUT);
if(cmd.find("/") == cmd.npos && if(cmd.find("/") == cmd.npos &&
commandLine[0].find("/") != cmd.npos) commandLine[0].find("/") != cmd.npos)
{ {
// Add a leading "./" for executables in the current directory. // Add a leading "./" for executables in the current directory.
cmd = "./" + cmd; cmd = "./" + cmd;
} }
cmd = cmSystemTools::ConvertToOutputPath(cmd.c_str()); cmd = this->Convert(cmd.c_str(),NONE,SHELL);
for(unsigned int j=1; j < commandLine.size(); ++j) for(unsigned int j=1; j < commandLine.size(); ++j)
{ {
cmd += " "; cmd += " ";
@ -2617,7 +2596,7 @@ cmLocalUnixMakefileGenerator3
f != files.end(); ++f) f != files.end(); ++f)
{ {
remove += " "; remove += " ";
remove += this->ConvertToRelativeOutputPath(f->c_str()); remove += this->Convert(f->c_str(),START_OUTPUT,SHELL);
} }
commands.push_back(remove); commands.push_back(remove);
} }
@ -3008,7 +2987,7 @@ void cmLocalUnixMakefileGenerator3::WriteLocalMakefile()
// Write the empty all rule. // Write the empty all rule.
std::string dir = m_Makefile->GetStartOutputDirectory(); std::string dir = m_Makefile->GetStartOutputDirectory();
dir += "/directory"; dir += "/directory";
dir = m_GlobalGenerator->ConvertToHomeRelativeOutputPath(dir.c_str()); dir = this->Convert(dir.c_str(),HOME_OUTPUT,MAKEFILE);
this->CreateJumpCommand(commands,dir); this->CreateJumpCommand(commands,dir);
this->WriteMakeRule(ruleFileStream, "The main all target", "all", depends, commands); this->WriteMakeRule(ruleFileStream, "The main all target", "all", depends, commands);
@ -3170,7 +3149,7 @@ cmLocalUnixMakefileGenerator3
// Add the target. // Add the target.
if (tgt && tgt[0] != '\0') if (tgt && tgt[0] != '\0')
{ {
std::string tgt2 = m_GlobalGenerator->ConvertToHomeRelativeOutputPath(tgt); std::string tgt2 = this->Convert(tgt,HOME_OUTPUT,MAKEFILE);
tgt2 = this->ConvertToMakeTarget(tgt2.c_str()); tgt2 = this->ConvertToMakeTarget(tgt2.c_str());
cmd += tgt2; cmd += tgt2;
} }

View File

@ -134,7 +134,6 @@ public:
void WriteSpecialTargetsBottom(std::ostream& makefileStream); void WriteSpecialTargetsBottom(std::ostream& makefileStream);
std::string ConvertToRelativeOutputPath(const char* p);
std::string GetRelativeTargetDirectory(const cmTarget& target); std::string GetRelativeTargetDirectory(const cmTarget& target);
void WriteLocalCleanRule(std::ostream& makefileStream); void WriteLocalCleanRule(std::ostream& makefileStream);