[CMake] Symlink problem under linux for runtime search path generation

Nicolas Desprès nicolas.despres at gmail.com
Fri Dec 26 05:03:21 EST 2008


Hi Brad,

Sorry for the delayed answer. It was Christmas break :-)

I've tried your patch and it works :-) Thank you very much. I think
the next step is to open an issue in the bug tracker (I could do it).
Or maybe you can directly commit the patch if you have access.

Thanks again,

-- 
Nico

On Wed, Dec 24, 2008 at 10:39 PM, Brad King <brad.king at kitware.com> wrote:
> Nicolas Desprès wrote:
>>
>> But in this kind of case, cmake could figure out that these two
>> directories are actually the same ?
>
> There is code to figure that out but it doesn't seem to be working
> for some reason.  My guess is that the recent change to help find
> openbsd-style libraries enabled loading of the directory content
> including that on disk from the directory.  This tricks the code
> into thinking CMake will build the file which skips the same-file test.
>
> Try the patch below.  If it doesn't work, look in
> Source/cmOrderDirectories.cxx for the function
>
>  cmOrderDirectoriesConstraint::FileMayConflict
>
> This is the function that checks for a file in a given directory that
> could conflict with a given file in another directory during the runtime
> search.  First it checks whether a conflicting file will be built by
> CMake.  If not, then it looks for a file on disk that is not the same
> (considering symlinks) as the given file.  Can you please add some print
> statements in there to see what it is doing?
>
> -Brad
>
> diff --git Source/cmOrderDirectories.cxx Source/cmOrderDirectories.cxx
> index 54f23f7..24b7138 100644
> --- Source/cmOrderDirectories.cxx
> +++ 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<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.
> +  // 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<cmStdString> const& files =
> +    (this->GlobalGenerator->GetDirectoryContent(dir, false));
> +  std::set<cmStdString>::const_iterator fi = files.find(name);
> +  return fi != files.end();
>  }
>
>  //----------------------------------------------------------------------------
>



-- 
Nicolas Desprès


More information about the CMake mailing list