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

Eric Noulard eric.noulard at gmail.com
Fri Mar 23 05:58:51 EDT 2018


2018-03-23 10:21 GMT+01:00 Mario Emmenlauer <mario at emmenlauer.de>:

>
> Thanks PF, I think this makes more sense now! I was assuming that
> cmake always prefers CMAKE_PREFIX_PATH over builtin paths. But as you
> clarified, that only applies to libraries that provide find_package
> support.
>
> This is actually quite unfortunate. Then I don't see an easy way to
> enforce usage of specific libs. As an example, if I want to enforce a
> patched libtiff (that does not itself provide find_package support)
> the only "safe" way is to replace the system libtiff. Otherwise any
> package might just find the system version first without me even
> knowing.
>

You can always ship your own/patched version of  Find<Whatever>.cmake
module with your
project source and build the 'local' override logic in it for every
project/lib that does not provide a find_package.

Be sure to APPEND your local cmake module path (CMAKE_MODULE_PATH)

something like:
 list(APPEND CMAKE_MODULE_PATH ${AFS_SOURCE_DIR}/cmake)

before using find_package etc...

I find it a "safer" solution than system lib replacement.
My opinion though.

-- 
Eric
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://cmake.org/pipermail/cmake/attachments/20180323/2bb8e149/attachment.html>


More information about the CMake mailing list