[CMake] funny cmake warnings about conflicting library folders
Markus Blatt
markus at dr-blatt.de
Mon Sep 3 04:01:42 EDT 2012
On Mon, Sep 03, 2012 at 12:54:09AM +0200, Nico Schlömer wrote:
> 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.
I think CMake relies on absolute pathes. You might want to do
something like this :
get_filename_component(_dir "${CMAKE_CURRENT_LIST_FILE}" PATH)
get_filename_component(_prefix "${_dir}/../../.." ABSOLUTE)
SET(Foobar_INCLUDE_DIRS "${_prefix}/include/foobar")
SET(Foobar_LIBRARY_DIRS "${_prefix}/lib")
In newer versions there are also some macros/functions in
CMakePackageConfigHelpers that help
producing portable package configuration files.
Cheers,
Markus
--
Dr. Markus Blatt - HPC-Simulation-Software & Services http://www.dr-blatt.de
Hans-Bunte-Str. 8-10, 69123 Heidelberg, Germany, USt-Id: DE279960836
More information about the CMake
mailing list