[cmake-developers] FindPackageCheckArchLinuxSymlinks branch on stage

Alexander Neundorf neundorf at kde.org
Thu Jan 24 12:39:54 EST 2013


On Thursday 24 January 2013, Brad King wrote:
> On 1/21/2013 4:49 PM, Alexander Neundorf wrote:
> > It makes cmake warn if /lib64/ is a symbolic link to /usr/lib/ and a
> > Config.cmake file has been found in one of both (since any relative
> > directory references may be wrong then), see the "General Config.cmake
> > file issue on ArchLinux" thread here from November.
> 
> A package configuration file can know the path in which it was
> installed under the prefix rather than just the number of path
> components below the prefix.  Rather than using "../.." or
> stripping path components to get back the original prefix,
> we can actually *compare* the suffix part.
> 
> Say we install FooConfig.cmake to "<prefix>/lib/cmake/foo".
> The file can check if ${CMAKE_CURRENT_LIST_FILE} sits in a
> path ending in "/lib/cmake/foo".  If so, then the part before
> that is the <prefix>.  If not, then we likely have a symlink.
> Try resolving symlinks and then checking whether the path
> now ends in "/lib/cmake/foo".  If so, we now have a <prefix>.
> If not, then someone has fiddled with the layout since the
> installation.

And how do we proceed then ?
Also, it could have been installed into the symlink, but be found via the non-
symlink path.

Still, I think this is still not good enough.

If I understand correctly, with the "/usr-move", also /lib/ will be a symlink 
to /usr/lib/. Then it's the same suffix. Typically /lib/ is searched after 
/usr/lib/, so it will work for packages which have been installed to /usr/.
If a package has been installed to /, i.e. /lib/ is the correct path, it will 
first be found under /usr/lib/, and things may go wrong then.
It will probably point to /usr/usr/include/ for the include dirs.

The config macros check whether an install location is inside 
CMAKE_INSTALL_PREFIX or not. If not, they use the absolute path.
I would have to check how they work if CMAKE_INSTALL_PREFIX is /.
Maybe with some special handling for / it can be made to work. But then the 
package will not be relocatable anymore.

Alex



More information about the cmake-developers mailing list