diff options
author | Brad King <brad.king@kitware.com> | 2005-02-25 14:06:18 (GMT) |
---|---|---|
committer | Brad King <brad.king@kitware.com> | 2005-02-25 14:06:18 (GMT) |
commit | 03e2878db895efacc199253fabafb8ffa1c2150d (patch) | |
tree | af515eccdc3de934b5b3ccfad0fd088783e709d9 /Source | |
parent | 5bbf471f2323c8692027ca4e8572a1ec9d898fc7 (diff) | |
download | CMake-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')
-rw-r--r-- | Source/cmLocalUnixMakefileGenerator2.cxx | 53 | ||||
-rw-r--r-- | Source/cmLocalUnixMakefileGenerator2.h | 1 |
2 files changed, 51 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. diff --git a/Source/cmLocalUnixMakefileGenerator2.h b/Source/cmLocalUnixMakefileGenerator2.h index 90997f1..893dc7f 100644 --- a/Source/cmLocalUnixMakefileGenerator2.h +++ b/Source/cmLocalUnixMakefileGenerator2.h @@ -199,6 +199,7 @@ protected: const char* GetSourceFileLanguage(const cmSourceFile& source); std::string ConvertToFullPath(const std::string& localPath); std::string ConvertToRelativeOutputPath(const char* p); + std::string ConvertToQuotedOutputPath(const char* p); void ConfigureOutputPaths(); void FormatOutputPath(std::string& path, const char* name); |