[CMake] funny cmake warnings about conflicting library folders

Nico Schlömer nico.schloemer at gmail.com
Sun Sep 2 18:54:09 EDT 2012


Hi all,

I have a software library "Foobar" here that installs its
library in /usr/lib,
headers in /usr/include/foobar, and
CMake files in /usr/share/cmake/Foobar/FoobarConfig.cmake. -- So far, so good.

Foobar also depends on LAPACK, so it sets "SET(Foobar_TPL_LIBRARIES
"/usr/lib/liblapack.so")" in
/usr/share/cmake/Foobar/FoobarConfig.cmake; this variable can then be
used later for ADD_EXECUTABLE().
In an attempt to make Foobar relocatable, the library and header
directories are specified in
/usr/share/cmake/Foobar/FoobarConfig.cmake as

SET(Foobar_INCLUDE_DIRS "${CMAKE_CURRENT_LIST_DIR}/../../../include/foobar")
SET(Foobar_LIBRARY_DIRS "${CMAKE_CURRENT_LIST_DIR}/../../../lib")

All of this seems correct.
When running CMake on a project with FIND_PACKAGE(Foobar), the user is
swamped with warnings of the kind

==================== *snip* ====================
CMake Warning at test/CMakeLists.txt:81 (ADD_EXECUTABLE):
  Cannot generate a safe runtime search path for target operatorTest because
  files in some directories may conflict with libraries in implicit
  directories:

    runtime library [libblas.so.3] in /usr/lib may be hidden by files in:
      /usr/share/cmake/Foobar/../../../lib

  Some of these libraries may not be found correctly.
==================== *snap* ====================

When I edit /usr/share/cmake/Foobar/FoobarConfig.cmake to read

SET(Foobar_LIBRARY_DIRS "/usr/lib"),

those warnings disappear.

May this be a bug in CMake?
What would you think is the correct way to deal with this?

Cheers,
Nico


More information about the CMake mailing list