ENH: fix library builds with nmake
This commit is contained in:
parent
4b34ffa669
commit
2df56cf21b
@ -54,6 +54,7 @@ cmNMakeMakefileGenerator::cmNMakeMakefileGenerator()
|
||||
this->SetLibraryPrefix("");
|
||||
this->SetSharedLibraryExtension(".dll");
|
||||
this->SetStaticLibraryExtension(".lib");
|
||||
m_QuoteNextCommand = true; // most of the time command should be quoted
|
||||
}
|
||||
|
||||
cmNMakeMakefileGenerator::~cmNMakeMakefileGenerator()
|
||||
@ -186,31 +187,43 @@ 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";
|
||||
}
|
||||
if(command)
|
||||
{
|
||||
replace = command;
|
||||
m_Makefile->ExpandVariablesInString(replace);
|
||||
fout << "\t\"" << replace.c_str() << "\"\n";
|
||||
fout << startCommand << replace.c_str() << endCommand;
|
||||
}
|
||||
if(command2)
|
||||
{
|
||||
replace = command2;
|
||||
m_Makefile->ExpandVariablesInString(replace);
|
||||
fout << "\t\"" << replace.c_str() << "\"\n";
|
||||
fout << startCommand << replace.c_str() << endCommand;
|
||||
}
|
||||
if(command3)
|
||||
{
|
||||
replace = command3;
|
||||
m_Makefile->ExpandVariablesInString(replace);
|
||||
fout << "\t\"" << replace.c_str() << "\"\n";
|
||||
fout << startCommand << replace.c_str() << endCommand;
|
||||
}
|
||||
if(command4)
|
||||
{
|
||||
replace = command4;
|
||||
m_Makefile->ExpandVariablesInString(replace);
|
||||
fout << "\t\"" << replace.c_str() << "\"\n";
|
||||
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
|
||||
@ -262,6 +275,7 @@ OutputBuildObjectFromSource(std::ostream& fout,
|
||||
compileCommand += " /Fo";
|
||||
compileCommand += objectFile;
|
||||
}
|
||||
m_QuoteNextCommand = false;
|
||||
this->OutputMakeRule(fout,
|
||||
comment.c_str(),
|
||||
objectFile.c_str(),
|
||||
@ -285,6 +299,7 @@ void cmNMakeMakefileGenerator::OutputSharedLibraryRule(std::ostream& fout,
|
||||
linklibs << std::ends;
|
||||
command += linklibs.str();
|
||||
delete [] linklibs.str();
|
||||
m_QuoteNextCommand = false;
|
||||
this->OutputMakeRule(fout, "rules for a shared library",
|
||||
target.c_str(),
|
||||
depend.c_str(),
|
||||
@ -312,6 +327,7 @@ void cmNMakeMakefileGenerator::OutputStaticLibraryRule(std::ostream& fout,
|
||||
command += std::string(name) + "_SRC_OBJS)";
|
||||
std::string comment = "rule to build static library: ";
|
||||
comment += name;
|
||||
m_QuoteNextCommand = false;
|
||||
this->OutputMakeRule(fout,
|
||||
comment.c_str(),
|
||||
target.c_str(),
|
||||
@ -338,6 +354,7 @@ 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(),
|
||||
|
@ -98,6 +98,11 @@ protected:
|
||||
virtual void OutputLinkLibraries(std::ostream& fout,
|
||||
const char* targetLibrary,
|
||||
const cmTarget &tgt);
|
||||
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
|
||||
|
@ -144,13 +144,13 @@ protected:
|
||||
const std::vector<std::string>&
|
||||
SubDirectories);
|
||||
virtual void OutputMakeRule(std::ostream&,
|
||||
const char* comment,
|
||||
const char* target,
|
||||
const char* depends,
|
||||
const char* command,
|
||||
const char* command2 = 0,
|
||||
const char* command3 = 0,
|
||||
const char* command4 = 0);
|
||||
const char* comment,
|
||||
const char* target,
|
||||
const char* depends,
|
||||
const char* command,
|
||||
const char* command2 = 0,
|
||||
const char* command3 = 0,
|
||||
const char* command4 = 0);
|
||||
void SetObjectFileExtension(const char* e) { m_ObjectFileExtension = e;}
|
||||
void SetExecutableExtension(const char* e) { m_ExecutableExtension = e;}
|
||||
void SetStaticLibraryExtension(const char* e) {m_StaticLibraryExtension = e;}
|
||||
|
@ -55,7 +55,7 @@ cmake::cmake()
|
||||
m_Verbose = false;
|
||||
#if defined(_WIN32) && !defined(__CYGWIN__)
|
||||
cmMakefileGenerator::RegisterGenerator(new cmMSProjectGenerator);
|
||||
// cmMakefileGenerator::RegisterGenerator(new cmNMakeMakefileGenerator);
|
||||
cmMakefileGenerator::RegisterGenerator(new cmNMakeMakefileGenerator);
|
||||
cmMakefileGenerator::RegisterGenerator(new cmBorlandMakefileGenerator);
|
||||
#else
|
||||
cmMakefileGenerator::RegisterGenerator(new cmUnixMakefileGenerator);
|
||||
|
Loading…
x
Reference in New Issue
Block a user