Do not output library search path if the library path option/flag is empty + add CMAKE_LINKER_HIDE_PARAMETERS since some linkers just do not support the @<< syntax
This commit is contained in:
parent
efe160656b
commit
0a5f763bbe
|
@ -397,6 +397,7 @@ OutputBuildObjectFromSource(std::ostream& fout,
|
||||||
compileCommand += " " + output_object_file_flag;
|
compileCommand += " " + output_object_file_flag;
|
||||||
compileCommand += objectFile;
|
compileCommand += objectFile;
|
||||||
}
|
}
|
||||||
|
|
||||||
this->OutputMakeRule(fout,
|
this->OutputMakeRule(fout,
|
||||||
comment.c_str(),
|
comment.c_str(),
|
||||||
objectFile.c_str(),
|
objectFile.c_str(),
|
||||||
|
@ -420,7 +421,15 @@ void cmNMakeMakefileGenerator::OutputSharedLibraryRule(std::ostream& fout,
|
||||||
m_Makefile->GetDefinition("CMAKE_LINKER_OUTPUT_FILE_FLAG");
|
m_Makefile->GetDefinition("CMAKE_LINKER_OUTPUT_FILE_FLAG");
|
||||||
m_Makefile->ExpandVariablesInString(linker_output_file_flag);
|
m_Makefile->ExpandVariablesInString(linker_output_file_flag);
|
||||||
|
|
||||||
std::string command = "$(CMAKE_LINKER) $(CMAKE_LINKER_SHARED_LIBRARY_FLAG) @<<\n\t $(CMAKE_LINKER_FLAGS) " + linker_output_file_flag;
|
std::string command = "$(CMAKE_LINKER) $(CMAKE_LINKER_SHARED_LIBRARY_FLAG)";
|
||||||
|
|
||||||
|
bool hide_param = m_Makefile->IsOn("CMAKE_LINKER_HIDE_PARAMETERS");
|
||||||
|
if (hide_param)
|
||||||
|
{
|
||||||
|
command += " @<<\n\t";
|
||||||
|
}
|
||||||
|
|
||||||
|
command += " $(CMAKE_LINKER_FLAGS) " + linker_output_file_flag;
|
||||||
|
|
||||||
std::string dllpath = m_LibraryOutputPath + std::string(name) + m_SharedLibraryExtension;
|
std::string dllpath = m_LibraryOutputPath + std::string(name) + m_SharedLibraryExtension;
|
||||||
command += cmSystemTools::EscapeSpaces(dllpath.c_str());
|
command += cmSystemTools::EscapeSpaces(dllpath.c_str());
|
||||||
|
@ -432,6 +441,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();
|
||||||
|
|
||||||
const std::vector<cmSourceFile>& sources = t.GetSourceFiles();
|
const std::vector<cmSourceFile>& sources = t.GetSourceFiles();
|
||||||
for(std::vector<cmSourceFile>::const_iterator i = sources.begin();
|
for(std::vector<cmSourceFile>::const_iterator i = sources.begin();
|
||||||
i != sources.end(); ++i)
|
i != sources.end(); ++i)
|
||||||
|
@ -442,7 +452,13 @@ void cmNMakeMakefileGenerator::OutputSharedLibraryRule(std::ostream& fout,
|
||||||
command += i->GetFullPath();
|
command += i->GetFullPath();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
command += "\n<<\n";
|
|
||||||
|
command += "\n";
|
||||||
|
if (hide_param)
|
||||||
|
{
|
||||||
|
command += "<<\n";
|
||||||
|
}
|
||||||
|
|
||||||
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,11 +490,14 @@ void cmNMakeMakefileGenerator::OutputStaticLibraryRule(std::ostream& fout,
|
||||||
|
|
||||||
std::string libpath = m_LibraryOutputPath + std::string(name) + m_StaticLibraryExtension;
|
std::string libpath = m_LibraryOutputPath + std::string(name) + m_StaticLibraryExtension;
|
||||||
command += cmSystemTools::EscapeSpaces(libpath.c_str());
|
command += cmSystemTools::EscapeSpaces(libpath.c_str());
|
||||||
|
|
||||||
command += " $(";
|
command += " $(";
|
||||||
command += std::string(name) + "_SRC_OBJS)";
|
command += std::string(name) + "_SRC_OBJS)";
|
||||||
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;
|
||||||
|
|
||||||
this->OutputMakeRule(fout,
|
this->OutputMakeRule(fout,
|
||||||
comment.c_str(),
|
comment.c_str(),
|
||||||
target.c_str(),
|
target.c_str(),
|
||||||
|
@ -518,8 +537,10 @@ void cmNMakeMakefileGenerator::OutputExecutableRule(std::ostream& fout,
|
||||||
this->OutputLinkLibraries(linklibs, 0, t);
|
this->OutputLinkLibraries(linklibs, 0, t);
|
||||||
linklibs << std::ends;
|
linklibs << std::ends;
|
||||||
command += linklibs.str();
|
command += linklibs.str();
|
||||||
|
|
||||||
std::string comment = "rule to build executable: ";
|
std::string comment = "rule to build executable: ";
|
||||||
comment += name;
|
comment += name;
|
||||||
|
|
||||||
this->OutputMakeRule(fout,
|
this->OutputMakeRule(fout,
|
||||||
comment.c_str(),
|
comment.c_str(),
|
||||||
target.c_str(),
|
target.c_str(),
|
||||||
|
@ -537,23 +558,30 @@ void cmNMakeMakefileGenerator::OutputLinkLibraries(std::ostream& fout,
|
||||||
|
|
||||||
// Embed runtime search paths if possible and if required.
|
// Embed runtime search paths if possible and if required.
|
||||||
// collect all the flags needed for linking libraries
|
// collect all the flags needed for linking libraries
|
||||||
|
// Do not try if there is no library path option (it is set to -L or
|
||||||
|
// -LIBPATH for some linker, but some others do not even support link
|
||||||
|
// search path).
|
||||||
std::string linkLibs;
|
std::string linkLibs;
|
||||||
std::vector<std::string>& libdirs = m_Makefile->GetLinkDirectories();
|
|
||||||
for(std::vector<std::string>::iterator libDir = libdirs.begin();
|
|
||||||
libDir != libdirs.end(); ++libDir)
|
|
||||||
{
|
|
||||||
std::string libpath = ShortPath(libDir->c_str());
|
|
||||||
if(emitted.insert(libpath).second)
|
|
||||||
{
|
|
||||||
// Expand content because this value might have
|
|
||||||
// trailing space (since it is directly prepended to the filename)
|
|
||||||
std::string replaceVars = m_LibraryPathOption;
|
|
||||||
m_Makefile->ExpandVariablesInString(replaceVars);
|
|
||||||
|
|
||||||
linkLibs += replaceVars;
|
// Expand content because this value might have
|
||||||
cmSystemTools::ConvertToWindowsSlashes(libpath);
|
// trailing space (since it is directly prepended to the filename)
|
||||||
linkLibs += libpath;
|
std::string lib_path_opt = m_LibraryPathOption;
|
||||||
linkLibs += " ";
|
m_Makefile->ExpandVariablesInString(lib_path_opt);
|
||||||
|
|
||||||
|
if (lib_path_opt.size())
|
||||||
|
{
|
||||||
|
std::vector<std::string>& libdirs = m_Makefile->GetLinkDirectories();
|
||||||
|
for(std::vector<std::string>::iterator libDir = libdirs.begin();
|
||||||
|
libDir != libdirs.end(); ++libDir)
|
||||||
|
{
|
||||||
|
std::string libpath = ShortPath(libDir->c_str());
|
||||||
|
if(emitted.insert(libpath).second)
|
||||||
|
{
|
||||||
|
linkLibs += lib_path_opt;
|
||||||
|
cmSystemTools::ConvertToWindowsSlashes(libpath);
|
||||||
|
linkLibs += libpath;
|
||||||
|
linkLibs += " ";
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue