summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--Source/cmOrderLinkDirectories.cxx68
-rw-r--r--Source/cmOrderLinkDirectories.h6
-rw-r--r--Tests/Complex/Executable/complex.cxx4
-rw-r--r--Tests/ComplexOneConfig/Executable/complex.cxx4
-rw-r--r--Tests/ComplexRelativePaths/Executable/complex.cxx4
5 files changed, 76 insertions, 10 deletions
diff --git a/Source/cmOrderLinkDirectories.cxx b/Source/cmOrderLinkDirectories.cxx
index 2c5a108..4d74c47 100644
--- a/Source/cmOrderLinkDirectories.cxx
+++ b/Source/cmOrderLinkDirectories.cxx
@@ -74,7 +74,27 @@ void cmOrderLinkDirectories::FindIndividualLibraryOrders()
lib != this->MultiDirectoryLibraries.end(); ++lib)
{
std::vector<cmStdString>& dirs = this->LibraryToDirectories[lib->FullPath];
- this->DirectoryToAfterList[lib->Path] = dirs;
+ std::vector<std::pair<cmStdString, std::vector<cmStdString> > >::iterator i;
+ for(i = this->DirectoryToAfterList.begin(); i != this->DirectoryToAfterList.end();
+ ++i)
+ {
+ if(i->first == lib->Path)
+ {
+ break;
+ }
+ }
+ if(i == this->DirectoryToAfterList.end())
+ {
+ std::cerr << "ERROR: should not happen\n";
+ }
+ else
+ {
+ for(std::vector<cmStdString>::iterator d = dirs.begin();
+ d != dirs.end(); ++d)
+ {
+ i->second.push_back(*d);
+ }
+ }
}
}
@@ -162,14 +182,14 @@ void cmOrderLinkDirectories::PrepareLinkTargets()
//-------------------------------------------------------------------
bool cmOrderLinkDirectories::FindPathNotInDirectoryToAfterList(
cmStdString& path)
-{
- for(std::map<cmStdString, std::vector<cmStdString> >::iterator i
+{
+ for(std::vector<std::pair<cmStdString, std::vector<cmStdString> > >::iterator i
= this->DirectoryToAfterList.begin();
i != this->DirectoryToAfterList.end(); ++i)
{
const cmStdString& p = i->first;
bool found = false;
- for(std::map<cmStdString, std::vector<cmStdString> >::iterator j
+ for(std::vector<std::pair<cmStdString, std::vector<cmStdString> > >::iterator j
= this->DirectoryToAfterList.begin(); j != this->DirectoryToAfterList.end()
&& !found; ++j)
{
@@ -208,7 +228,7 @@ void cmOrderLinkDirectories::OrderPaths(std::vector<cmStdString>&
// then there is a cycle and we are stuck
if(this->DirectoryToAfterList.size())
{
- for(std::map<cmStdString, std::vector<cmStdString> >::iterator i
+ for(std::vector<std::pair<cmStdString, std::vector<cmStdString> > >::iterator i
= this->DirectoryToAfterList.begin();
i != this->DirectoryToAfterList.end(); ++i)
{
@@ -235,8 +255,13 @@ void cmOrderLinkDirectories::SetLinkInformation(
for(std::vector<std::string>::const_iterator p = linkDirectories.begin();
p != linkDirectories.end(); ++p)
{
- this->DirectoryToAfterList[*p] = empty;
- this->LinkPathSet.insert(*p);
+ if(this->DirectoryToAfterListEmitted.insert(*p).second)
+ {
+ std::pair<cmStdString, std::vector<cmStdString> > dp;
+ dp.first = *p;
+ this->DirectoryToAfterList.push_back(dp);
+ this->LinkPathSet.insert(*p);
+ }
}
// Append the link library list into our raw list.
@@ -310,7 +335,12 @@ bool cmOrderLinkDirectories::DetermineLibraryPathOrder()
}
dir = cmSystemTools::GetActualCaseForPath(dir.c_str());
#endif
- this->DirectoryToAfterList[dir] = empty;
+ if(this->DirectoryToAfterListEmitted.insert(dir).second)
+ {
+ std::pair<cmStdString, std::vector<cmStdString> > dp;
+ dp.first = dir;
+ this->DirectoryToAfterList.push_back(dp);
+ }
this->LinkPathSet.insert(dir);
aLib.FullPath = this->RawLinkItems[i];
aLib.File = file;
@@ -343,7 +373,7 @@ bool cmOrderLinkDirectories::DetermineLibraryPathOrder()
if(this->Debug)
{
this->PrintMap("this->LibraryToDirectories", this->LibraryToDirectories);
- this->PrintMap("this->DirectoryToAfterList", this->DirectoryToAfterList);
+ this->PrintVector("this->DirectoryToAfterList", this->DirectoryToAfterList);
}
this->OrderPaths(this->SortedSearchPaths);
// now turn libfoo.a into foo and foo.a into foo
@@ -403,6 +433,26 @@ cmOrderLinkDirectories::PrintMap(const char* name,
std::cout << "\n";
}
}
+//-------------------------------------------------------------------
+void
+cmOrderLinkDirectories::PrintVector(const char* name,
+ std::vector<std::pair<cmStdString,
+ std::vector<cmStdString> > >& m)
+{
+ std::cout << name << "\n";
+ for(std::vector<std::pair<cmStdString, std::vector<cmStdString> > >::iterator i =
+ m.begin(); i != m.end();
+ ++i)
+ {
+ std::cout << i->first << ": ";
+ for(std::vector<cmStdString>::iterator l = i->second.begin();
+ l != i->second.end(); ++l)
+ {
+ std::cout << *l << " ";
+ }
+ std::cout << "\n";
+ }
+}
void cmOrderLinkDirectories::GetFullPathLibraries(std::vector<cmStdString>&
libs)
diff --git a/Source/cmOrderLinkDirectories.h b/Source/cmOrderLinkDirectories.h
index a7e1b2a..f5aca3d 100644
--- a/Source/cmOrderLinkDirectories.h
+++ b/Source/cmOrderLinkDirectories.h
@@ -108,6 +108,9 @@ private:
void FindIndividualLibraryOrders();
void PrintMap(const char* name,
std::map<cmStdString, std::vector<cmStdString> >& m);
+ void PrintVector(const char* name,
+ std::vector<std::pair<cmStdString,
+ std::vector<cmStdString> > >& m);
void OrderPaths(std::vector<cmStdString>& paths);
bool FindPathNotInDirectoryToAfterList(cmStdString& path);
std::string NoCaseExpression(const char* str);
@@ -115,7 +118,8 @@ private:
// map from library to directories that it is in other than its full path
std::map<cmStdString, std::vector<cmStdString> > LibraryToDirectories;
// map from directory to vector of directories that must be after it
- std::map<cmStdString, std::vector<cmStdString> > DirectoryToAfterList;
+ std::vector<std::pair<cmStdString, std::vector<cmStdString> > > DirectoryToAfterList;
+ std::set<cmStdString> DirectoryToAfterListEmitted;
// map from full path to a Library struct
std::map<cmStdString, Library> FullPathLibraries;
// libraries that are found in multiple directories
diff --git a/Tests/Complex/Executable/complex.cxx b/Tests/Complex/Executable/complex.cxx
index 60308a4..5b8cebd 100644
--- a/Tests/Complex/Executable/complex.cxx
+++ b/Tests/Complex/Executable/complex.cxx
@@ -93,6 +93,10 @@ bool TestLibraryOrder(bool shouldFail)
orderLibs.SetLinkPrefix("lib");
orderLibs.SetLinkInformation("test", linkLibraries, linkDirectories);
bool ret = orderLibs.DetermineLibraryPathOrder();
+ if(!ret)
+ {
+ std::cout << orderLibs.GetWarnings() << "\n";
+ }
orderLibs.GetLinkerInformation(sortedpaths, linkItems);
std::cout << "Sorted Link Paths:\n";
for(std::vector<cmStdString>::iterator i = sortedpaths.begin();
diff --git a/Tests/ComplexOneConfig/Executable/complex.cxx b/Tests/ComplexOneConfig/Executable/complex.cxx
index 60308a4..5b8cebd 100644
--- a/Tests/ComplexOneConfig/Executable/complex.cxx
+++ b/Tests/ComplexOneConfig/Executable/complex.cxx
@@ -93,6 +93,10 @@ bool TestLibraryOrder(bool shouldFail)
orderLibs.SetLinkPrefix("lib");
orderLibs.SetLinkInformation("test", linkLibraries, linkDirectories);
bool ret = orderLibs.DetermineLibraryPathOrder();
+ if(!ret)
+ {
+ std::cout << orderLibs.GetWarnings() << "\n";
+ }
orderLibs.GetLinkerInformation(sortedpaths, linkItems);
std::cout << "Sorted Link Paths:\n";
for(std::vector<cmStdString>::iterator i = sortedpaths.begin();
diff --git a/Tests/ComplexRelativePaths/Executable/complex.cxx b/Tests/ComplexRelativePaths/Executable/complex.cxx
index 60308a4..5b8cebd 100644
--- a/Tests/ComplexRelativePaths/Executable/complex.cxx
+++ b/Tests/ComplexRelativePaths/Executable/complex.cxx
@@ -93,6 +93,10 @@ bool TestLibraryOrder(bool shouldFail)
orderLibs.SetLinkPrefix("lib");
orderLibs.SetLinkInformation("test", linkLibraries, linkDirectories);
bool ret = orderLibs.DetermineLibraryPathOrder();
+ if(!ret)
+ {
+ std::cout << orderLibs.GetWarnings() << "\n";
+ }
orderLibs.GetLinkerInformation(sortedpaths, linkItems);
std::cout << "Sorted Link Paths:\n";
for(std::vector<cmStdString>::iterator i = sortedpaths.begin();