ENH: fix for spaces in paths on unix
This commit is contained in:
parent
8c3400dc6b
commit
b8d2413156
@ -75,7 +75,14 @@ void cmAddTestCommand::FinalPass()
|
|||||||
++it;
|
++it;
|
||||||
for (; it != m_Args.end(); ++it)
|
for (; it != m_Args.end(); ++it)
|
||||||
{
|
{
|
||||||
fout << " " << (*it).c_str();
|
if(it->find(" ") != std::string::npos)
|
||||||
|
{
|
||||||
|
fout << " \"" << *it << "\"";
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
fout << " " << *it;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
fout << ")" << std::endl;
|
fout << ")" << std::endl;
|
||||||
fout.close();
|
fout.close();
|
||||||
|
@ -441,13 +441,16 @@ std::string cmSystemTools::ConvertToUnixOutputPath(const char* path)
|
|||||||
if(ret.find(" ") != std::string::npos)
|
if(ret.find(" ") != std::string::npos)
|
||||||
{
|
{
|
||||||
std::string result = "";
|
std::string result = "";
|
||||||
|
char lastch = 1;
|
||||||
for(const char* ch = ret.c_str(); *ch != '\0'; ++ch)
|
for(const char* ch = ret.c_str(); *ch != '\0'; ++ch)
|
||||||
{
|
{
|
||||||
if(*ch == ' ')
|
// if it is already escaped then don't try to escape it again
|
||||||
|
if(*ch == ' ' && lastch != '\\')
|
||||||
{
|
{
|
||||||
result += '\\';
|
result += '\\';
|
||||||
}
|
}
|
||||||
result += *ch;
|
result += *ch;
|
||||||
|
lastch = *ch;
|
||||||
}
|
}
|
||||||
ret = result;
|
ret = result;
|
||||||
}
|
}
|
||||||
|
@ -607,7 +607,9 @@ void cmUnixMakefileGenerator::OutputSharedLibraryRule(std::ostream& fout,
|
|||||||
std::string command2 = "$(CMAKE_CXX_COMPILER) $(CMAKE_SHLIB_LINK_FLAGS) "
|
std::string command2 = "$(CMAKE_CXX_COMPILER) $(CMAKE_SHLIB_LINK_FLAGS) "
|
||||||
"$(CMAKE_SHLIB_BUILD_FLAGS) $(CMAKE_CXX_FLAGS) -o \\\n";
|
"$(CMAKE_SHLIB_BUILD_FLAGS) $(CMAKE_CXX_FLAGS) -o \\\n";
|
||||||
command2 += "\t ";
|
command2 += "\t ";
|
||||||
command2 += m_LibraryOutputPath + "lib" + std::string(name) + "$(SHLIB_SUFFIX) \\\n";
|
std::string libName = m_LibraryOutputPath + "lib" + std::string(name) + "$(SHLIB_SUFFIX)";
|
||||||
|
libName = this->ConvertToOutputPath(libName.c_str());
|
||||||
|
command2 += libName + " \\\n";
|
||||||
command2 += "\t $(" + this->CreateMakeVariable(name, "_SRC_OBJS") + ") ";
|
command2 += "\t $(" + this->CreateMakeVariable(name, "_SRC_OBJS") + ") ";
|
||||||
std::strstream linklibs;
|
std::strstream linklibs;
|
||||||
this->OutputLinkLibraries(linklibs, name, t);
|
this->OutputLinkLibraries(linklibs, name, t);
|
||||||
@ -640,7 +642,9 @@ void cmUnixMakefileGenerator::OutputModuleLibraryRule(std::ostream& fout,
|
|||||||
std::string command2 = "$(CMAKE_CXX_COMPILER) $(CMAKE_MODULE_LINK_FLAGS) "
|
std::string command2 = "$(CMAKE_CXX_COMPILER) $(CMAKE_MODULE_LINK_FLAGS) "
|
||||||
"$(CMAKE_MODULE_BUILD_FLAGS) $(CMAKE_CXX_FLAGS) -o \\\n";
|
"$(CMAKE_MODULE_BUILD_FLAGS) $(CMAKE_CXX_FLAGS) -o \\\n";
|
||||||
command2 += "\t ";
|
command2 += "\t ";
|
||||||
command2 += m_LibraryOutputPath + "lib" + std::string(name) + "$(MODULE_SUFFIX) \\\n";
|
std::string libName = m_LibraryOutputPath + "lib" + std::string(name) + "$(MODULE_SUFFIX)";
|
||||||
|
libName = this->ConvertToOutputPath(libName.c_str());
|
||||||
|
command2 += libName + " \\\n";
|
||||||
command2 += "\t $(" + this->CreateMakeVariable(name, "_SRC_OBJS") + ") ";
|
command2 += "\t $(" + this->CreateMakeVariable(name, "_SRC_OBJS") + ") ";
|
||||||
std::strstream linklibs;
|
std::strstream linklibs;
|
||||||
this->OutputLinkLibraries(linklibs, std::string(name).c_str(), t);
|
this->OutputLinkLibraries(linklibs, std::string(name).c_str(), t);
|
||||||
@ -667,18 +671,15 @@ void cmUnixMakefileGenerator::OutputStaticLibraryRule(std::ostream& fout,
|
|||||||
const cmTarget &t)
|
const cmTarget &t)
|
||||||
{
|
{
|
||||||
std::string target = m_LibraryOutputPath + "lib" + std::string(name) + ".a";
|
std::string target = m_LibraryOutputPath + "lib" + std::string(name) + ".a";
|
||||||
|
target = this->ConvertToOutputPath(target.c_str());
|
||||||
std::string depend = "$(";
|
std::string depend = "$(";
|
||||||
depend += this->CreateMakeVariable(name, "_SRC_OBJS") + ")";
|
depend += this->CreateMakeVariable(name, "_SRC_OBJS") + ")";
|
||||||
std::string command = "$(CMAKE_AR) $(CMAKE_AR_ARGS) ";
|
std::string command = "$(CMAKE_AR) $(CMAKE_AR_ARGS) ";
|
||||||
command += m_LibraryOutputPath;
|
command += target;
|
||||||
command += "lib";
|
command += " $(";
|
||||||
command += name;
|
|
||||||
command += ".a $(";
|
|
||||||
command += this->CreateMakeVariable(name, "_SRC_OBJS") + ")";
|
command += this->CreateMakeVariable(name, "_SRC_OBJS") + ")";
|
||||||
std::string command2 = "$(CMAKE_RANLIB) ";
|
std::string command2 = "$(CMAKE_RANLIB) ";
|
||||||
command2 += m_LibraryOutputPath;
|
command2 += target;
|
||||||
command2 += "lib";
|
|
||||||
command2 += std::string(name) + ".a";
|
|
||||||
std::string comment = "rule to build static library: ";
|
std::string comment = "rule to build static library: ";
|
||||||
comment += name;
|
comment += name;
|
||||||
std::string customCommands = this->CreateTargetRules(t, name);
|
std::string customCommands = this->CreateTargetRules(t, name);
|
||||||
@ -711,7 +712,8 @@ void cmUnixMakefileGenerator::OutputExecutableRule(std::ostream& fout,
|
|||||||
this->OutputLinkLibraries(linklibs, 0, t);
|
this->OutputLinkLibraries(linklibs, 0, t);
|
||||||
linklibs << std::ends;
|
linklibs << std::ends;
|
||||||
command += linklibs.str();
|
command += linklibs.str();
|
||||||
command += " -o " + m_ExecutableOutputPath + name;
|
std::string outputFile = m_ExecutableOutputPath + name;
|
||||||
|
command += " -o " + this->ConvertToOutputPath(outputFile.c_str());
|
||||||
std::string comment = "rule to build executable: ";
|
std::string comment = "rule to build executable: ";
|
||||||
comment += name;
|
comment += name;
|
||||||
|
|
||||||
@ -1812,6 +1814,7 @@ OutputBuildObjectFromSource(std::ostream& fout,
|
|||||||
|
|
||||||
std::string comment = "Build ";
|
std::string comment = "Build ";
|
||||||
std::string objectFile = std::string(shortName) + m_ObjectFileExtension;
|
std::string objectFile = std::string(shortName) + m_ObjectFileExtension;
|
||||||
|
objectFile = this->ConvertToOutputPath(objectFile.c_str());
|
||||||
comment += objectFile + " From ";
|
comment += objectFile + " From ";
|
||||||
comment += source.GetFullPath();
|
comment += source.GetFullPath();
|
||||||
std::string compileCommand;
|
std::string compileCommand;
|
||||||
@ -1954,7 +1957,7 @@ void cmUnixMakefileGenerator::OutputMakeRule(std::ostream& fout,
|
|||||||
fout << "\n";
|
fout << "\n";
|
||||||
replace = target;
|
replace = target;
|
||||||
m_Makefile->ExpandVariablesInString(replace);
|
m_Makefile->ExpandVariablesInString(replace);
|
||||||
fout << replace.c_str() << ": ";
|
fout << this->ConvertToOutputPath(replace.c_str()) << ": ";
|
||||||
if(depends)
|
if(depends)
|
||||||
{
|
{
|
||||||
replace = depends;
|
replace = depends;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user