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

This commit is contained in:
Sebastien Barre 2001-12-06 13:32:28 -05:00
parent 2b8e16e59c
commit dea1309e8d
4 changed files with 36 additions and 50 deletions

View File

@ -248,11 +248,6 @@ void cmBorlandMakefileGenerator::OutputMakeRule(std::ostream& fout,
fout << startCommand << replace.c_str() << endCommand; fout << startCommand << replace.c_str() << endCommand;
} }
fout << "\n"; 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 void
@ -313,7 +308,6 @@ OutputBuildObjectFromSource(std::ostream& fout,
compileCommand += compileCommand +=
cmSystemTools::EscapeSpaces(source.GetFullPath().c_str()); cmSystemTools::EscapeSpaces(source.GetFullPath().c_str());
} }
m_QuoteNextCommand = false;
this->OutputMakeRule(fout, this->OutputMakeRule(fout,
comment.c_str(), comment.c_str(),
objectFile.c_str(), objectFile.c_str(),
@ -362,7 +356,6 @@ void cmBorlandMakefileGenerator::OutputSharedLibraryRule(std::ostream& fout,
} }
} }
command += "\n|\n"; command += "\n|\n";
m_QuoteNextCommand = false;
this->OutputMakeRule(fout, "rules for a shared library", this->OutputMakeRule(fout, "rules for a shared library",
target.c_str(), target.c_str(),
@ -398,7 +391,6 @@ void cmBorlandMakefileGenerator::OutputStaticLibraryRule(std::ostream& fout,
command += "\n|\n"; command += "\n|\n";
std::string comment = "rule to build static library: "; std::string comment = "rule to build static library: ";
comment += name; comment += name;
m_QuoteNextCommand = false;
this->OutputMakeRule(fout, this->OutputMakeRule(fout,
comment.c_str(), comment.c_str(),
target.c_str(), target.c_str(),
@ -436,7 +428,6 @@ void cmBorlandMakefileGenerator::OutputExecutableRule(std::ostream& fout,
std::string comment = "rule to build executable: "; std::string comment = "rule to build executable: ";
comment += name; comment += name;
m_QuoteNextCommand = false;
this->OutputMakeRule(fout, this->OutputMakeRule(fout,
comment.c_str(), comment.c_str(),
target.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;
}

View File

@ -102,13 +102,6 @@ protected:
const char* fullpath); const char* fullpath);
///! return true if the two paths are the same (checks short paths) ///! return true if the two paths are the same (checks short paths)
virtual bool SamePath(const char* path1, const char* path2); 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 #endif

View File

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

View File

@ -110,11 +110,8 @@ protected:
virtual bool SamePath(const char* path1, const char* path2); virtual bool SamePath(const char* path1, const char* path2);
void SetLibraryPathOption(const char* lib){ m_LibraryPathOption = lib;} void SetLibraryPathOption(const char* lib){ m_LibraryPathOption = lib;}
void SetLibraryLinkOption(const char* lib){ m_LibraryLinkOption = lib;} void SetLibraryLinkOption(const char* lib){ m_LibraryLinkOption = lib;}
virtual std::string ConvertToNativePath(const char* s);
private: 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_LibraryPathOption;// option to specifiy a link path -LIBPATH
std::string m_LibraryLinkOption; // option to specify a library (like -l, empty for nmake) std::string m_LibraryLinkOption; // option to specify a library (like -l, empty for nmake)
}; };