BUG: Changed include and link directory paths in cmMakefile back to std::vector because there is an order dependency. Only cmMakefile::AddIncludeDirectory and cmMakefile::AddLinkDirectory should be called to add directories to the paths. They make sure the paths are unique as they are inserted.

This commit is contained in:
Brad King 2001-07-30 11:34:03 -04:00
parent b24861d895
commit ddec29c52d
7 changed files with 52 additions and 61 deletions

View File

@ -644,11 +644,11 @@ void ElementCombinationGenerator::FindTagSource()
}
// Get the makefile's include path.
const std::set<std::string>& includePath =
const std::vector<std::string>& includePath =
m_Makefile->GetIncludeDirectories();
// Search the path for a file called "(m_Tag).h".
for(std::set<std::string>::const_iterator dir = includePath.begin();
for(std::vector<std::string>::const_iterator dir = includePath.begin();
dir != includePath.end(); ++dir)
{
std::string filePath = *dir;

View File

@ -298,9 +298,9 @@ void cmCableWrapTclCommand::GenerateCableClassFiles(const char* name,
commandArgs += m_Makefile->GetStartDirectory();
commandArgs += "\"";
const std::set<std::string>& includes =
const std::vector<std::string>& includes =
m_Makefile->GetIncludeDirectories();
for(std::set<std::string>::const_iterator i = includes.begin();
for(std::vector<std::string>::const_iterator i = includes.begin();
i != includes.end(); ++i)
{
commandArgs += " -I";

View File

@ -68,8 +68,8 @@ void cmDSPWriter::OutputDSPFile()
}
// Setup /I and /LIBPATH options for the resulting DSP file
std::set<std::string>& includes = m_Makefile->GetIncludeDirectories();
std::set<std::string>::iterator i;
std::vector<std::string>& includes = m_Makefile->GetIncludeDirectories();
std::vector<std::string>::iterator i;
for(i = includes.begin(); i != includes.end(); ++i)
{
m_IncludeOptions += "/I \"";
@ -504,8 +504,8 @@ void cmDSPWriter::WriteDSPHeader(std::ostream& fout, const char *libName,
libMultiLineOptions += exePath;
libMultiLineOptions += "\" \n";
}
std::set<std::string>::iterator i;
std::set<std::string>& libdirs = m_Makefile->GetLinkDirectories();
std::vector<std::string>::iterator i;
std::vector<std::string>& libdirs = m_Makefile->GetLinkDirectories();
for(i = libdirs.begin(); i != libdirs.end(); ++i)
{
libOptions += " /LIBPATH:\"";

View File

@ -90,9 +90,9 @@ void cmMakeDepend::SetMakefile(const cmMakefile* makefile)
m_Makefile->m_ComplainFileRegularExpression.c_str());
// Now extract any include paths from the makefile flags
const std::set<std::string>& includes =
const std::vector<std::string>& includes =
m_Makefile->GetIncludeDirectories();
for(std::set<std::string>::const_iterator j = includes.begin();
for(std::vector<std::string>::const_iterator j = includes.begin();
j != includes.end(); ++j)
{
std::string path = *j;

View File

@ -170,17 +170,6 @@ void cmMakefile::PrintStringVector(const char* s, const std::vector<std::string>
std::cout << " )\n";
}
void cmMakefile::PrintStringVector(const char* s, const std::set<std::string>& v) const
{
std::cout << s << ": ( \n";
for(std::set<std::string>::const_iterator i = v.begin();
i != v.end(); ++i)
{
std::cout << (*i).c_str() << " ";
}
std::cout << " )\n";
}
// call print on all the classes in the makefile
void cmMakefile::Print() const
@ -545,7 +534,15 @@ void cmMakefile::AddLinkLibrary(const char* lib)
void cmMakefile::AddLinkDirectory(const char* dir)
{
m_LinkDirectories.insert(dir);
// Don't add a link directory that is already present. Yes, this
// linear search results in n^2 behavior, but n won't be getting
// much bigger than 20. We cannot use a set because of order
// dependency of the link search path.
if(std::find(m_LinkDirectories.begin(),
m_LinkDirectories.end(), dir) == m_LinkDirectories.end())
{
m_LinkDirectories.push_back(dir);
}
}
void cmMakefile::AddSubDirectory(const char* sub)
@ -555,7 +552,15 @@ void cmMakefile::AddSubDirectory(const char* sub)
void cmMakefile::AddIncludeDirectory(const char* inc)
{
m_IncludeDirectories.insert(inc);
// Don't add an include directory that is already present. Yes,
// this linear search results in n^2 behavior, but n won't be
// getting much bigger than 20. We cannot use a set because of
// order dependency of the include path.
if(std::find(m_IncludeDirectories.begin(),
m_IncludeDirectories.end(), inc) == m_IncludeDirectories.end())
{
m_IncludeDirectories.push_back(inc);
}
}
void cmMakefile::AddDefinition(const char* name, const char* value)
@ -739,37 +744,20 @@ std::string cmMakefile::GetParentListFileName(const char *currentFileName)
void cmMakefile::ExpandVariables()
{
// Now expand varibles in the include and link strings
std::set<std::string>::iterator j, begin, end;
begin = m_IncludeDirectories.begin();
end = m_IncludeDirectories.end();
std::set<std::string> new_set;
std::string x;
for(j = begin; j != end; ++j)
for(std::vector<std::string>::iterator d = m_IncludeDirectories.begin();
d != m_IncludeDirectories.end(); ++d)
{
x= *j;
this->ExpandVariablesInString(x);
new_set.insert(x);
this->ExpandVariablesInString(*d);
}
m_IncludeDirectories = new_set;
new_set.clear();
begin = m_LinkDirectories.begin();
end = m_LinkDirectories.end();
for(j = begin; j != end; ++j)
for(std::vector<std::string>::iterator d = m_LinkDirectories.begin();
d != m_LinkDirectories.end(); ++d)
{
x = *j;
this->ExpandVariablesInString(x);
new_set.insert(x);
this->ExpandVariablesInString(*d);
}
m_LinkDirectories = new_set;
cmTarget::LinkLibraries::iterator j2, end2;
j2 = m_LinkLibraries.begin();
end2 = m_LinkLibraries.end();
for(; j2 != end2; ++j2)
for(cmTarget::LinkLibraries::iterator l = m_LinkLibraries.begin();
l != m_LinkLibraries.end(); ++l)
{
this->ExpandVariablesInString(j2->first);
this->ExpandVariablesInString(l->first);
}
}

View File

@ -383,11 +383,11 @@ public:
/**
* Get a list of include directories in the build.
*/
std::set<std::string>& GetIncludeDirectories()
std::vector<std::string>& GetIncludeDirectories()
{
return m_IncludeDirectories;
}
const std::set<std::string>& GetIncludeDirectories() const
const std::vector<std::string>& GetIncludeDirectories() const
{
return m_IncludeDirectories;
}
@ -395,7 +395,7 @@ public:
/**
* Get a list of link directories in the build.
*/
std::set<std::string>& GetLinkDirectories()
std::vector<std::string>& GetLinkDirectories()
{
return m_LinkDirectories;
}
@ -523,8 +523,12 @@ protected:
SourceMap m_Sources;
std::vector<std::string> m_SubDirectories; // list of sub directories
std::set<std::string> m_IncludeDirectories;
std::set<std::string> m_LinkDirectories;
// The include and link-library paths. These may have order
// dependency, so they must be vectors (not set).
std::vector<std::string> m_IncludeDirectories;
std::vector<std::string> m_LinkDirectories;
std::vector<std::string> m_ListFiles; // list of command files loaded
@ -555,7 +559,6 @@ private:
friend class cmMakeDepend; // make depend needs direct access
// to the m_Sources array
void PrintStringVector(const char* s, const std::vector<std::string>& v) const;
void PrintStringVector(const char* s, const std::set<std::string>& v) const;
void AddDefaultCommands();
void AddDefaultDefinitions();
std::set<cmFunctionBlocker *> m_FunctionBlockers;

View File

@ -65,7 +65,7 @@ void cmUnixMakefileGenerator::GenerateMakefile()
m_LibraryOutputPath += "/";
}
cmSystemTools::MakeDirectory(m_LibraryOutputPath.c_str());
m_Makefile->GetLinkDirectories().insert(m_LibraryOutputPath);
m_Makefile->AddLinkDirectory(m_LibraryOutputPath.c_str());
}
if (m_Makefile->GetDefinition("EXECUTABLE_OUTPUT_PATH"))
{
@ -76,7 +76,7 @@ void cmUnixMakefileGenerator::GenerateMakefile()
m_ExecutableOutputPath += "/";
}
cmSystemTools::MakeDirectory(m_ExecutableOutputPath.c_str());
m_Makefile->GetLinkDirectories().insert(m_ExecutableOutputPath);
m_Makefile->AddLinkDirectory(m_ExecutableOutputPath.c_str());
}
if(m_CacheOnly)
@ -362,8 +362,8 @@ void cmUnixMakefileGenerator::OutputLinkLibraries(std::ostream& fout,
// collect all the flags needed for linking libraries
std::string linkLibs;
std::set<std::string>& libdirs = m_Makefile->GetLinkDirectories();
for(std::set<std::string>::iterator libDir = libdirs.begin();
std::vector<std::string>& libdirs = m_Makefile->GetLinkDirectories();
for(std::vector<std::string>::iterator libDir = libdirs.begin();
libDir != libdirs.end(); ++libDir)
{
std::string libpath = cmSystemTools::EscapeSpaces(libDir->c_str());
@ -653,8 +653,8 @@ void cmUnixMakefileGenerator::OutputMakeFlags(std::ostream& fout)
{
// Output Include paths
fout << "INCLUDE_FLAGS = ";
std::set<std::string>& includes = m_Makefile->GetIncludeDirectories();
std::set<std::string>::iterator i;
std::vector<std::string>& includes = m_Makefile->GetIncludeDirectories();
std::vector<std::string>::iterator i;
fout << "-I" << m_Makefile->GetStartDirectory() << " ";
for(i = includes.begin(); i != includes.end(); ++i)
{