PG wrote:

Hi all,

I want to link a target to libraries A and B.
A is in the /usr/lib directory, and B is in another directory, say /some/path. My problem is that an old version of A also exists in the directory /some/path, and if I add this directory to the linker search path, /some/path/A will be found instead of /usr/lib/A.

I am using cmake 2.8 on linux (ubuntu 9.10 karmic), and found that with policy CMP0003, libraries with full path provided shouldn't produce linker search paths entry.
I made sure this policy is active by adding a
  CMAKE_POLICY(SET CMP0003 NEW)
even though I used
  CMAKE_MINIMUM_REQUIRED(VERSION 2.8)
at the beginning of my CMakeList.txt file.

I add these to library to the linker using full path:
  TARGET_LINK_LIBRARY(target /usr/lib/A /some/path/B)

I run cmake and got the error:

CMake Warning at CMakeLists.txt:67 (add_executable):
  Cannot generate a safe linker search path for target target because files
  in some directories may conflict with libraries in implicit directories:

    link library [A] in /usr/lib may be hidden by files in:
      /some/path

  Some of these libraries may not be found correctly.


I checked the file CMakeFiles/target.dir/link.txt
and get a line like
  /usr/bin/c++ [...] -L/some/path -lA -lB
where I would like to see
  /usr/bin/c++ [...] -lA /some/path/B
according to what I understood from the CMP0003 policy help page.
This:
  /usr/bin/c++ [...] -lA -L/some/path/ -lB
would also work, but as far as I understand this is not what policy CMP0003 should produce.


I googled for a solution, but cannot find any that corresponds to my case. I still don't understand why I get the "-L" statement while using policy CMP0003.

I also tried adding a
  LINK_DIRECTORIES(/usr/include)
to get at least something like
  /usr/bin/c++ [...] -L/usr/lib,/some/path -lA -lB
so /usr/lib/A will be found prior to /some/path/A, but it didn't change anything. I guess it is because /usr/lib is an implicit directory.


Is there a way to have this working, knowing that B is from a third party software, meaning that I don't have control on what files are present or not in the /some/path directory? I can of course manually edit the CMakeFiles/target.dir/link.txt file after running cmake, but as my code is to be installed by some users on their own computer, I would like to avoid asking them to do this.


Can you create a small example that shows the problem you are having?

Also, you might want to run cmake --trace and make sure nothing is changing the policy on you...

-Bill
_______________________________________________
Powered by www.kitware.com

Visit other Kitware open-source projects at 
http://www.kitware.com/opensource/opensource.html

Please keep messages on-topic and check the CMake FAQ at: 
http://www.cmake.org/Wiki/CMake_FAQ

Follow this link to subscribe/unsubscribe:
http://www.cmake.org/mailman/listinfo/cmake

Reply via email to