Hi all,

I posted an issue about link dir order a week ago, but it seems nobody
has replied to it :-/ Is there a reason like "one should not use env
var, but FindXXX scripts instead", or did it simply slip through
unnoticed?

The initial post follows.

Thanks,
Renaud.


Hello,

I'm having trouble with cmake LINK_DIRECTORIES order. I understand
cmake smart-orders link directory flags. However, flags coming from
the shell env LDFLAGS don't seem to be taken into account in this
smart sort. Is this a feature or a bug?

To illustrate the issue, I slightly modified the example code from

  http://www.cmake.org/HTML/cmakeExample.tar.gz

The only change is in

  cmakeExample.tar.gz:CMakeExample/Hello/CMakeLists.txt

which becomes

# Create a library called "Hello" which includes the source file "hello.cxx". # The extension is already found. Any number of sources could be listed here.
add_library (Hello hello.cxx)

INSTALL(TARGETS Hello
        RUNTIME DESTINATION bin
        ARCHIVE DESTINATION lib
        LIBRARY DESTINATION lib)

As one can see in the attached terminal output, the linker for Demo
looks in /tmp/lib before looking in the build dir:

  /usr/bin/c++ -headerpad_max_install_names -fPIC -L/tmp/lib
  "CMakeFiles/helloDemo.dir/demo.o"
  "CMakeFiles/helloDemo.dir/demo_b.o" -o helloDemo
  -L/Volumes/Data/Users/detryr/tmp/CMakeExample/Hello -lHello

As a result, Demo is linked against an obsolete installed version of
Hello, instead of the local fresh one.

Here's the terminal output (note that /tmp/lib was empty when I ran cmake):

[EMAIL PROTECTED] $ export LDFLAGS=-L/tmp/lib [~/tmp/ CMakeExample] [EMAIL PROTECTED] $ rm /tmp/lib/libHello.a [~/tmp/ CMakeExample]
rm: /tmp/lib/libHello.a: No such file or directory
[EMAIL PROTECTED] $ cmake -DCMAKE_INSTALL_PREFIX=/tmp [~/tmp/ CMakeExample]
  [...]
[EMAIL PROTECTED] $ make VERBOSE=1 [~/tmp/ CMakeExample]
  [...]
cd /Volumes/Data/Users/detryr/tmp/CMakeExample/Demo && /usr/bin/c+ + -headerpad_max_install_names -fPIC -L/tmp/lib "CMakeFiles/ helloDemo.dir/demo.o" "CMakeFiles/helloDemo.dir/demo_b.o" -o helloDemo -L/Volumes/Data/Users/detryr/tmp/CMakeExample/Hello -lHello
  [...]

_______________________________________________
CMake mailing list
[email protected]
http://www.cmake.org/mailman/listinfo/cmake

Reply via email to