[CMake] CMAKE_SYSTEM_LIBRARY_PATH does not honor system wide ld.so.conf/ld.config setting

Ryo IGARASHI rigarash at gmail.com
Thu Jan 21 20:50:24 EST 2010


Hi, developers,

When I look at Platform/UnixPaths.cmake file, I found that
CMAKE_SYSTEM_LIBRARY_PATH is hardcoded.
This means that find_library() does not honor system-wide
library path settings which may be set by system admininstrator
and/or OS policy and fails to find libraries even if you can link them
from the command line without specifying library path.

It looks to me that find_library() uses /bin/ls like algorithm
for finding lib*.so.* files instead of real link test used by autotools
(whether "${CC} X.c -lXXX" works).
(I do not look at the find_library() source; correct me if I am wrong)
I know that autotools mechanism is expensive but do not suffer
from this problem since the link can succeed without knowing
system-wide search path.

CMAKE_SYSTEM_LIBRARY_PATH should be set from
platform/machine settings. The policy of setting system-wide
library search path varies from distribution to distribution
and even changes when version changes.
For example, on NetBSD, system-wide library search path
should only be /usr/lib, since they remove /usr/local/lib from
that list (from version 4.0). (See http://www.netbsd.org/docs/elf.html).
On linux systems, the variable should be set from /etc/ld.so.conf
and files included from this file (normally /etc/ld.so.conf.d/*.conf
but not restricted).
On Solaris systems, command created /var/ld/ld.config is used.
FreeBSD, OpenBSD, HP-UX, AIX etc. may have different convention.

Best regards,
-- 
Ryo IGARASHI, Ph.D.
rigarash at gmail.com


More information about the CMake mailing list