فهرست منبع

Fix the command quoting pb (remove m_QuoteNextCommand), move ConvertToNativePath to NMake gen

Sebastien Barre 24 سال پیش
والد
کامیت
dea1309e8d

+ 0 - 15
Source/cmBorlandMakefileGenerator.cxx

@@ -248,11 +248,6 @@ void cmBorlandMakefileGenerator::OutputMakeRule(std::ostream& fout,
     fout << startCommand << replace.c_str() << endCommand;
     }
   fout << "\n";
-  // reset m_QuoteNextCommand, as the default should be to quote the 
-  // commands.   We need the quotes when the command has a full path
-  // to an executable.  However, the quotes break things like the
-  // linker command.
-  m_QuoteNextCommand = true;
 }
 
 void 
@@ -313,7 +308,6 @@ OutputBuildObjectFromSource(std::ostream& fout,
     compileCommand += 
       cmSystemTools::EscapeSpaces(source.GetFullPath().c_str());
     }
-  m_QuoteNextCommand = false;
   this->OutputMakeRule(fout,
                        comment.c_str(),
                        objectFile.c_str(),
@@ -362,7 +356,6 @@ void cmBorlandMakefileGenerator::OutputSharedLibraryRule(std::ostream& fout,
       }
     }
   command += "\n|\n";
-  m_QuoteNextCommand = false;
     
   this->OutputMakeRule(fout, "rules for a shared library",
                        target.c_str(),
@@ -398,7 +391,6 @@ void cmBorlandMakefileGenerator::OutputStaticLibraryRule(std::ostream& fout,
   command += "\n|\n";
   std::string comment = "rule to build static library: ";
   comment += name;
-  m_QuoteNextCommand = false;
   this->OutputMakeRule(fout,
                        comment.c_str(),
                        target.c_str(),
@@ -436,7 +428,6 @@ void cmBorlandMakefileGenerator::OutputExecutableRule(std::ostream& fout,
   
   std::string comment = "rule to build executable: ";
   comment += name;
-  m_QuoteNextCommand = false;
   this->OutputMakeRule(fout, 
                        comment.c_str(),
                        target.c_str(),
@@ -489,10 +480,4 @@ void cmBorlandMakefileGenerator::OutputBuildLibraryInDir(std::ostream& fout,
 }
 
 
-std::string cmBorlandMakefileGenerator::ConvertToNativePath(const char* s)
-{
-  std::string ret = s;
-  cmSystemTools::ConvertToWindowsSlashes(ret);
-  return ret;
-}
 

+ 0 - 7
Source/cmBorlandMakefileGenerator.h

@@ -102,13 +102,6 @@ protected:
 				       const char* fullpath); 
   ///! return true if the two paths are the same (checks short paths)
   virtual bool SamePath(const char* path1, const char* path2);
-  virtual std::string ConvertToNativePath(const char* s);
-
-private:
-  bool m_QuoteNextCommand;      // if this is true, OutputMakeRule
-                                // will not quote the next commands
-                                // it is reset to false after each
-                                // call to OutputMakeRule
 };
 
 #endif

+ 35 - 24
Source/cmNMakeMakefileGenerator.cxx

@@ -57,7 +57,6 @@ cmNMakeMakefileGenerator::cmNMakeMakefileGenerator()
   this->SetLibraryPrefix("");
   this->SetStaticLibraryExtension("$(CMAKE_STATICLIB_SUFFIX)");
   this->SetSharedLibraryExtension("$(CMAKE_SHLIB_SUFFIX)");
-  m_QuoteNextCommand = true; // most of the time command should be quoted
 }
 
 cmNMakeMakefileGenerator::~cmNMakeMakefileGenerator()
@@ -143,21 +142,15 @@ void cmNMakeMakefileGenerator::OutputMakeVariables(std::ostream& fout)
 {
   fout << "# NMake Makefile generated by cmake\n";
   const char* variables = 
-    "# general varibles used in the makefile\n"
+    "# general variables used in the makefile\n"
     "\n"
     "# Path to cmake\n"
-    "CMAKE_COMMAND                          = ${CMAKE_COMMAND}\n"    
     "CMAKE_STANDARD_WINDOWS_LIBRARIES       = @CMAKE_STANDARD_WINDOWS_LIBRARIES@\n"
-    "CMAKE_C_COMPILER                       = @CMAKE_C_COMPILER@\n"
     "CMAKE_C_FLAGS                          = @CMAKE_C_FLAGS@ @BUILD_FLAGS@\n"
-
     "CMAKE_C_LINK_EXECUTABLE_FLAG           = @CMAKE_C_LINK_EXECUTABLE_FLAG@\n"
     "CMAKE_CXX_FLAGS                        = @CMAKE_CXX_FLAGS@ @BUILD_FLAGS@\n"
-    "CMAKE_CXX_COMPILER                     = @CMAKE_CXX_COMPILER@\n"
-    "CMAKE_LINKER                           = @CMAKE_LINKER@\n"
     "CMAKE_LINKER_FLAGS                     = @CMAKE_LINKER_FLAGS@ @LINKER_BUILD_FLAGS@\n"
     "CMAKE_LINKER_SHARED_LIBRARY_FLAG       = @CMAKE_LINKER_SHARED_LIBRARY_FLAG@\n"
-    "CMAKE_LIBRARY_MANAGER                  = @CMAKE_LIBRARY_MANAGER@\n"
     "CMAKE_LIBRARY_MANAGER_FLAGS            = @CMAKE_LIBRARY_MANAGER_FLAGS@\n"
     "CMAKE_OBJECT_FILE_SUFFIX               = @CMAKE_OBJECT_FILE_SUFFIX@\n"
     "CMAKE_EXECUTABLE_SUFFIX                = @CMAKE_EXECUTABLE_SUFFIX@\n"
@@ -181,6 +174,27 @@ void cmNMakeMakefileGenerator::OutputMakeVariables(std::ostream& fout)
   std::string replaceVars = variables;
   m_Makefile->ExpandVariablesInString(replaceVars);
   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";
+
+  std::string cxxcompiler = m_Makefile->GetDefinition("CMAKE_CXX_COMPILER");
+  cmSystemTools::ConvertToWindowsSlashes(cxxcompiler);
+  fout << "CMAKE_CXX_COMPILER                     = " << cmSystemTools::EscapeSpaces(cxxcompiler.c_str()) << "\n";
+
+  std::string linker = m_Makefile->GetDefinition("CMAKE_LINKER");
+  cmSystemTools::ConvertToWindowsSlashes(linker);
+  fout << "CMAKE_LINKER                           = " << cmSystemTools::EscapeSpaces(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";
+
+  std::string cmakecommand = m_Makefile->GetDefinition("CMAKE_COMMAND");
+  cmSystemTools::ConvertToWindowsSlashes(cmakecommand);
+  fout << "CMAKE_COMMAND                          = " << cmSystemTools::EscapeSpaces(cmakecommand.c_str()) << "\n";
+
   fout << "CMAKE_CURRENT_SOURCE                   = " 
        << ShortPath(m_Makefile->GetStartDirectory() )
        << "\n";
@@ -192,6 +206,7 @@ void cmNMakeMakefileGenerator::OutputMakeVariables(std::ostream& fout)
   fout << "CMAKE_BINARY_DIR                       = " 
        << ShortPath(m_Makefile->GetHomeOutputDirectory() )
        << "\n";
+
   // Output Include paths
   fout << "INCLUDE_FLAGS                          = ";
   std::vector<std::string>& includes = m_Makefile->GetIncludeDirectories();
@@ -208,6 +223,7 @@ void cmNMakeMakefileGenerator::OutputMakeVariables(std::ostream& fout)
       fout << "-I" << cmSystemTools::EscapeSpaces(i->c_str()).c_str() << " ";
       }
     } 
+
   fout << m_Makefile->GetDefineFlags();
   fout << "\n\n";
 }
@@ -279,13 +295,8 @@ void cmNMakeMakefileGenerator::OutputMakeRule(std::ostream& fout,
     fout << replace.c_str();
     }
   fout << "\n";
-  const char* startCommand = "\t\"";
-  const char* endCommand = "\"\n";
-  if(!m_QuoteNextCommand)
-    {
-    startCommand = "\t";
-    endCommand = "\n";
-    }
+  const char* startCommand = "\t";
+  const char* endCommand = "\n";
   if(command)
     {
     replace = ShortPathCommand(command);
@@ -311,11 +322,6 @@ void cmNMakeMakefileGenerator::OutputMakeRule(std::ostream& fout,
     fout << startCommand << replace.c_str() << endCommand;
     }
   fout << "\n";
-  // reset m_QuoteNextCommand, as the default should be to quote the 
-  // commands.   We need the quotes when the command has a full path
-  // to an executable.  However, the quotes break things like the
-  // linker command.
-  m_QuoteNextCommand = true;
 }
 
 void 
@@ -371,6 +377,7 @@ OutputBuildObjectFromSource(std::ostream& fout,
   // assume c++ if not c rc or def
   else
     {
+    
     compileCommand = "$(CMAKE_CXX_COMPILER) $(CMAKE_CXX_FLAGS) ";
     compileCommand += extraCompileFlags;
     if(shared)
@@ -390,7 +397,6 @@ OutputBuildObjectFromSource(std::ostream& fout,
     compileCommand += " " + output_object_file_flag;
     compileCommand += objectFile;
     }
-  m_QuoteNextCommand = false;
   this->OutputMakeRule(fout,
                        comment.c_str(),
                        objectFile.c_str(),
@@ -437,7 +443,6 @@ void cmNMakeMakefileGenerator::OutputSharedLibraryRule(std::ostream& fout,
       }
     }
   command += "\n<<\n";
-  m_QuoteNextCommand = false;
   this->OutputMakeRule(fout, "rules for a shared library",
                        target.c_str(),
                        depend.c_str(),
@@ -474,7 +479,6 @@ void cmNMakeMakefileGenerator::OutputStaticLibraryRule(std::ostream& fout,
   command += "\n<<\n";
   std::string comment = "rule to build static library: ";
   comment += name;
-  m_QuoteNextCommand = false;
   this->OutputMakeRule(fout,
                        comment.c_str(),
                        target.c_str(),
@@ -516,7 +520,6 @@ void cmNMakeMakefileGenerator::OutputExecutableRule(std::ostream& fout,
   command += linklibs.str();
   std::string comment = "rule to build executable: ";
   comment += name;
-  m_QuoteNextCommand = false;
   this->OutputMakeRule(fout, 
                        comment.c_str(),
                        target.c_str(),
@@ -648,3 +651,11 @@ void cmNMakeMakefileGenerator::OutputBuildLibraryInDir(std::ostream& fout,
        << "\n\tcd " <<
     cmSystemTools::EscapeSpaces(currentDir.c_str()) << "\n";
 }
+
+
+std::string cmNMakeMakefileGenerator::ConvertToNativePath(const char* s)
+{
+  std::string ret = s;
+  cmSystemTools::ConvertToWindowsSlashes(ret);
+  return ret;
+}

+ 1 - 4
Source/cmNMakeMakefileGenerator.h

@@ -110,11 +110,8 @@ 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);
 private:
-  bool m_QuoteNextCommand;      // if this is true, OutputMakeRule
-                                // will not quote the next commands
-                                // it is reset to false after each
-                                // call to OutputMakeRule
   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)
 };