<html><body style="word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space;" class="">Hi Mario,<div class=""><br class=""></div><div class="">Very sorry, I should have looked more closely! CMAKE_MODULE_PATH is for libraries that install their own CMake scripts. You are correct, Zlib only installs a pkg-config script. However, FindZLIB.cmake doesn’t appear to use that at all (aka I don’t believe you <i class="">need</i> to be setting PKG_CONFIG_PATH). You should be able to get away with setting <b class="">ZLIB_ROOT</b>. So for you I think it would look like</div><div class=""><br class=""></div><div class=""> cmake .. -DZLIB_ROOT=/data/thirdparty</div><div class=""><br class=""></div><div class="">FindZLIB.cmake will proceed to look for ZLIB_ROOT/include/zlib.h and look in ZLIB_ROOT/lib for the library.</div><div class=""><br class=""></div><div class="">The XXX_ROOT is typically available for any built-in CMake FindXXX.cmake modules (see hint at bottom: <a href="https://cmake.org/cmake/help/v3.0/module/FindZLIB.html" class="">https://cmake.org/cmake/help/v3.0/module/FindZLIB.html</a> ). These FindXXX.cmake modules are for this exact scenario: there is a library that many users want access to that does not install cmake scripts (typically because the library uses a different build system such as autotools).</div><div class=""><br class=""></div><div class="">- - - - -</div><div class=""><br class=""></div><div class="">If you are still having trouble, this is what I used to test this. I didn’t actually write code that uses it, but I suspect if you <b class="">remove</b> setting of CMAKE_PREFIX_PATH (I think that’s where your conflict originates from) and just specify ZLIB_ROOT your problem will be solved (I hope!).</div><div class=""><br class=""></div><div class="">With a very crude CMakeLists.txt:</div><div class=""><br class=""></div><div class=""><div class=""> cmake_minimum_required(VERSION 3.0 FATAL_ERROR)</div><div class=""> project("find_zlib")</div><div class=""><br class=""></div><div class=""> find_package(ZLIB)</div><div class=""> if (ZLIB_FOUND)</div><div class=""> message(FATAL_ERROR "Found Zlib:\n- ZLIB_INCLUDE_DIRS: ${ZLIB_INCLUDE_DIRS}\n- ZLIB_LIBRARIES: ${ZLIB_LIBRARIES}")</div><div class=""> else()</div><div class=""> message(FATAL_ERROR "Did not find Zlib :/")</div><div class=""> endif()</div></div><div class=""><br class=""></div><div class=""><b class="">Without</b> setting ZLIB_ROOT:</div><div class=""><br class=""></div><div class=""> $ cmake ..</div><div class=""> -- Found ZLIB: /usr/lib/libz.dylib (found version "1.2.8")</div><div class=""> CMake Error at CMakeLists.txt:6 (message):</div><div class=""> Found Zlib:</div><div class=""> - ZLIB_INCLUDE_DIRS: /usr/include</div><div class=""> - ZLIB_LIBRARIES: /usr/lib/libz.dylib</div><div class=""><br class=""></div><div class="">That’s the default Zlib that comes with OS X. However, if I specify ZLIB_ROOT:</div><div class=""><br class=""></div><div class=""> $ cmake .. -DZLIB_ROOT=/usr/local/Cellar/zlib/1.2.11/</div><div class=""> -- Found ZLIB: /usr/local/Cellar/zlib/1.2.11/lib/libz.dylib (found version "1.2.11")</div><div class=""> CMake Error at CMakeLists.txt:6 (message):</div><div class=""> Found Zlib:</div><div class=""> - ZLIB_INCLUDE_DIRS: /usr/local/Cellar/zlib/1.2.11/include</div><div class=""> - ZLIB_LIBRARIES: /usr/local/Cellar/zlib/1.2.11/lib/libz.dylib</div><div class=""><br class=""></div><div class="">Let us know if it works or if you still need help!</div><div class=""><br class=""></div><div class="">-Stephen</div><div class=""><br class=""></div></body></html>