summaryrefslogtreecommitdiffstats
path: root/Source/cmLocalUnixMakefileGenerator2.cxx
diff options
context:
space:
mode:
authorBrad King <brad.king@kitware.com>2005-02-25 14:06:18 (GMT)
committerBrad King <brad.king@kitware.com>2005-02-25 14:06:18 (GMT)
commit03e2878db895efacc199253fabafb8ffa1c2150d (patch)
treeaf515eccdc3de934b5b3ccfad0fd088783e709d9 /Source/cmLocalUnixMakefileGenerator2.cxx
parent5bbf471f2323c8692027ca4e8572a1ec9d898fc7 (diff)
downloadCMake-03e2878db895efacc199253fabafb8ffa1c2150d.zip
CMake-03e2878db895efacc199253fabafb8ffa1c2150d.tar.gz
CMake-03e2878db895efacc199253fabafb8ffa1c2150d.tar.bz2
ENH: Added ConvertToQuotedOutputPath method and used it to properly generate external object references with spaces in the path.
Diffstat (limited to 'Source/cmLocalUnixMakefileGenerator2.cxx')
-rw-r--r--Source/cmLocalUnixMakefileGenerator2.cxx53
1 files changed, 50 insertions, 3 deletions
diff --git a/Source/cmLocalUnixMakefileGenerator2.cxx b/Source/cmLocalUnixMakefileGenerator2.cxx
index 996e42e..fea3d75 100644
--- a/Source/cmLocalUnixMakefileGenerator2.cxx
+++ b/Source/cmLocalUnixMakefileGenerator2.cxx
@@ -1995,10 +1995,10 @@ cmLocalUnixMakefileGenerator2
for(std::vector<std::string>::const_iterator i = objects.begin();
i != objects.end(); ++i)
{
- // TODO: Make sure we don't escape spaces and quote.
+ std::string object = this->ConvertToRelativePath(i->c_str());
ruleFileStream
<< " \\\n"
- << "\"" << this->ConvertToRelativeOutputPath(i->c_str()) << "\"";
+ << this->ConvertToQuotedOutputPath(object.c_str());
}
ruleFileStream
<< "\n";
@@ -2008,14 +2008,16 @@ cmLocalUnixMakefileGenerator2
variableNameExternal = this->CreateMakeVariable(target.GetName(),
"_EXTERNAL_OBJECTS");
ruleFileStream
+ << "\n"
<< "# External object files for target " << target.GetName() << "\n"
<< variableNameExternal.c_str() << " =";
for(std::vector<std::string>::const_iterator i = external_objects.begin();
i != external_objects.end(); ++i)
{
+ std::string object = this->ConvertToRelativePath(i->c_str());
ruleFileStream
<< " \\\n"
- << "\"" << this->ConvertToRelativeOutputPath(i->c_str()) << "\"";
+ << this->ConvertToQuotedOutputPath(object.c_str());
}
ruleFileStream
<< "\n"
@@ -2318,6 +2320,51 @@ cmLocalUnixMakefileGenerator2::ConvertToRelativeOutputPath(const char* p)
}
//----------------------------------------------------------------------------
+std::string
+cmLocalUnixMakefileGenerator2::ConvertToQuotedOutputPath(const char* p)
+{
+ // Split the path into its components.
+ std::vector<std::string> components;
+ cmSystemTools::SplitPath(p, components);
+
+ // Return an empty path if there are no components.
+ if(components.empty())
+ {
+ return "\"\"";
+ }
+
+ // Begin the quoted result with the root component.
+ std::string result = "\"";
+ result += components[0];
+
+ // Now add the rest of the components separated by the proper slash
+ // direction for this platform.
+ bool first = true;
+ for(unsigned int i=1; i < components.size(); ++i)
+ {
+ // Only the last component can be empty to avoid double slashes.
+ if(components[i].length() > 0 || (i == (components.size()-1)))
+ {
+ if(!first)
+ {
+#if defined(_WIN32) && !defined(__CYGWIN__)
+ result += "\\";
+#else
+ result += "/";
+#endif
+ }
+ result += components[i];
+ first = false;
+ }
+ }
+
+ // Close the quoted result.
+ result += "\"";
+
+ return result;
+}
+
+//----------------------------------------------------------------------------
void cmLocalUnixMakefileGenerator2::ConfigureOutputPaths()
{
// Format the library and executable output paths.