[CMake] should zlib be searched in CMAKE_PREFIX_PATH or am I confused?

Mario Emmenlauer mario at emmenlauer.de
Wed Mar 21 05:31:48 EDT 2018


Dear All,

I use find_package(ZLIB) to detect zlib on Ubuntu 16.04 Linux.
I have a newer zlib in /data/thirdparty that I'd like to use. To
prefer my newer version I add -DCMAKE_PREFIX_PATH="/data/thirdparty".
In my understanding, the documentation says CMAKE_PREFIX_PATH is
searched first (1). But cmake behaves different than I'd expect:

It detects the system zlib first:

-- Found ZLIB: /usr/lib/x86_64-linux-gnu/libz.so (found version "1.2.8")

And then complains that zlib exists twice:

CMake Warning at CMakeLists.txt:693 (add_library):
  Cannot generate a safe runtime search path for target bdaimage because
  files in some directories may conflict with libraries in implicit
  directories:
    runtime library [libz.so.1] in /usr/lib/x86_64-linux-gnu may be hidden by files in:
      /data/thirdparty/lib
  Some of these libraries may not be found correctly.

Why am I misunderstanding the documentation? Is CMAKE_PREFIX_PATH
not preferred over system directories?

All the best,

    Mario Emmenlauer


(1) https://cmake.org/cmake/help/v3.0/command/find_package.html



--
BioDataAnalysis GmbH, Mario Emmenlauer      Tel. Buero: +49-89-74677203
Balanstr. 43                   mailto: memmenlauer * biodataanalysis.de
D-81669 München                          http://www.biodataanalysis.de/


More information about the CMake mailing list