[cmake-developers] FindPackageCheckArchLinuxSymlinks branch on stage

Alexander Neundorf neundorf at kde.org
Tue Jan 22 15:51:49 EST 2013


On Tuesday 22 January 2013, Stephen Kelly wrote:
> Alexander Neundorf wrote:
> > I think this is all a mess for cmake's config files, as long as they try
> > to be relocatable.
> > Should we just forget about relocatable Config.cmake files on UNIX
> > (excluding OSX) systems ?
> 
> Maybe it would be better to build some awareness into CMake of which
> platforms are symlinking like this, and what they are symlinking. That way,
> if a Config file is found in /lib64/lib/cmake/FooConfig.cmake, cmake would
> be able to 'switch' to use the non-symlink, which would make the relative
> paths correct, as long as the actual install was all into non-symlinks.

Yes, but as you say, only "as long as the actual install was all into non-
symlinks".

So what do we do about a package which installs into /lib64/, /bin/ and 
/usr/include/ ?

Here the found path in /lib64/lib/cmake/FooConfig.cmake would be the correct 
one, without the switching.

Maybe somewhere some logic could be added, so that if a config file is found 
in one of the two directories which are symlink pairs (as you suggest below), 
then in some way get the used CMAKE_INSTALL_PREFIX from the config (or 
version) file, and if this is the directory where it has been found, it is 
accepted, if it is the other symlinked directory, it is skipped, if it is none 
of both, it is accepted too.

This might work in many cases, but doesn't feel like a good solution.

Is there a way to keep cmake from installing into symlinked lib/ dirs ?
If, then find_package() could skip (known) lib/ dirs which are symlinks.
But, if somebody installs with DESTDIR, cmake has no idea whether lib/ is a 
symlink or a real directory in the actual file system.
Except if, as you suggest below, cmake knows which directories are symlinks.

Then, install() could error out if the destination is such a known symlinked 
dir, and find_package() could skip those symlinked dirs when searching.

Would that be safe ?

Hmm, this would fail if I let's say create an rpm on SUSE (without symlinks) 
and then install it on Fedora (with symlinks).

Or, as I already said, on UNIX systems just put full absolute paths in the 
Config.cmake files, then this is no issue (but the package can't be installed 
to another place).

> Something like this in Linux.cmake (partly pseudocode):
> 
> if (ARCHLINUX OR FEDORA18)
>   set(PLATFORM_SYMLINK_PAIRS
>     "/lib64" "/usr/lib64"
>     "/bin" "/usr/bin" # For illustration only. Config files don't get found
> below /bin, so this doesn't matter.
>   )
> endif()


Alex



More information about the cmake-developers mailing list