[CMake] Problems with implicit directories

Brad King brad.king at kitware.com
Fri Nov 13 13:32:35 EST 2009


Tyler Roscoe wrote:
> We then rebuilt Qt and told it to link dynamically against the "system"
> libpng instead. That resolved the version mismatch problem, but now each
> library in my product that links against Qt produces this warning:
> 
>> CMake Warning at
>> /chehalis/tylermr/autobuild/common/trunk/_build/util/HelperMacros.cmake:592
>> (add_library):
>>   Cannot generate a safe runtime search path for target
>>   [a library in my project that uses Qt] because files in some directories may
>> conflict
>>   with libraries in implicit directories:
>>
>>     runtime library [libpng12.so.0] in /usr/lib64 may be hidden by
>>     files
>> in:
>>       /3rdpartylibs/png/1.2.35/build/linux/release/lib
>>     runtime library [libz.so.1] in /usr/lib64 may be hidden by files
>>     in:
>>       /3rdpartylibs/zlib/1.2.3/build/linux/release/lib
>>
>>   Some of these libraries may not be found correctly.
> 
> I think my problem has something to do with the transitive linking that
> CMake calculates. That is, it sees that my library needs some Qt
> library, so then it tries to figure out what that Qt library needs.

CMake does not try to detect the dependencies of an outside library.

> Qt library needs libpng, so it looks around and finds libpng in /usr/lib
> (note that my /3rdpartylibs/png/... location is not in LD_LIBRARY_PATH
> or anything like that). But then when it goes to compile my library, it
> has two different libpngs to contend with, and throws the warning.
> 
> If my analysis of why this is happening is correct, can someone suggest
> a way to de-confuse CMake and quell the warning?

Something is telling CMake that you want the directory

   /3rdpartylibs/png/1.2.35/build/linux/release/lib

in the runtime library search path.  You may be linking to a library in
this directory, or adding it with link_directories() and setting the
INSTALL_RPATH_USE_LINK_PATH property for the target.  Anyway, CMake is
warning you that you can't put that directory in the RPATH because the
file

   /3rdpartylibs/png/1.2.35/build/linux/release/lib/libpng12.so.0

will be found by the dynamic loader at runtime instead of

   /usr/lib64/libpng12.so.0

from the system directory.

-Brad


More information about the CMake mailing list