[CMake] Result of FIND_LIBRARY changing its value
Alan W. Irwin
irwin at beluga.phys.uvic.ca
Sun Nov 26 11:53:44 EST 2006
On 2006-11-26 17:08+0100 Eduard Bloch wrote:
> I have a problem with the FIND_LIBRARY directive. I need to look in
> /usr/local/lib for libraries that may be installed additionaly by user.
> But then I would like to use the libs found there and not the ones in
> default system path. Therefore, I would like to have the full path to
> the library or having -L/usr/local/lib attached only before the extra
> libraries are specified. I tried to use the value returned by
> FIND_LIBRARY. I can print it with MESSAGE() and I see
> /usr/local/lib/libiconv.a there (it's an AIX system, don't wonder). It
> seems also to work with lib lists passed with LINK_LIBRARIES.
> However, when this var is passed to TARGET_LINK_LIBRARIES, it seems to
> be changed to "-liconv" in the call. It is visible with VERBOSE=1, there
> is suddenly -liconv instead of /usr/local/lib/libiconv.a .
> What can I do to solve that? Adding -L/usr/local/lib to the compiler
> flags is a workaround, but is there any better way?
IIRC, for some Unix systems /usr/local/lib takes precedence over /usr/lib
without having to specify -L/usr/local/lib. You can check your libraries
with the ldd command (or whatever equivalent there is on AIX) to see exactly
which libraries they are linked with. It's quite possible cmake knows the
AIX conventions and it does not specify the -L/usr/local/lib flag because it
is actually not needed for that platform. Normally, though, cmake does
specify the appropriate -L option for libraries that have been found in
If it turns out the -L/usr/local/lib flag is necessary on your version of
AIX, and cmake does not supply it, then that is a bug in the platform
support for cmake which I suggest you report with AIX version, ldd results,
etc. via the CMake bug-tracking system.
Alan W. Irwin
Astronomical research affiliation with Department of Physics and Astronomy,
University of Victoria (astrowww.phys.uvic.ca).
Programming affiliations with the FreeEOS equation-of-state implementation
for stellar interiors (freeeos.sf.net); PLplot scientific plotting software
package (plplot.org); the Yorick front-end to PLplot (yplot.sf.net); the
Loads of Linux Links project (loll.sf.net); and the Linux Brochure Project
More information about the CMake