summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--Source/cmBorlandMakefileGenerator.cxx42
-rw-r--r--Source/cmDSPWriter.cxx46
-rw-r--r--Source/cmExecProgramCommand.cxx2
-rw-r--r--Source/cmMSDotNETGenerator.cxx46
-rw-r--r--Source/cmNMakeMakefileGenerator.cxx84
-rw-r--r--Source/cmNMakeMakefileGenerator.h2
-rw-r--r--Source/cmSystemTools.cxx171
-rw-r--r--Source/cmSystemTools.h53
-rw-r--r--Source/cmUnixMakefileGenerator.cxx79
-rw-r--r--Source/cmUnixMakefileGenerator.h5
-rw-r--r--Source/cmaketest.cxx10
11 files changed, 269 insertions, 271 deletions
diff --git a/Source/cmBorlandMakefileGenerator.cxx b/Source/cmBorlandMakefileGenerator.cxx
index 5d91594..ee4c3f4 100644
--- a/Source/cmBorlandMakefileGenerator.cxx
+++ b/Source/cmBorlandMakefileGenerator.cxx
@@ -101,18 +101,18 @@ void cmBorlandMakefileGenerator::OutputMakeVariables(std::ostream& fout)
m_Makefile->ExpandVariablesInString(replaceVars);
std::string ccompiler = m_Makefile->GetDefinition("CMAKE_C_COMPILER");
- cmSystemTools::ConvertToWindowsSlashes(ccompiler);
- fout << "CMAKE_C_COMPILER = " << cmSystemTools::EscapeSpaces(ccompiler.c_str())
+ fout << "CMAKE_C_COMPILER = "
+ << this->ConvertToOutputPath(ccompiler.c_str())
<< "\n";
std::string cxxcompiler = m_Makefile->GetDefinition("CMAKE_CXX_COMPILER");
- cmSystemTools::ConvertToWindowsSlashes(cxxcompiler);
- fout << "CMAKE_CXX_COMPILER = " << cmSystemTools::EscapeSpaces(cxxcompiler.c_str())
+ fout << "CMAKE_CXX_COMPILER = "
+ << this->ConvertToOutputPath(cxxcompiler.c_str())
<< "\n";
std::string cmakecommand = m_Makefile->GetDefinition("CMAKE_COMMAND");
- cmSystemTools::ConvertToWindowsSlashes(cmakecommand);
- fout << "CMAKE_COMMAND = " << cmSystemTools::EscapeSpaces(cmakecommand.c_str()) << "\n";
+ fout << "CMAKE_COMMAND = "
+ << this->ConvertToOutputPath(cmakecommand.c_str()) << "\n";
fout << replaceVars.c_str();
fout << "CMAKE_CURRENT_SOURCE = "
@@ -130,17 +130,15 @@ void cmBorlandMakefileGenerator::OutputMakeVariables(std::ostream& fout)
fout << "INCLUDE_FLAGS = ";
std::vector<std::string>& includes = m_Makefile->GetIncludeDirectories();
std::vector<std::string>::iterator i;
- fout << "-I" << cmSystemTools::EscapeSpaces(m_Makefile->GetStartDirectory()) << " ";
+ fout << "-I" <<
+ this->ConvertToOutputPath(m_Makefile->GetStartDirectory()) << " ";
for(i = includes.begin(); i != includes.end(); ++i)
{
std::string include = *i;
// Don't output a -I for the standard include path "/usr/include".
// This can cause problems with certain standard library
// implementations because the wrong headers may be found first.
- if(include != "/usr/include")
- {
- fout << "-I" << cmSystemTools::EscapeSpaces(i->c_str()).c_str() << " ";
- }
+ fout << "-I" << this->ConvertToOutputPath(i->c_str()).c_str() << " ";
}
fout << m_Makefile->GetDefineFlags();
fout << "\n\n";
@@ -168,7 +166,7 @@ OutputBuildObjectFromSource(std::ostream& fout,
std::string comment = "Build ";
std::string objectFile = std::string(shortName) +
this->GetOutputExtension(source.GetSourceExtension().c_str());
- cmSystemTools::ConvertToWindowsSlashes(objectFile);
+ objectFile = this->ConvertToOutputPath(objectFile.c_str());
comment += objectFile + " From ";
comment += source.GetFullPath();
std::string compileCommand;
@@ -185,7 +183,7 @@ OutputBuildObjectFromSource(std::ostream& fout,
compileCommand += objectFile;
compileCommand += " $(INCLUDE_FLAGS) -c ";
compileCommand +=
- cmSystemTools::EscapeSpaces(source.GetFullPath().c_str());
+ this->ConvertToOutputPath(source.GetFullPath().c_str());
}
else if (ext == "rc")
{
@@ -193,7 +191,7 @@ OutputBuildObjectFromSource(std::ostream& fout,
compileCommand += objectFile;
compileCommand += "\" ";
compileCommand +=
- cmSystemTools::EscapeSpaces(source.GetFullPath().c_str());
+ this->ConvertToOutputPath(source.GetFullPath().c_str());
}
else if (ext == "def")
{
@@ -213,12 +211,12 @@ OutputBuildObjectFromSource(std::ostream& fout,
compileCommand += objectFile;
compileCommand += " $(INCLUDE_FLAGS) -c ";
compileCommand +=
- cmSystemTools::EscapeSpaces(source.GetFullPath().c_str());
+ this->ConvertToOutputPath(source.GetFullPath().c_str());
}
this->OutputMakeRule(fout,
comment.c_str(),
objectFile.c_str(),
- cmSystemTools::EscapeSpaces(
+ this->ConvertToOutputPath(
source.GetFullPath().c_str()).c_str(),
compileCommand.c_str());
}
@@ -230,10 +228,8 @@ void cmBorlandMakefileGenerator::OutputSharedLibraryRule(std::ostream& fout,
std::string target = m_LibraryOutputPath + name;
std::string libpath = target + ".lib";
target += ".dll";
- cmSystemTools::ConvertToWindowsSlashes(libpath);
- cmSystemTools::ConvertToWindowsSlashes(target);
- target = cmSystemTools::EscapeSpaces(target.c_str());
- libpath = cmSystemTools::EscapeSpaces(libpath.c_str());
+ target = this->ConvertToOutputPath(target.c_str());
+ libpath = this->ConvertToOutputPath(libpath.c_str());
std::string depend = "$(";
depend += this->CreateMakeVariable(name, "_SRC_OBJS");
depend += ") $(" + this->CreateMakeVariable(name, "_DEPEND_LIBS") + ")";
@@ -290,8 +286,7 @@ void cmBorlandMakefileGenerator::OutputStaticLibraryRule(std::ostream& fout,
const cmTarget &t)
{
std::string target = m_LibraryOutputPath + std::string(name) + ".lib";
- cmSystemTools::ConvertToWindowsSlashes(target);
- target = cmSystemTools::EscapeSpaces(target.c_str());
+ target = this->ConvertToOutputPath(target.c_str());
std::string depend = "$(";
depend += this->CreateMakeVariable(name, "_SRC_OBJS") + ") ";
std::string command = "tlib @&&|\n\t /p512 /a ";
@@ -326,8 +321,7 @@ void cmBorlandMakefileGenerator::OutputExecutableRule(std::ostream& fout,
const cmTarget &t)
{
std::string target = m_ExecutableOutputPath + name + m_ExecutableExtension;
- cmSystemTools::ConvertToWindowsSlashes(target);
- target = cmSystemTools::EscapeSpaces(target.c_str());
+ target = this->ConvertToOutputPath(target.c_str());
std::string depend = "$(";
depend += this->CreateMakeVariable(name, "_SRC_OBJS") + ") $(" +
this->CreateMakeVariable(name, "_DEPEND_LIBS") + ")";
diff --git a/Source/cmDSPWriter.cxx b/Source/cmDSPWriter.cxx
index d895e8d..f60840d 100644
--- a/Source/cmDSPWriter.cxx
+++ b/Source/cmDSPWriter.cxx
@@ -48,8 +48,7 @@ void cmDSPWriter::OutputDSPFile()
for(i = includes.begin(); i != includes.end(); ++i)
{
m_IncludeOptions += " /I ";
- std::string tmp = cmSystemTools::EscapeSpaces(i->c_str());
- cmSystemTools::ConvertToWindowsSlashesAndCleanUp(tmp);
+ std::string tmp = cmSystemTools::ConvertToOutputPath(i->c_str());
// quote if not already quoted
if (tmp[0] != '"')
@@ -147,20 +146,23 @@ void cmDSPWriter::AddDSPBuildRule(cmSourceGroup& sourceGroup)
std::string makefileIn = m_Makefile->GetStartDirectory();
makefileIn += "/";
makefileIn += "CMakeLists.txt";
- makefileIn = cmSystemTools::HandleNetworkPaths(makefileIn.c_str());
- makefileIn = cmSystemTools::EscapeSpaces(makefileIn.c_str());
+ makefileIn = cmSystemTools::ConvertToOutputPath(makefileIn.c_str());
std::string dsprule = "${CMAKE_COMMAND}";
m_Makefile->ExpandVariablesInString(dsprule);
- dsprule = cmSystemTools::HandleNetworkPaths(dsprule.c_str());
+ dsprule = cmSystemTools::ConvertToOutputPath(dsprule.c_str());
std::string args = makefileIn;
args += " -H\"";
- args += cmSystemTools::HandleNetworkPaths(m_Makefile->GetHomeDirectory());
+ args +=
+ cmSystemTools::ConvertToOutputPath(m_Makefile->GetHomeDirectory());
args += "\" -S\"";
- args += cmSystemTools::HandleNetworkPaths(m_Makefile->GetStartDirectory());
+ args +=
+ cmSystemTools::ConvertToOutputPath(m_Makefile->GetStartDirectory());
args += "\" -O\"";
- args += cmSystemTools::HandleNetworkPaths(m_Makefile->GetStartOutputDirectory());
+ args +=
+ cmSystemTools::ConvertToOutputPath(m_Makefile->GetStartOutputDirectory());
args += "\" -B\"";
- args += cmSystemTools::HandleNetworkPaths(m_Makefile->GetHomeOutputDirectory());
+ args +=
+ cmSystemTools::ConvertToOutputPath(m_Makefile->GetHomeOutputDirectory());
args += "\"";
m_Makefile->ExpandVariablesInString(args);
@@ -268,7 +270,8 @@ void cmDSPWriter::WriteDSPFile(std::ostream& fout,
// Tell MS-Dev what the source is. If the compiler knows how to
// build it, then it will.
- fout << "SOURCE=" << cmSystemTools::EscapeSpaces(source.c_str()) << "\n\n";
+ fout << "SOURCE=" <<
+ cmSystemTools::ConvertToOutputPath(source.c_str()) << "\n\n";
if (!commands.empty())
{
cmSourceGroup::CommandFiles totalCommand;
@@ -315,12 +318,11 @@ void cmDSPWriter::WriteCustomRule(std::ostream& fout,
// Write out the dependencies for the rule.
fout << "USERDEP__HACK=";
- std::string temp;
for(std::set<std::string>::const_iterator d = depends.begin();
d != depends.end(); ++d)
{
- temp = *d;
- fout << "\\\n\t" << cmSystemTools::EscapeSpaces(cmSystemTools::ConvertToWindowsSlashes(temp));
+ fout << "\\\n\t" <<
+ cmSystemTools::ConvertToOutputPath(d->c_str());
}
fout << "\n";
@@ -455,8 +457,7 @@ cmDSPWriter::CombineCommands(const cmSourceGroup::Commands &commands,
{
totalCommandStr += "\n\t";
temp= c->second.m_Command;
- cmSystemTools::ConvertToWindowsSlashes(temp);
- temp = cmSystemTools::EscapeSpaces(temp.c_str());
+ temp = cmSystemTools::ConvertToOutputPath(temp.c_str());
totalCommandStr += temp;
totalCommandStr += " ";
totalCommandStr += c->second.m_Arguments;
@@ -556,7 +557,8 @@ void cmDSPWriter::WriteDSPHeader(std::ostream& fout, const char *libName,
{
libPath += "/";
}
- std::string lpath = cmSystemTools::HandleNetworkPaths(libPath.c_str());
+ std::string lpath =
+ cmSystemTools::ConvertToOutputPath(libPath.c_str());
if(pathEmitted.insert(lpath).second)
{
libOptions += " /LIBPATH:\"";
@@ -580,7 +582,8 @@ void cmDSPWriter::WriteDSPHeader(std::ostream& fout, const char *libName,
{
exePath += "/";
}
- std::string lpath = cmSystemTools::HandleNetworkPaths(exePath.c_str());
+ std::string lpath =
+ cmSystemTools::ConvertToOutputPath(exePath.c_str());
if(pathEmitted.insert(lpath).second)
{
libOptions += " /LIBPATH:\"";
@@ -601,7 +604,8 @@ void cmDSPWriter::WriteDSPHeader(std::ostream& fout, const char *libName,
std::vector<std::string>& libdirs = m_Makefile->GetLinkDirectories();
for(i = libdirs.begin(); i != libdirs.end(); ++i)
{
- std::string lpath = cmSystemTools::HandleNetworkPaths(i->c_str());
+ std::string lpath =
+ cmSystemTools::ConvertToOutputPath(i->c_str());
if(lpath[lpath.size()-1] != '/')
{
lpath += "/";
@@ -640,7 +644,7 @@ void cmDSPWriter::WriteDSPHeader(std::ostream& fout, const char *libName,
{
lib += ".lib";
}
- lib = cmSystemTools::EscapeSpaces(lib.c_str());
+ lib = cmSystemTools::ConvertToOutputPath(lib.c_str());
if (j->second == cmTarget::GENERAL)
{
@@ -725,9 +729,9 @@ void cmDSPWriter::WriteDSPHeader(std::ostream& fout, const char *libName,
m_IncludeOptions.c_str());
cmSystemTools::ReplaceString(line, "OUTPUT_LIBNAME",libName);
cmSystemTools::ReplaceString(line, "LIBRARY_OUTPUT_PATH",
- cmSystemTools::HandleNetworkPaths(libPath.c_str()).c_str());
+ cmSystemTools::ConvertToOutputPath(libPath.c_str()).c_str());
cmSystemTools::ReplaceString(line, "EXECUTABLE_OUTPUT_PATH",
- cmSystemTools::HandleNetworkPaths(exePath.c_str()).c_str());
+ cmSystemTools::ConvertToOutputPath(exePath.c_str()).c_str());
cmSystemTools::ReplaceString(line,
"EXTRA_DEFINES",
m_Makefile->GetDefineFlags());
diff --git a/Source/cmExecProgramCommand.cxx b/Source/cmExecProgramCommand.cxx
index abfeafc..1953e33 100644
--- a/Source/cmExecProgramCommand.cxx
+++ b/Source/cmExecProgramCommand.cxx
@@ -34,7 +34,7 @@ bool cmExecProgramCommand::InitialPass(std::vector<std::string> const& argsIn)
cmSystemTools::MakeDirectory(args[1].c_str());
std::string command;
command = "cd ";
- command += args[1].c_str();
+ command += cmSystemTools::ConvertToOutputPath(args[1].c_str());
command += " && ";
command += args[0].c_str();
cmSystemTools::RunCommand(command.c_str(), output);
diff --git a/Source/cmMSDotNETGenerator.cxx b/Source/cmMSDotNETGenerator.cxx
index d99881e..27df9df 100644
--- a/Source/cmMSDotNETGenerator.cxx
+++ b/Source/cmMSDotNETGenerator.cxx
@@ -306,8 +306,7 @@ void cmMSDotNETGenerator::WriteProject(std::ostream& fout,
const cmTarget& target
)
{
- std::string d = dir;
- cmSystemTools::ConvertToWindowsSlashes(d);
+ std::string d = cmSystemTools::ConvertToOutputPath(dir);
fout << "Project(\"{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}\" = \""
<< dspname << "\", \""
<< d << "\\" << dspname << ".vcproj\", \"{"
@@ -485,7 +484,8 @@ void cmMSDotNETGenerator::OutputVCProjFile()
{
m_LibraryOutputPath += "/";
}
- m_LibraryOutputPath = cmSystemTools::HandleNetworkPaths(m_LibraryOutputPath.c_str());
+ m_LibraryOutputPath =
+ cmSystemTools::ConvertToOutputPath(m_LibraryOutputPath.c_str());
}
m_ExecutableOutputPath = "";
if (m_Makefile->GetDefinition("EXECUTABLE_OUTPUT_PATH"))
@@ -500,14 +500,14 @@ void cmMSDotNETGenerator::OutputVCProjFile()
m_ExecutableOutputPath += "/";
}
}
- m_ExecutableOutputPath = cmSystemTools::HandleNetworkPaths(m_ExecutableOutputPath.c_str());
+ m_ExecutableOutputPath =
+ cmSystemTools::ConvertToOutputPath(m_ExecutableOutputPath.c_str());
std::vector<std::string>& includes = m_Makefile->GetIncludeDirectories();
std::vector<std::string>::iterator i;
for(i = includes.begin(); i != includes.end(); ++i)
{
- std::string tmp = cmSystemTools::EscapeSpaces(i->c_str());
- cmSystemTools::ConvertToWindowsSlashesAndCleanUp(tmp);
+ std::string tmp = cmSystemTools::ConvertToOutputPath(i->c_str());
m_IncludeOptions += ",";
// quote if not already quoted
if (tmp[0] != '"')
@@ -578,20 +578,23 @@ void cmMSDotNETGenerator::AddVCProjBuildRule(cmSourceGroup& sourceGroup)
std::string makefileIn = m_Makefile->GetStartDirectory();
makefileIn += "/";
makefileIn += "CMakeLists.txt";
- makefileIn = cmSystemTools::HandleNetworkPaths(makefileIn.c_str());
- makefileIn = cmSystemTools::EscapeSpaces(makefileIn.c_str());
+ makefileIn = cmSystemTools::ConvertToOutputPath(makefileIn.c_str());
std::string dsprule = "${CMAKE_COMMAND}";
m_Makefile->ExpandVariablesInString(dsprule);
- dsprule = cmSystemTools::HandleNetworkPaths(dsprule.c_str());
+ dsprule = cmSystemTools::ConvertToOutputPath(dsprule.c_str());
std::string args = makefileIn;
args += " -H\"";
- args += cmSystemTools::HandleNetworkPaths(m_Makefile->GetHomeDirectory());
+ args +=
+ cmSystemTools::ConvertToOutputPath(m_Makefile->GetHomeDirectory());
args += "\" -S\"";
- args += cmSystemTools::HandleNetworkPaths(m_Makefile->GetStartDirectory());
+ args +=
+ cmSystemTools::ConvertToOutputPath(m_Makefile->GetStartDirectory());
args += "\" -O\"";
- args += cmSystemTools::HandleNetworkPaths(m_Makefile->GetStartOutputDirectory());
+ args +=
+ cmSystemTools::ConvertToOutputPath(m_Makefile->GetStartOutputDirectory());
args += "\" -B\"";
- args += cmSystemTools::HandleNetworkPaths(m_Makefile->GetHomeOutputDirectory());
+ args +=
+ cmSystemTools::ConvertToOutputPath(m_Makefile->GetHomeOutputDirectory());
args += "\"";
m_Makefile->ExpandVariablesInString(args);
@@ -824,7 +827,7 @@ void cmMSDotNETGenerator::OutputLibraryDirectories(std::ostream& fout,
std::vector<std::string>& libdirs = m_Makefile->GetLinkDirectories();
for(i = libdirs.begin(); i != libdirs.end(); ++i)
{
- std::string lpath = cmSystemTools::HandleNetworkPaths(i->c_str());
+ std::string lpath = cmSystemTools::ConvertToOutputPath(i->c_str());
if(lpath[lpath.size()-1] != '/')
{
lpath += "/";
@@ -855,7 +858,7 @@ void cmMSDotNETGenerator::OutputLibraries(std::ostream& fout,
{
lib += ".lib";
}
- lib = cmSystemTools::EscapeSpaces(lib.c_str());
+ lib = cmSystemTools::ConvertToOutputPath(lib.c_str());
if (j->second == cmTarget::GENERAL
|| (j->second == cmTarget::DEBUG && strcmp(configName, "DEBUG") == 0)
|| (j->second == cmTarget::OPTIMIZED && strcmp(configName, "DEBUG") != 0))
@@ -968,11 +971,10 @@ void cmMSDotNETGenerator::WriteVCProjFile(std::ostream& fout,
if (source != libName || target.GetType() == cmTarget::UTILITY)
{
fout << "\t\t\t<File\n";
- std::string d = source;
- cmSystemTools::ConvertToWindowsSlashes(d);
+ std::string d = cmSystemTools::ConvertToOutputPath(source.c_str());
// Tell MS-Dev what the source is. If the compiler knows how to
// build it, then it will.
- fout << "\t\t\t\tRelativePath=\"" << cmSystemTools::EscapeSpaces(d.c_str()) << "\">\n";
+ fout << "\t\t\t\tRelativePath=\"" << d << "\">\n";
if (!commands.empty())
{
cmSourceGroup::CommandFiles totalCommand;
@@ -1022,8 +1024,7 @@ void cmMSDotNETGenerator::WriteCustomRule(std::ostream& fout,
for(std::set<std::string>::const_iterator d = depends.begin();
d != depends.end(); ++d)
{
- temp = *d;
- fout << cmSystemTools::EscapeSpaces(cmSystemTools::ConvertToWindowsSlashes(temp))
+ fout << cmSystemTools::ConvertToOutputPath(d->c_str())
<< ";";
}
fout << "\"\n";
@@ -1087,9 +1088,8 @@ cmMSDotNETGenerator::CombineCommands(const cmSourceGroup::Commands &commands,
for(cmSourceGroup::Commands::const_iterator c = commands.begin();
c != commands.end(); ++c)
{
- temp= c->second.m_Command;
- cmSystemTools::ConvertToWindowsSlashes(temp);
- temp = cmSystemTools::EscapeSpaces(temp.c_str());
+ temp=
+ cmSystemTools::ConvertToOutputPath(c->second.m_Command.c_str());
totalCommandStr += temp;
totalCommandStr += " ";
totalCommandStr += c->second.m_Arguments;
diff --git a/Source/cmNMakeMakefileGenerator.cxx b/Source/cmNMakeMakefileGenerator.cxx
index c90b883..aad3fbf 100644
--- a/Source/cmNMakeMakefileGenerator.cxx
+++ b/Source/cmNMakeMakefileGenerator.cxx
@@ -44,11 +44,11 @@ cmNMakeMakefileGenerator::~cmNMakeMakefileGenerator()
std::string cmNMakeMakefileGenerator::ShortPath(const char* path)
{
std::string ret = path;
- cmSystemTools::ConvertToWindowsSlashes(ret);
- // if there are no spaces in path, then just return path
+ // if there are no spaces in path, then just
+ // call ConvertToOutputPath
if(ret.find(' ') == std::string::npos)
{
- return ret;
+ return this->ConvertToOutputPath(path);
}
// if there are spaces then call GetShortPathName to get rid of them
@@ -61,8 +61,8 @@ std::string cmNMakeMakefileGenerator::ShortPath(const char* path)
else
{
// if GetShortPathName failed for some reason use
- // EscapeSpaces instead
- ret = cmSystemTools::EscapeSpaces(path);
+ // ConvertToOutputPath instead which will at least escape the spaces
+ ret = this->ConvertToOutputPath(path);
}
delete [] buffer;
return ret;
@@ -87,7 +87,7 @@ std::string cmNMakeMakefileGenerator::ShortPathCommand(const char* command)
{
c = removeIntDir.match(1) + removeIntDir.match(2);
}
- c = ShortPath(c.c_str());
+ c = this->ShortPath(c.c_str());
std::string ret = c;
std::string args = reg.match(2);
ret += args;
@@ -159,24 +159,24 @@ void cmNMakeMakefileGenerator::OutputMakeVariables(std::ostream& fout)
fout << replaceVars.c_str();
std::string ccompiler = m_Makefile->GetDefinition("CMAKE_C_COMPILER");
- cmSystemTools::ConvertToWindowsSlashes(ccompiler);
- fout << "CMAKE_C_COMPILER = " << cmSystemTools::EscapeSpaces(ccompiler.c_str()) << "\n";
+ fout << "CMAKE_C_COMPILER = "
+ << this->ConvertToOutputPath(ccompiler.c_str()) << "\n";
std::string cxxcompiler = m_Makefile->GetDefinition("CMAKE_CXX_COMPILER");
- cmSystemTools::ConvertToWindowsSlashes(cxxcompiler);
- fout << "CMAKE_CXX_COMPILER = " << cmSystemTools::EscapeSpaces(cxxcompiler.c_str()) << "\n";
+ fout << "CMAKE_CXX_COMPILER = "
+ << this->ConvertToOutputPath(cxxcompiler.c_str()) << "\n";
std::string linker = m_Makefile->GetDefinition("CMAKE_LINKER");
- cmSystemTools::ConvertToWindowsSlashes(linker);
- fout << "CMAKE_LINKER = " << cmSystemTools::EscapeSpaces(linker.c_str()) << "\n";
+ fout << "CMAKE_LINKER = " <<
+ this->ConvertToOutputPath(linker.c_str()) << "\n";
std::string lib_manager = m_Makefile->GetDefinition("CMAKE_LIBRARY_MANAGER");
- cmSystemTools::ConvertToWindowsSlashes(lib_manager);
- fout << "CMAKE_LIBRARY_MANAGER = " << cmSystemTools::EscapeSpaces(lib_manager.c_str()) << "\n";
+ fout << "CMAKE_LIBRARY_MANAGER = "
+ << this->ConvertToOutputPath(lib_manager.c_str()) << "\n";
std::string cmakecommand = m_Makefile->GetDefinition("CMAKE_COMMAND");
- cmSystemTools::ConvertToWindowsSlashes(cmakecommand);
- fout << "CMAKE_COMMAND = " << cmSystemTools::EscapeSpaces(cmakecommand.c_str()) << "\n";
+ fout << "CMAKE_COMMAND = "
+ << this->ConvertToOutputPath(cmakecommand.c_str()) << "\n";
fout << "CMAKE_CURRENT_SOURCE = "
<< ShortPath(m_Makefile->GetStartDirectory() )
@@ -194,17 +194,15 @@ void cmNMakeMakefileGenerator::OutputMakeVariables(std::ostream& fout)
fout << "INCLUDE_FLAGS = ";
std::vector<std::string>& includes = m_Makefile->GetIncludeDirectories();
std::vector<std::string>::iterator i;
- fout << "-I" << cmSystemTools::EscapeSpaces(m_Makefile->GetStartDirectory()) << " ";
+ fout << "-I" <<
+ this->ConvertToOutputPath(m_Makefile->GetStartDirectory()) << " ";
for(i = includes.begin(); i != includes.end(); ++i)
{
std::string include = *i;
// Don't output a -I for the standard include path "/usr/include".
// This can cause problems with certain standard library
// implementations because the wrong headers may be found first.
- if(include != "/usr/include")
- {
- fout << "-I" << cmSystemTools::EscapeSpaces(i->c_str()).c_str() << " ";
- }
+ fout << "-I" << this->ConvertToOutputPath(i->c_str()).c_str() << " ";
}
fout << m_Makefile->GetDefineFlags();
@@ -219,9 +217,7 @@ void cmNMakeMakefileGenerator::BuildInSubDirectory(std::ostream& fout,
{
if(target1)
{
- std::string dir = directory;
- cmSystemTools::ConvertToWindowsSlashes(dir);
- dir = cmSystemTools::EscapeSpaces(dir.c_str());
+ std::string dir = this->ConvertToOutputPath(directory);
fout << "\tif not exist \"" << dir << "\\$(NULL)\""
<< " "
<< "$(MAKE) $(MAKESILENT) rebuild_cache\n"
@@ -235,8 +231,7 @@ void cmNMakeMakefileGenerator::BuildInSubDirectory(std::ostream& fout,
fout << "\t$(MAKE) -$(MAKEFLAGS) $(MAKESILENT) " << target2 << "\n";
}
std::string currentDir = m_Makefile->GetCurrentOutputDirectory();
- cmSystemTools::ConvertToWindowsSlashes(currentDir);
- fout << "\tcd " << cmSystemTools::EscapeSpaces(currentDir.c_str()) << "\n\n";
+ fout << "\tcd " << this->ConvertToOutputPath(currentDir.c_str()) << "\n\n";
}
@@ -272,7 +267,7 @@ void cmNMakeMakefileGenerator::OutputMakeRule(std::ostream& fout,
fout << "\n";
replace = target;
m_Makefile->ExpandVariablesInString(replace);
- replace = cmSystemTools::EscapeSpaces(replace.c_str());
+ replace = this->ConvertToOutputPath(replace.c_str());
fout << replace.c_str() << ": ";
if(depends)
{
@@ -358,7 +353,7 @@ OutputBuildObjectFromSource(std::ostream& fout,
}
compileCommand += "$(INCLUDE_FLAGS) -c ";
compileCommand +=
- cmSystemTools::EscapeSpaces(source.GetFullPath().c_str());
+ this->ConvertToOutputPath(source.GetFullPath().c_str());
// Need to get the definition here because this value might have
// trailing space (since it is directly prepended to the filename)
@@ -375,7 +370,7 @@ OutputBuildObjectFromSource(std::ostream& fout,
compileCommand += objectFile;
compileCommand += "\" ";
compileCommand +=
- cmSystemTools::EscapeSpaces(source.GetFullPath().c_str());
+ this->ConvertToOutputPath(source.GetFullPath().c_str());
}
else if (ext == "def")
{
@@ -394,7 +389,7 @@ OutputBuildObjectFromSource(std::ostream& fout,
}
compileCommand += "$(INCLUDE_FLAGS) -c ";
compileCommand +=
- cmSystemTools::EscapeSpaces(source.GetFullPath().c_str());
+ this->ConvertToOutputPath(source.GetFullPath().c_str());
// Need to get the definition here because this value might have
// trailing space (since it is directly prepended to the filename)
@@ -409,7 +404,7 @@ OutputBuildObjectFromSource(std::ostream& fout,
this->OutputMakeRule(fout,
comment.c_str(),
objectFile.c_str(),
- cmSystemTools::EscapeSpaces(
+ this->ConvertToOutputPath(
source.GetFullPath().c_str()).c_str(),
compileCommand.c_str());
}
@@ -440,7 +435,7 @@ void cmNMakeMakefileGenerator::OutputSharedLibraryRule(std::ostream& fout,
command += " $(CMAKE_LINKER_FLAGS) " + linker_output_file_flag;
std::string dllpath = m_LibraryOutputPath + std::string(name) + m_SharedLibraryExtension;
- command += cmSystemTools::EscapeSpaces(dllpath.c_str());
+ command += this->ConvertToOutputPath(dllpath.c_str());
command += " $(" + this->CreateMakeVariable(name, "_SRC_OBJS") + ") ";
@@ -503,7 +498,7 @@ void cmNMakeMakefileGenerator::OutputStaticLibraryRule(std::ostream& fout,
std::string command = "$(CMAKE_LIBRARY_MANAGER) $(CMAKE_LIBRARY_MANAGER_FLAGS) @<<\n\t " + library_manager_output_file_flag;
std::string libpath = m_LibraryOutputPath + std::string(name) + m_StaticLibraryExtension;
- command += cmSystemTools::EscapeSpaces(libpath.c_str());
+ command += this->ConvertToOutputPath(libpath.c_str());
command += " $(";
command += this->CreateMakeVariable(name, "_SRC_OBJS") + ")";
@@ -546,7 +541,7 @@ void cmNMakeMakefileGenerator::OutputExecutableRule(std::ostream& fout,
m_Makefile->ExpandVariablesInString(output_executable_file_flag);
command += " " + output_executable_file_flag +
- cmSystemTools::EscapeSpaces(path.c_str());
+ this->ConvertToOutputPath(path.c_str());
command += " $(CMAKE_C_LINK_EXECUTABLE_FLAG) ";
if(t.GetType() == cmTarget::WIN32_EXECUTABLE)
@@ -605,7 +600,7 @@ void cmNMakeMakefileGenerator::OutputLinkLibraries(std::ostream& fout,
if(emitted.insert(libpath).second)
{
linkLibs += lib_path_opt;
- cmSystemTools::ConvertToWindowsSlashes(libpath);
+ this->ConvertToOutputPath(libpath.c_str());
linkLibs += libpath;
linkLibs += " ";
}
@@ -698,26 +693,21 @@ void cmNMakeMakefileGenerator::OutputBuildLibraryInDir(std::ostream& fout,
const char* fullpath)
{
- std::string currentDir = m_Makefile->GetCurrentOutputDirectory();
- cmSystemTools::ConvertToWindowsSlashes(currentDir);
- std::string wpath = cmSystemTools::EscapeSpaces(path);
- cmSystemTools::ConvertToWindowsSlashes(wpath);
- std::string wfullpath = cmSystemTools::EscapeSpaces(fullpath);
- cmSystemTools::ConvertToWindowsSlashes(wfullpath);
+ std::string currentDir =
+ this->ConvertToOutputPath(m_Makefile->GetCurrentOutputDirectory());
+ std::string wpath = this->ConvertToOutputPath(path);
+ std::string wfullpath = this->ConvertToOutputPath(fullpath);
fout << wfullpath
<< ":\n\tcd " << wpath << "\n"
<< "\t$(MAKE) -$(MAKEFLAGS) $(MAKESILENT) cmake.depends\n"
<< "\t$(MAKE) -$(MAKEFLAGS) $(MAKESILENT) cmake.check_depends\n"
<< "\t$(MAKE) -$(MAKEFLAGS) $(MAKESILENT) -f cmake.check_depends\n"
<< "\t$(MAKE) $(MAKESILENT) " << wfullpath
- << "\n\tcd " <<
- cmSystemTools::EscapeSpaces(currentDir.c_str()) << "\n";
+ << "\n\tcd " << currentDir << "\n";
}
-std::string cmNMakeMakefileGenerator::ConvertToNativePath(const char* s)
+std::string cmNMakeMakefileGenerator::ConvertToOutputPath(const char* s)
{
- std::string ret = s;
- cmSystemTools::ConvertToWindowsSlashes(ret);
- return ret;
+ return cmSystemTools::ConvertToOutputPath(s);
}
diff --git a/Source/cmNMakeMakefileGenerator.h b/Source/cmNMakeMakefileGenerator.h
index e8046b2..e6bbb8f 100644
--- a/Source/cmNMakeMakefileGenerator.h
+++ b/Source/cmNMakeMakefileGenerator.h
@@ -86,7 +86,7 @@ protected:
virtual bool SamePath(const char* path1, const char* path2);
void SetLibraryPathOption(const char* lib){ m_LibraryPathOption = lib;}
void SetLibraryLinkOption(const char* lib){ m_LibraryLinkOption = lib;}
- virtual std::string ConvertToNativePath(const char* s);
+ virtual std::string ConvertToOutputPath(const char* s);
private:
std::string m_LibraryPathOption;// option to specifiy a link path -LIBPATH
std::string m_LibraryLinkOption; // option to specify a library (like -l, empty for nmake)
diff --git a/Source/cmSystemTools.cxx b/Source/cmSystemTools.cxx
index 39386cb..200889a 100644
--- a/Source/cmSystemTools.cxx
+++ b/Source/cmSystemTools.cxx
@@ -303,62 +303,7 @@ void cmSystemTools::ExpandRegistryValues(std::string& source)
}
-std::string cmSystemTools::HandleNetworkPaths(const char* str)
-{
-#if defined(_WIN32) && !defined(__CYGWIN__)
- std::string result;
- // watch for network paths, MSVC can't seem to load //
- if (strlen(str) > 2 && str[0] == '/' && str[1] == '/')
- {
- result = "\\\\";
- result += (str + 2);
- }
- else
- {
- result += str;
- }
-#else
- std::string result = "";
-#endif
- return result;
-}
-std::string cmSystemTools::EscapeSpaces(const char* str)
-{
-#if defined(_WIN32) && !defined(__CYGWIN__)
- std::string result;
-
- // if there are spaces
- std::string temp = str;
- if (temp.find(" ") != std::string::npos)
- {
- // don't add quotes if they're already there
- if (temp.find("\"")==std::string::npos)
- {
- result = "\"";
- }
- result += cmSystemTools::HandleNetworkPaths(str);
- if (temp.find("\"")==std::string::npos)
- {
- result += "\"";
- }
- return result;
- }
- return cmSystemTools::HandleNetworkPaths(str);
-
-#else
- std::string result = "";
- for(const char* ch = str; *ch != '\0'; ++ch)
- {
- if(*ch == ' ')
- {
- result += '\\';
- }
- result += *ch;
- }
- return result;
-#endif
-}
std::string cmSystemTools::EscapeQuotes(const char* str)
{
@@ -449,7 +394,7 @@ std::string cmSystemTools::UpperCase(const std::string& s)
// convert windows slashes to unix slashes \ with /
-const char *cmSystemTools::ConvertToUnixSlashes(std::string& path)
+void cmSystemTools::ConvertToUnixSlashes(std::string& path)
{
std::string::size_type pos = 0;
while((pos = path.find('\\', pos)) != std::string::npos)
@@ -478,41 +423,113 @@ const char *cmSystemTools::ConvertToUnixSlashes(std::string& path)
{
path = path.substr(8);
}
-
- return path.c_str();
}
-// convert windows slashes to unix slashes
-const char *cmSystemTools::ConvertToWindowsSlashes(std::string& path)
+
+// change // to /, and escape any spaces in the path
+std::string cmSystemTools::ConvertToUnixOutputPath(const char* path)
{
+ std::string ret = path;
+
+ // remove //
std::string::size_type pos = 0;
- while((pos = path.find('/', pos)) != std::string::npos)
+ while((pos = ret.find("//", pos)) != std::string::npos)
{
- path[pos] = '\\';
- pos++;
+ ret.erase(pos, 1);
}
- // remove any trailing slash
- if(path[path.size()-1] == '\\')
+ // now escape spaces if there is a space in the path
+ if(ret.find(" ") != std::string::npos)
{
- path = path.substr(0, path.size()-1);
+ std::string result = "";
+ for(const char* ch = ret.c_str(); *ch != '\0'; ++ch)
+ {
+ if(*ch == ' ')
+ {
+ result += '\\';
+ }
+ result += *ch;
+ }
+ ret = result;
+ }
+ return ret;
+}
+
+
+
+std::string cmSystemTools::EscapeSpaces(const char* str)
+{
+#if defined(_WIN32) && !defined(__CYGWIN__)
+ std::string result;
+
+ // if there are spaces
+ std::string temp = str;
+ if (temp.find(" ") != std::string::npos &&
+ temp.find("\"")==std::string::npos)
+ {
+ result = "\"";
+ result += str;
+ result += "\"";
+ return result;
+ }
+ return str;
+#else
+ std::string result = "";
+ for(const char* ch = str; *ch != '\0'; ++ch)
+ {
+ if(*ch == ' ')
+ {
+ result += '\\';
+ }
+ result += *ch;
}
- return path.c_str();
+ return result;
+#endif
}
-// convert Unix slashes to Windows slashes and cleanup double slashes
-const char *cmSystemTools::ConvertToWindowsSlashesAndCleanUp(std::string& path)
+std::string cmSystemTools::ConvertToOutputPath(const char* path)
{
- cmSystemTools::ConvertToWindowsSlashes(path);
+#if defined(_WIN32) && !defined(__CYGWIN__)
+ return cmSystemTools::ConvertToWindowsOutputPath(path);
+#else
+ return cmSystemTools::ConvertToUnixOutputPath(path);
+#endif
+}
+
+
+// remove double slashes not at the start
+std::string cmSystemTools::ConvertToWindowsOutputPath(const char* path)
+{
+ std::string ret = path;
std::string::size_type pos = 0;
- if(path.size() > 1)
+ // first convert all of the slashes
+ while((pos = ret.find('/', pos)) != std::string::npos)
+ {
+ ret[pos] = '\\';
+ pos++;
+ }
+ // check for really small paths
+ if(ret.size() < 2)
+ {
+ return ret;
+ }
+ // now clean up a bit and remove double slashes
+ // Only if it is not the first position in the path which is a network
+ // path on windows
+ pos = 1; // start at position 1
+ while((pos = ret.find("\\\\", pos)) != std::string::npos)
+ {
+ ret.erase(pos, 1);
+ }
+ // now double quote the path if it has spaces in it
+ // and is not already double quoted
+ if(ret.find(" ") != std::string::npos
+ && ret[0] != '\"')
{
- pos = 1;
- while((pos = path.find("\\\\", pos)) != std::string::npos)
- {
- path.erase(pos, 1);
- }
+ std::string result;
+ result = "\"" + ret + "\"";
+ ret = result;
}
- return path.c_str();
+ return ret;
}
bool cmSystemTools::ParseFunction(std::ifstream& fin,
diff --git a/Source/cmSystemTools.h b/Source/cmSystemTools.h
index ed48e85..a48ea1b 100644
--- a/Source/cmSystemTools.h
+++ b/Source/cmSystemTools.h
@@ -49,23 +49,6 @@ public:
static void ExpandRegistryValues(std::string& source);
/**
- * make sure on windows that paths with // are converted to \\
- */
- static std::string HandleNetworkPaths(const char*);
-
- /**
- * Return a string equivalent to the input string, but with all " " replaced
- * with "\ " to escape the spaces.
- */
- static std::string EscapeSpaces(const char*);
-
- /**
- * Return a string equivalent to the input string, but with all " replaced
- * with \" to escape the quote
- */
- static std::string EscapeQuotes(const char*);
-
- /**
* Return a capitalized string (i.e the first letter is uppercased, all other
* are lowercased).
*/
@@ -84,19 +67,23 @@ public:
/**
* Replace Windows file system slashes with Unix-style slashes.
*/
- static const char *ConvertToUnixSlashes(std::string& path);
-
+ static void ConvertToUnixSlashes(std::string& path);
+
/**
- * Replace Unix file system slashes with Windows-style slashes
+ * Platform independent escape spaces, unix uses backslash,
+ * windows double quotes the string.
*/
- static const char *ConvertToWindowsSlashes(std::string& path);
+ static std::string EscapeSpaces(const char* str);
+
+ ///! Escape quotes in a string.
+ static std::string EscapeQuotes(const char* str);
/**
- * Replace Unix file system slashes with Windows-style slashes and
- * remove any duplicate \\ slashes to clean the path.
+ * For windows this calles ConvertToWindowsOutputPath and for unix
+ * it calls ConvertToUnixOutputPath
*/
- static const char *ConvertToWindowsSlashesAndCleanUp(std::string& path);
-
+ static std::string ConvertToOutputPath(const char*);
+
///! Return true if a file exists in the current directory.
static bool FileExists(const char* filename);
@@ -265,7 +252,23 @@ public:
static void DisableMessages() { s_DisableMessages = true; }
static void DisableRunCommandOutput() {s_DisableRunCommandOutput = true; }
static void EnableRunCommandOutput() {s_DisableRunCommandOutput = false; }
+protected:
+ // these two functions can be called from ConvertToOutputPath
+ /**
+ * Convert the path to a string that can be used in a unix makefile.
+ * double slashes are removed, and spaces are escaped.
+ */
+ static std::string ConvertToUnixOutputPath(const char*);
+ /**
+ * Convert the path to string that can be used in a windows project or
+ * makefile. Double slashes are removed if they are not at the start of
+ * the string, the slashes are converted to windows style backslashes, and
+ * if there are spaces in the string it is double quoted.
+ */
+ static std::string ConvertToWindowsOutputPath(const char*);
+
+
private:
static bool s_ErrorOccured;
static bool s_DisableMessages;
diff --git a/Source/cmUnixMakefileGenerator.cxx b/Source/cmUnixMakefileGenerator.cxx
index 0a5aa8b..4c57f20 100644
--- a/Source/cmUnixMakefileGenerator.cxx
+++ b/Source/cmUnixMakefileGenerator.cxx
@@ -216,13 +216,12 @@ void cmUnixMakefileGenerator::OutputMakefile(const char* file)
for(std::vector<std::string>::const_iterator i = lfiles.begin();
i != lfiles.end(); ++i)
{
- fout << " " << this->ConvertToNativePath(cmSystemTools::EscapeSpaces(i->c_str()).c_str());
+ fout << " " << this->ConvertToOutputPath(i->c_str());
}
// Add the cache to the list
std::string cacheFile = m_Makefile->GetHomeOutputDirectory();
cacheFile += "/CMakeCache.txt";
- fout << " " <<
- this->ConvertToNativePath(cmSystemTools::EscapeSpaces(cacheFile.c_str()).c_str());
+ fout << " " << this->ConvertToOutputPath(cacheFile.c_str());
fout << "\n\n\n";
this->OutputMakeVariables(fout);
// Set up the default target as the VERY first target, so that make with no arguments will run it
@@ -314,21 +313,21 @@ void cmUnixMakefileGenerator::OutputTargetRules(std::ostream& fout)
{
path = path + l->first + m_StaticLibraryExtension;
fout << " \\\n"
- << this->ConvertToNativePath(cmSystemTools::EscapeSpaces(path.c_str()).c_str());
+ << this->ConvertToOutputPath(path.c_str());
}
else if(l->second.GetType() == cmTarget::SHARED_LIBRARY)
{
path = path + l->first +
m_Makefile->GetDefinition("CMAKE_SHLIB_SUFFIX");
fout << " \\\n"
- << this->ConvertToNativePath(cmSystemTools::EscapeSpaces(path.c_str()).c_str());
+ << this->ConvertToOutputPath(path.c_str());
}
else if(l->second.GetType() == cmTarget::MODULE_LIBRARY)
{
path = path + l->first +
m_Makefile->GetDefinition("CMAKE_MODULE_SUFFIX");
fout << " \\\n"
- << this->ConvertToNativePath(cmSystemTools::EscapeSpaces(path.c_str()).c_str());
+ << this->ConvertToOutputPath(path.c_str());
}
}
}
@@ -342,7 +341,7 @@ void cmUnixMakefileGenerator::OutputTargetRules(std::ostream& fout)
{
std::string path = m_ExecutableOutputPath + l->first +
m_ExecutableExtension;
- fout << " \\\n" << this->ConvertToNativePath(cmSystemTools::EscapeSpaces(path.c_str()).c_str());
+ fout << " \\\n" << this->ConvertToOutputPath(path.c_str());
}
}
// list utilities last
@@ -372,7 +371,7 @@ void cmUnixMakefileGenerator::OutputTargetRules(std::ostream& fout)
std::string outExt(this->GetOutputExtension(i->GetSourceExtension().c_str()));
if(outExt.size())
{
- fout << "\\\n" << this->ConvertToNativePath(i->GetSourceName().c_str())
+ fout << "\\\n" << this->ConvertToOutputPath(i->GetSourceName().c_str())
<< outExt.c_str() << " ";
}
}
@@ -387,7 +386,7 @@ void cmUnixMakefileGenerator::OutputTargetRules(std::ostream& fout)
std::string outExt(this->GetOutputExtension(i->GetSourceExtension().c_str()));
if(outExt.size())
{
- fout << "\\\n\"" << this->ConvertToNativePath(i->GetSourceName().c_str())
+ fout << "\\\n\"" << this->ConvertToOutputPath(i->GetSourceName().c_str())
<< outExt.c_str() << "\" ";
}
}
@@ -454,7 +453,7 @@ void cmUnixMakefileGenerator::OutputLinkLibraries(std::ostream& fout,
for(std::vector<std::string>::iterator libDir = libdirs.begin();
libDir != libdirs.end(); ++libDir)
{
- std::string libpath = cmSystemTools::EscapeSpaces(libDir->c_str());
+ std::string libpath = this->ConvertToOutputPath(libDir->c_str());
if(emitted.insert(libpath).second)
{
std::string::size_type pos = libDir->find("-L");
@@ -492,7 +491,7 @@ void cmUnixMakefileGenerator::OutputLinkLibraries(std::ostream& fout,
std::string dir, file;
cmSystemTools::SplitProgramPath(lib->first.c_str(),
dir, file);
- std::string libpath = cmSystemTools::EscapeSpaces(dir.c_str());
+ std::string libpath = this->ConvertToOutputPath(dir.c_str());
if(emitted.insert(libpath).second)
{
linkLibs += "-L";
@@ -586,8 +585,7 @@ std::string cmUnixMakefileGenerator::CreateTargetRules(const cmTarget &target,
{
initNext = true;
}
- std::string command = cmSystemTools::EscapeSpaces(cc.GetCommand().c_str());
- command = this->ConvertToNativePath(command.c_str());
+ std::string command = this->ConvertToOutputPath(cc.GetCommand().c_str());
customRuleCode += command + " " + cc.GetArguments();
}
}
@@ -938,8 +936,8 @@ void cmUnixMakefileGenerator::OutputBuildLibraryInDir(std::ostream& fout,
{
makeTarget = fullpath;
}
- fout << cmSystemTools::EscapeSpaces(fullpath)
- << ":\n\tcd " << cmSystemTools::EscapeSpaces(path)
+ fout << this->ConvertToOutputPath(fullpath)
+ << ":\n\tcd " << this->ConvertToOutputPath(path)
<< "; $(MAKE) -$(MAKEFLAGS) $(MAKESILENT) cmake.depends"
<< "; $(MAKE) -$(MAKEFLAGS) $(MAKESILENT) cmake.check_depends"
<< "; $(MAKE) -$(MAKEFLAGS) $(MAKESILENT) -f cmake.check_depends"
@@ -957,8 +955,8 @@ void cmUnixMakefileGenerator::OutputBuildExecutableInDir(std::ostream& fout,
{
makeTarget = fullpath;
}
- fout << cmSystemTools::EscapeSpaces(fullpath)
- << ":\n\tcd " << cmSystemTools::EscapeSpaces(path)
+ fout << this->ConvertToOutputPath(fullpath)
+ << ":\n\tcd " << this->ConvertToOutputPath(path)
<< "; $(MAKE) -$(MAKEFLAGS) $(MAKESILENT) cmake.depends"
<< "; $(MAKE) -$(MAKEFLAGS) $(MAKESILENT) cmake.check_depends"
<< "; $(MAKE) -$(MAKEFLAGS) $(MAKESILENT) -f cmake.check_depends"
@@ -1019,8 +1017,7 @@ void cmUnixMakefileGenerator::OutputLibDepend(std::ostream& fout,
{
libpath += m_StaticLibraryExtension;
}
- fout << this->ConvertToNativePath(cmSystemTools::EscapeSpaces(libpath.c_str()).c_str())
- << " ";
+ fout << this->ConvertToOutputPath(libpath.c_str()) << " ";
}
}
@@ -1066,8 +1063,7 @@ void cmUnixMakefileGenerator::OutputExeDepend(std::ostream& fout,
}
exepath += replaceVars;
}
- fout << this->ConvertToNativePath(cmSystemTools::EscapeSpaces(exepath.c_str()).c_str())
- << " ";
+ fout << this->ConvertToOutputPath(exepath.c_str()) << " ";
}
}
@@ -1100,7 +1096,7 @@ void cmUnixMakefileGenerator::BuildInSubDirectory(std::ostream& fout,
const char* target1,
const char* target2)
{
- std::string directory = cmSystemTools::EscapeSpaces(dir);
+ std::string directory = this->ConvertToOutputPath(dir);
if(target1)
{
fout << "\t@if test ! -d " << directory
@@ -1241,8 +1237,7 @@ bool cmUnixMakefileGenerator::OutputObjectDepends(std::ostream& fout)
dep != source->GetDepends().end(); ++dep)
{
fout << " \\\n"
- << this->ConvertToNativePath(cmSystemTools::EscapeSpaces(
- dep->c_str()).c_str());
+ << this->ConvertToOutputPath(dep->c_str());
ret = true;
}
fout << "\n\n";
@@ -1290,8 +1285,7 @@ void cmUnixMakefileGenerator::OutputCheckDepends(std::ostream& fout)
dep != source->GetDepends().end(); ++dep)
{
std::string dependfile =
- this->ConvertToNativePath(cmSystemTools::EscapeSpaces(
- dep->c_str()).c_str());
+ this->ConvertToOutputPath(dep->c_str());
if(emitted.insert(dependfile).second)
{
fout << " \\\n" << dependfile ;
@@ -1371,9 +1365,8 @@ void cmUnixMakefileGenerator::OutputCustomRules(std::ostream& fout)
{
// escape spaces and convert to native slashes path for
// the command
- std::string command =
- cmSystemTools::EscapeSpaces(c->second.m_Command.c_str());
- command = this->ConvertToNativePath(command.c_str());
+ std::string command =
+ this->ConvertToOutputPath(c->second.m_Command.c_str());
command += " ";
// now add the arguments
command += c->second.m_Arguments;
@@ -1388,7 +1381,7 @@ void cmUnixMakefileGenerator::OutputCustomRules(std::ostream& fout)
commandFiles.m_Depends.begin();
d != commandFiles.m_Depends.end(); ++d)
{
- std::string dep = cmSystemTools::EscapeSpaces(d->c_str());
+ std::string dep = this->ConvertToOutputPath(d->c_str());
depends += " ";
depends += dep;
}
@@ -1404,7 +1397,7 @@ void cmUnixMakefileGenerator::OutputCustomRules(std::ostream& fout)
commandFiles.m_Outputs.begin();
output != commandFiles.m_Outputs.end(); ++output)
{
- std::string src = cmSystemTools::EscapeSpaces(source.c_str());
+ std::string src = this->ConvertToOutputPath(source.c_str());
std::string depends;
depends += src;
// Collect out all the dependencies for this rule.
@@ -1412,7 +1405,7 @@ void cmUnixMakefileGenerator::OutputCustomRules(std::ostream& fout)
commandFiles.m_Depends.begin();
d != commandFiles.m_Depends.end(); ++d)
{
- std::string dep = cmSystemTools::EscapeSpaces(d->c_str());
+ std::string dep = this->ConvertToOutputPath(d->c_str());
depends += " ";
depends += dep;
}
@@ -1506,19 +1499,19 @@ void cmUnixMakefileGenerator::OutputMakeVariables(std::ostream& fout)
m_Makefile->ExpandVariablesInString(replaceVars);
fout << replaceVars.c_str();
fout << "CMAKE_CURRENT_SOURCE = " <<
- cmSystemTools::EscapeSpaces(m_Makefile->GetStartDirectory()) << "\n";
+ this->ConvertToOutputPath(m_Makefile->GetStartDirectory()) << "\n";
fout << "CMAKE_CURRENT_BINARY = " <<
- cmSystemTools::EscapeSpaces(m_Makefile->GetStartOutputDirectory()) << "\n";
+ this->ConvertToOutputPath(m_Makefile->GetStartOutputDirectory()) << "\n";
fout << "CMAKE_SOURCE_DIR = " <<
- cmSystemTools::EscapeSpaces(m_Makefile->GetHomeDirectory()) << "\n";
+ this->ConvertToOutputPath(m_Makefile->GetHomeDirectory()) << "\n";
fout << "CMAKE_BINARY_DIR = " <<
- cmSystemTools::EscapeSpaces(m_Makefile->GetHomeOutputDirectory()) << "\n";
+ this->ConvertToOutputPath(m_Makefile->GetHomeOutputDirectory()) << "\n";
// Output Include paths
fout << "INCLUDE_FLAGS = ";
std::vector<std::string>& includes = m_Makefile->GetIncludeDirectories();
std::vector<std::string>::iterator i;
fout << "-I" <<
- cmSystemTools::EscapeSpaces(m_Makefile->GetStartDirectory()) << " ";
+ this->ConvertToOutputPath(m_Makefile->GetStartDirectory()) << " ";
for(i = includes.begin(); i != includes.end(); ++i)
{
std::string include = *i;
@@ -1527,7 +1520,7 @@ void cmUnixMakefileGenerator::OutputMakeVariables(std::ostream& fout)
// implementations because the wrong headers may be found first.
if(include != "/usr/include")
{
- fout << "-I" << cmSystemTools::EscapeSpaces(i->c_str()).c_str() << " ";
+ fout << "-I" << this->ConvertToOutputPath(i->c_str()) << " ";
}
}
fout << m_Makefile->GetDefineFlags();
@@ -1833,7 +1826,7 @@ OutputBuildObjectFromSource(std::ostream& fout,
}
compileCommand += "$(INCLUDE_FLAGS) -c ";
compileCommand +=
- cmSystemTools::EscapeSpaces(source.GetFullPath().c_str());
+ this->ConvertToOutputPath(source.GetFullPath().c_str());
compileCommand += " -o ";
compileCommand += objectFile;
}
@@ -1847,15 +1840,15 @@ OutputBuildObjectFromSource(std::ostream& fout,
}
compileCommand += "$(INCLUDE_FLAGS) -c ";
compileCommand +=
- cmSystemTools::EscapeSpaces(source.GetFullPath().c_str());
+ this->ConvertToOutputPath(source.GetFullPath().c_str());
compileCommand += " -o ";
compileCommand += objectFile;
}
this->OutputMakeRule(fout,
comment.c_str(),
objectFile.c_str(),
- cmSystemTools::EscapeSpaces(source.GetFullPath().
- c_str()).c_str(),
+ this->ConvertToOutputPath(source.GetFullPath().
+ c_str()).c_str(),
compileCommand.c_str());
}
@@ -2057,7 +2050,7 @@ void cmUnixMakefileGenerator::ComputeSystemInfo()
// currently we run configure shell script here to determine the info
std::string output;
std::string cmd = "cd ";
- cmd += cmSystemTools::EscapeSpaces(m_Makefile->GetHomeOutputDirectory());
+ cmd += this->ConvertToOutputPath(m_Makefile->GetHomeOutputDirectory());
cmd += "; ";
const char* root
= m_Makefile->GetDefinition("CMAKE_ROOT");
diff --git a/Source/cmUnixMakefileGenerator.h b/Source/cmUnixMakefileGenerator.h
index 5a73de8..68d3cda 100644
--- a/Source/cmUnixMakefileGenerator.h
+++ b/Source/cmUnixMakefileGenerator.h
@@ -153,7 +153,10 @@ protected:
void SetStaticLibraryExtension(const char* e) {m_StaticLibraryExtension = e;}
void SetSharedLibraryExtension(const char* e) {m_SharedLibraryExtension = e;}
void SetLibraryPrefix(const char* e) { m_LibraryPrefix = e;}
- virtual std::string ConvertToNativePath(const char* s) { return s; }
+ // convert a path to an output path for unix this will call
+ // ConvertToUnixOutputPath
+ virtual std::string ConvertToOutputPath(const char* s)
+ { return cmSystemTools::ConvertToOutputPath(s); }
std::string CreateTargetRules(const cmTarget &target,
const char* targetName);
virtual std::string CreateMakeVariable(const char* s, const char* s2)
diff --git a/Source/cmaketest.cxx b/Source/cmaketest.cxx
index d1372d8..28f9b94 100644
--- a/Source/cmaketest.cxx
+++ b/Source/cmaketest.cxx
@@ -116,10 +116,7 @@ int main (int argc, char *argv[])
{
std::cerr << "Error: cmaketest does not have a valid MAKEPROGRAM\n";
}
- makeCommand = cmSystemTools::EscapeSpaces(makeCommand.c_str());
-#if defined(_WIN32) && !defined(__CYGWIN__)
- cmSystemTools::ConvertToWindowsSlashes(makeCommand);
-#endif
+ makeCommand = cmSystemTools::ConvertToOutputPath(makeCommand.c_str());
std::string lowerCaseCommand = makeCommand;
cmSystemTools::LowerCase(lowerCaseCommand);
@@ -246,10 +243,7 @@ int main (int argc, char *argv[])
cmSystemTools::ChangeDirectory(cwd.c_str());
return 1;
}
- fullPath = cmSystemTools::EscapeSpaces(fullPath.c_str());
-#if defined(_WIN32) && !defined(__CYGWIN__)
- cmSystemTools::ConvertToWindowsSlashes(fullPath);
-#endif
+ fullPath = cmSystemTools::ConvertToOutputPath(fullPath.c_str());
std::cout << "Running test executable: " << fullPath.c_str() << "\n";
int ret = 0;
if (!cmSystemTools::RunCommand(fullPath.c_str(), output, ret, true))