[cmake-developers] Debugging find_package() search behavior?

Robert Dailey rcdailey.lists at gmail.com
Tue Aug 29 10:48:54 EDT 2017


I am doing that. Here is a live example:

Library is zlib, installed here:

E:\code\frontend\msvc_2015\third_party\installed\zlib

(has include, lib, bin, share inside it)

I set the following variables (Using the set() command (non-cache)
inside my CMake script, before the find_package calls):

CMAKE_PREFIX_PATH: E:/code/frontend/msvc_2015/third_party/installed
CMAKE_FIND_ROOT_PATH: E:/code/frontend/msvc_2015/third_party/installed

And then the find_package() command is executed:

find_package( ZLIB 1.2.11 EXACT REQUIRED )

And fails with:

CMake Error at E:/Program
Files/CMake/share/cmake-3.9/Modules/FindPackageHandleStandardArgs.cmake:137
(message):
Could NOT find ZLIB (missing: ZLIB_LIBRARY ZLIB_INCLUDE_DIR) (Required is
exact version "1.2.11")
Call Stack (most recent call first):
E:/Program Files/CMake/share/cmake-3.9/Modules/FindPackageHandleStandardArgs.cmake:377
(_FPHSA_FAILURE_MESSAGE)
E:/Program Files/CMake/share/cmake-3.9/Modules/FindZLIB.cmake:112
(FIND_PACKAGE_HANDLE_STANDARD_ARGS)
Core/ThirdParty/zlib/CMakeLists.txt:6 (find_package)

On Tue, Aug 29, 2017 at 9:33 AM, Brad King <brad.king at kitware.com> wrote:
> On 08/29/2017 10:27 AM, Robert Dailey wrote:
>> I'm relying on the two variables above to control this behavior, but
>> CMAKE_INSTALL_PREFIX doesn't work well for both purposes.
>
> Use CMAKE_PREFIX_PATH, not CMAKE_INSTALL_PREFIX, to control
> the set of prefixes that find commands search.
>
> -Brad


More information about the cmake-developers mailing list