> > 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
> non-standard places.
> 
> 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.

It depends on what neccessary means. I played a bit with IBMs native compiler 
xlc and gcc and they have different behaviour. xlc's looks first in 
/usr/include, AIX ld looks first in /usr/lib, GCC looks first in 
/usr/local/include. And ld seems to use some voodoo to find the correct library 
which this source has been compiled for.

In cmake's default linker flags for various situations, it uses an order 
similar to xlc's, so it is not a real bug. However, I need to make sure that 
/usr/local/lib is used when /usr/local/lib/libiconv.a has been found. OTOH it 
may be any other path, eg. /opt/freeware/..., so the user should have an easy 
way to configure it. It was really easy with autodevtools, I have set LDFLAGS 
environment once and forgot about the issue.

With cmake, there are three variables for linker flags in the cache. Assuming 
that the user wants to set linker flags and does set those vars explicitely, it 
is still not enough. Because FIND_LIBRARY has another, independent lookup 
algorithm. Introducing another alien, some LIB variable (which I have never 
seen before, which is not documented well and which does not work AFAICS). And 
then there are the Cmake modules using another list of "required libraries". I 
have not looked at the details but it looks like they are processed trough 
cmake's library option-list building algorithms and so the final command call 
is not influenced by user's ld flags.

So what is the best way to say: I want -L/usr/local/bin be prepended to the 
command on whatever you do with gcc, and also be respected by ALL tests, etc.?

For my current purpose (linking with a library but only if it is there), I 
consider throwing the find_library test away and use self-made snippet with 
CheckCSourceCompiles module and the user ldflags passed trough 
CMAKE_REQUIRED_FLAGS.
-- 
Der GMX SmartSurfer hilft bis zu 70% Ihrer Onlinekosten zu sparen! 
Ideal für Modem und ISDN: http://www.gmx.net/de/go/smartsurfer
_______________________________________________
CMake mailing list
[email protected]
http://www.cmake.org/mailman/listinfo/cmake

Reply via email to