BUG: Fix same-file check for directory ordering

When computing runtime search path ordering a constraint exists when a
file that may be found by the runtime search exists in a directory other
than that containing the desired file.  We test whether a potential
conflict is really the same due to a symlink.  Recently the change to
cmFindLibraryCommand to load directory content created a case in which
the same-file check would be incorrectly skipped.  This avoids skipping
the check.
This commit is contained in:
Brad King 2008-12-26 13:28:20 -05:00
parent b77d00b7f6
commit 85a46e9e51
1 changed files with 11 additions and 14 deletions

View File

@ -113,25 +113,22 @@ protected:
bool cmOrderDirectoriesConstraint::FileMayConflict(std::string const& dir, bool cmOrderDirectoriesConstraint::FileMayConflict(std::string const& dir,
std::string const& name) std::string const& name)
{ {
// Check if the file will be built by cmake. // Check if the file exists on disk.
std::set<cmStdString> const& files =
(this->GlobalGenerator->GetDirectoryContent(dir, false));
if(std::set<cmStdString>::const_iterator(files.find(name)) != files.end())
{
return true;
}
// Check if the file exists on disk and is not a symlink back to the
// original file.
std::string file = dir; std::string file = dir;
file += "/"; file += "/";
file += name; file += name;
if(cmSystemTools::FileExists(file.c_str(), true) && if(cmSystemTools::FileExists(file.c_str(), true))
!cmSystemTools::SameFile(this->FullPath.c_str(), file.c_str()))
{ {
return true; // The file conflicts only if it is not the same as the original
// file due to a symlink or hardlink.
return !cmSystemTools::SameFile(this->FullPath.c_str(), file.c_str());
} }
return false;
// Check if the file will be built by cmake.
std::set<cmStdString> const& files =
(this->GlobalGenerator->GetDirectoryContent(dir, false));
std::set<cmStdString>::const_iterator fi = files.find(name);
return fi != files.end();
} }
//---------------------------------------------------------------------------- //----------------------------------------------------------------------------