[cmake-developers] General Config.cmake file issue on ArchLinux

Alexander Neundorf neundorf at kde.org
Thu Dec 6 14:48:02 EST 2012


On Tuesday 04 December 2012, Stephen Kelly wrote:
> Alexander Neundorf wrote:
> > All install variables which are at cmake time somewhere below
> > CMAKE_INSTALL_PREFIX are treated as relative to CMAKE_INSTALL_PREFIX.
> > This is what the @PAKCAGE_INIT@ macro together with the @PACKAGE_FOO_DIR@
> > variables does.
> 
> Could your set_and_check macro be extended to warn in cases where a symlink
> is crossed?
> 
> eg:
> 
> File /lib64/cmake/foo/FooConfig.cmake
> contains set(Foo_Bar_Dir "../../../lib/libfoobar.so")
> 
> set and check walks up the path and checks at each step if it is a symlink.
> When it is at lib64/ which is a symlink and there is another '..', emit a
> warning? Similarly when climbing back up the path (eg if lib in the example
> above is a symlink). That should at least warn no matter which way around
> it is, right?
> 
> It's something that would need to be an option to cmsys::CollapseFullPath
> maybe. I'm still just brainstorming here really.
> 
> > Well, if you have a symlink, you don't know whether the symlink is the
> > correct location or the target of the symlink is the correct destination.
> 
> If you cross a symlink while processing a relative path, then something
> must have gone wrong.

I don't think so.

Let's assume /opt/foo/lib/ is a symlink to /usr/local/lib/.
The package has been installed to /opt/foo/ and is found via CMAKE_PREFIX_PATH 
in /opt/foo/lib/cmake/Foo/FooConfig.cmake.
Now when going up to the prefix, we will come across /opt/foo/lib/, which is a 
symlink, but everything will be fine, since going up will take us to 
/opt/foo/, from where we can correctly descend again.

If the package would have been found in 
/usr/local/lib/cmake/Foo/FooConfig.cmake (e.g. because CMAKE_PREFIX_PATH was 
not set), then we would get the problem, but here there would be no symlink 
(other than if it would be possible to test whether a directory is the 
destination of a symlink).

It's a problem if the symlinked location is not the location to which the 
package has been installed, but for whatever reason the symlinked location is 
found first.

Alex



More information about the cmake-developers mailing list