ENH: Compress the library search directories so that each appears only once.

This commit is contained in:
Amitha Perera 2001-06-05 22:54:42 -04:00
parent 22270abae5
commit 84edcba848
1 changed files with 20 additions and 9 deletions

View File

@ -251,6 +251,9 @@ void cmUnixMakefileGenerator::OutputLinkLibraries(std::ostream& fout,
const char* targetLibrary, const char* targetLibrary,
const cmTarget &tgt) const cmTarget &tgt)
{ {
// Try to emit each search path once
std::set<std::string> emitted;
// collect all the flags needed for linking libraries // collect all the flags needed for linking libraries
std::string linkLibs; std::string linkLibs;
std::vector<std::string>& libdirs = m_Makefile->GetLinkDirectories(); std::vector<std::string>& libdirs = m_Makefile->GetLinkDirectories();
@ -259,6 +262,8 @@ void cmUnixMakefileGenerator::OutputLinkLibraries(std::ostream& fout,
{ {
std::string libpath = cmSystemTools::EscapeSpaces(libDir->c_str()); std::string libpath = cmSystemTools::EscapeSpaces(libDir->c_str());
if(libpath != "/usr/lib") if(libpath != "/usr/lib")
{
if(emitted.insert(libpath).second)
{ {
std::string::size_type pos = libDir->find("-L"); std::string::size_type pos = libDir->find("-L");
if((pos == std::string::npos || pos > 0) if((pos == std::string::npos || pos > 0)
@ -270,6 +275,8 @@ void cmUnixMakefileGenerator::OutputLinkLibraries(std::ostream& fout,
linkLibs += " "; linkLibs += " ";
} }
} }
}
std::string librariesLinked; std::string librariesLinked;
const cmTarget::LinkLibraries& libs = tgt.GetLinkLibraries(); const cmTarget::LinkLibraries& libs = tgt.GetLinkLibraries();
cmRegularExpression reg("lib(.*)(\\.so$|\\.a|\\.sl$)"); cmRegularExpression reg("lib(.*)(\\.so$|\\.a|\\.sl$)");
@ -293,11 +300,14 @@ void cmUnixMakefileGenerator::OutputLinkLibraries(std::ostream& fout,
dir, file); dir, file);
std::string libpath = cmSystemTools::EscapeSpaces(dir.c_str()); std::string libpath = cmSystemTools::EscapeSpaces(dir.c_str());
if(libpath != "/usr/lib") if(libpath != "/usr/lib")
{
if(emitted.insert(libpath).second)
{ {
linkLibs += "-L"; linkLibs += "-L";
linkLibs += libpath; linkLibs += libpath;
linkLibs += " "; linkLibs += " ";
} }
}
cmRegularExpression libname("lib(.*)\\.(.*)"); cmRegularExpression libname("lib(.*)\\.(.*)");
if(libname.find(file)) if(libname.find(file))
{ {
@ -318,6 +328,7 @@ void cmUnixMakefileGenerator::OutputLinkLibraries(std::ostream& fout,
librariesLinked += " "; librariesLinked += " ";
} }
} }
linkLibs += librariesLinked; linkLibs += librariesLinked;
if(!targetLibrary) if(!targetLibrary)