[CMake] policy CMP0003 and full path, but still conflict with implicit directories

Brad King brad.king at kitware.com
Thu Feb 25 14:01:15 EST 2010


PG wrote:
> 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.

It is not necessary to explicitly set the policy.  Even a minimum version
of CMake 2.6 will set that particular policy to NEW.

> 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 was able to reproduce this as follows:

  cmake_minimum_required(VERSION 2.6)
  project(FOO C)
  link_directories(/some/path) # ** this line is the cause
  add_executable(foo foo.c)
  target_link_libraries(foo /usr/lib/libm.so /some/path/libB.so)

Without the explicit link_directories call it should not happen.
Perhaps in something else in the project is calling link_directories()?

-Brad


More information about the CMake mailing list