diff --git a/Source/cmOrderDirectories.cxx b/Source/cmOrderDirectories.cxx index 54f23f794..24b7138df 100644 --- a/Source/cmOrderDirectories.cxx +++ b/Source/cmOrderDirectories.cxx @@ -113,25 +113,22 @@ protected: bool cmOrderDirectoriesConstraint::FileMayConflict(std::string const& dir, std::string const& name) { - // Check if the file will be built by cmake. - std::set const& files = - (this->GlobalGenerator->GetDirectoryContent(dir, false)); - if(std::set::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. + // Check if the file exists on disk. std::string file = dir; file += "/"; file += name; - if(cmSystemTools::FileExists(file.c_str(), true) && - !cmSystemTools::SameFile(this->FullPath.c_str(), file.c_str())) + if(cmSystemTools::FileExists(file.c_str(), true)) { - 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 const& files = + (this->GlobalGenerator->GetDirectoryContent(dir, false)); + std::set::const_iterator fi = files.find(name); + return fi != files.end(); } //----------------------------------------------------------------------------