Răsfoiți Sursa

ERR: Corrected use of double-quotes to be compatible with UNIX make. Now double quotes (windows) or escape sequences for spaces (unix) are added when dependencies are output.

Brad King 25 ani în urmă
părinte
comite
e0da3ef275

+ 6 - 6
Source/cmCableCommand.cxx

@@ -81,23 +81,23 @@ void cmCableCommand::SetupCableData()
   
   
   // We must add a custom rule to cause the cable_config.xml to be re-built
   // We must add a custom rule to cause the cable_config.xml to be re-built
   // when it is removed.  Rebuilding it means re-running CMake.
   // when it is removed.  Rebuilding it means re-running CMake.
-  std::string cMakeLists = "\"";
-  cMakeLists += m_Makefile->GetStartDirectory();
+  std::string cMakeLists = m_Makefile->GetStartDirectory();
   cMakeLists += "/";
   cMakeLists += "/";
-  cMakeLists += "CMakeLists.txt\"";
+  cMakeLists += "CMakeLists.txt";
 
 
   std::string command;
   std::string command;
 #if defined(_WIN32) && !defined(__CYGWIN__)
 #if defined(_WIN32) && !defined(__CYGWIN__)
   command = "\"";
   command = "\"";
   command += m_Makefile->GetHomeDirectory();
   command += m_Makefile->GetHomeDirectory();
-  command += "/CMake/Source/CMakeSetupCMD\" ";
+  command += "/CMake/Source/CMakeSetupCMD\" \"";
   command += cMakeLists;
   command += cMakeLists;
-  command += " -DSP";
+  command += "\" -DSP";
 #else
 #else
   command = "\"";
   command = "\"";
   command += m_Makefile->GetHomeOutputDirectory();  
   command += m_Makefile->GetHomeOutputDirectory();  
-  command += "/CMake/Source/CMakeBuildTargets\" ";
+  command += "/CMake/Source/CMakeBuildTargets\" \"";
   command += cMakeLists;
   command += cMakeLists;
+  command += "\"";
 #endif
 #endif
   command += " -H\"";
   command += " -H\"";
   command += m_Makefile->GetHomeDirectory();
   command += m_Makefile->GetHomeDirectory();

+ 1 - 1
Source/cmDSPMakefile.cxx

@@ -322,7 +322,7 @@ void cmDSPMakefile::WriteCustomRule(std::ostream& fout,
       for(std::set<std::string>::const_iterator d = depends.begin();
       for(std::set<std::string>::const_iterator d = depends.begin();
           d != depends.end(); ++d)
           d != depends.end(); ++d)
         {
         {
-        fout << " " << d->c_str();
+        fout << " \"" << d->c_str() << "\"";
         }
         }
       fout << "\n  " << command << "\n\n";
       fout << "\n  " << command << "\n\n";
       }
       }

+ 1 - 1
Source/cmDSPWriter.cxx

@@ -322,7 +322,7 @@ void cmDSPMakefile::WriteCustomRule(std::ostream& fout,
       for(std::set<std::string>::const_iterator d = depends.begin();
       for(std::set<std::string>::const_iterator d = depends.begin();
           d != depends.end(); ++d)
           d != depends.end(); ++d)
         {
         {
-        fout << " " << d->c_str();
+        fout << " \"" << d->c_str() << "\"";
         }
         }
       fout << "\n  " << command << "\n\n";
       fout << "\n  " << command << "\n\n";
       }
       }

+ 16 - 0
Source/cmSystemTools.cxx

@@ -129,6 +129,22 @@ void cmSystemTools::ReplaceString(std::string& source,
     }
     }
 }
 }
 
 
+
+std::string cmSystemTools::EscapeSpaces(const char* str)
+{
+  std::string result = "";
+  for(const char* ch = str; *ch != '\0'; ++ch)
+    {
+    if(*ch == ' ')
+      {
+      result += '\\';
+      }
+    result += *ch;
+    }
+  return result;
+}
+
+
 // return true if the file exists
 // return true if the file exists
 bool cmSystemTools::FileExists(const char* filename)
 bool cmSystemTools::FileExists(const char* filename)
 {
 {

+ 6 - 0
Source/cmSystemTools.h

@@ -42,6 +42,12 @@ public:
                             const char* replace,
                             const char* replace,
                             const char* with);
                             const char* with);
 
 
+  /**
+   * Return a string equivalent to the input string, but with all " " replaced
+   * with "\ " to escape the spaces.
+   */
+  static std::string EscapeSpaces(const char*);
+  
   /**
   /**
    * Replace Windows file system slashes with Unix-style slashes.
    * Replace Windows file system slashes with Unix-style slashes.
    */
    */

+ 2 - 1
Source/cmUnixMakefileGenerator.cxx

@@ -436,7 +436,8 @@ void cmUnixMakefileGenerator::OutputCustomRules(std::ostream& fout)
                 commandFiles.m_Depends.begin();
                 commandFiles.m_Depends.begin();
               d != commandFiles.m_Depends.end(); ++d)
               d != commandFiles.m_Depends.end(); ++d)
             {
             {
-            fout << " " << d->c_str();
+            std::string dep = cmSystemTools::EscapeSpaces(d->c_str());
+            fout << " " << dep.c_str();
             }
             }
           fout << "\n\t" << command.c_str() << "\n\n";
           fout << "\n\t" << command.c_str() << "\n\n";
           }
           }

+ 2 - 2
Source/cmUtilitySourceCommand.cxx

@@ -70,8 +70,8 @@ bool cmUtilitySourceCommand::Invoke(std::vector<std::string>& args)
   
   
   // Construct the cache entry for the executable's location.
   // Construct the cache entry for the executable's location.
   std::string utilityExecutable =
   std::string utilityExecutable =
-    "\""+utilityDirectory+"/"+cmakeCFGout+"/"
-    +utilityName+cmSystemTools::GetExecutableExtension()+"\"";
+    utilityDirectory+"/"+cmakeCFGout+"/"
+    +utilityName+cmSystemTools::GetExecutableExtension();
   
   
   // Enter the value into the cache.
   // Enter the value into the cache.
   cmCacheManager::GetInstance()->AddCacheEntry(cacheEntry.c_str(),
   cmCacheManager::GetInstance()->AddCacheEntry(cacheEntry.c_str(),