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