(running CMake 3.30.2)
I’m on macOS, and I have a call to find_library
that looks like so, inside a CMake find module FindMoltenVK.cmake:
find_library(
MoltenVK_LIBRARY
NAMES MoltenVK
HINTS ${PC_MoltenVK_LIBRARY_DIRS}
DOC "MoltenVK location"
NO_SYSTEM_ENVIRONMENT_PATH
NO_CMAKE_SYSTEM_PATH
NO_PACKAGE_ROOT_PATH
)
The idea is that I basically only want CMake to search paths I’ve added to the CMake prefix path for this particular library.
I am trying to debug the paths searched to verify that the appropriate areas are being searched, but I’m seeing the following puzzling output when generating with --debug-find
:
CMake Debug Log at cmake/finders/FindMoltenVK.cmake:102 (find_library):
find_library called with the following settings:
VAR: MoltenVK_LIBRARY
NAMES: "MoltenVK"
Documentation: MoltenVK location
Framework
Only Search Frameworks: 0
Search Frameworks Last: 0
Search Frameworks First: 1
AppBundle
Only Search AppBundle: 0
Search AppBundle Last: 0
Search AppBundle First: 1
CMAKE_FIND_USE_CMAKE_PATH: 1
CMAKE_FIND_USE_CMAKE_ENVIRONMENT_PATH: 1
CMAKE_FIND_USE_SYSTEM_ENVIRONMENT_PATH: 0
CMAKE_FIND_USE_CMAKE_SYSTEM_PATH: 0
CMAKE_FIND_USE_INSTALL_PREFIX: 1
find_library considered the following locations:
The item was found at
/part/of/my/cmake/prefix/path/deps/lib/libMoltenVK.dylib
CMake is finding the library where I intend it to be found, but I have no debug output to confirm that only the right locations are being searched.
find_path
output, on the other hand, is working correctly with --debug-find
, and showing me the following:
find_path considered the following locations:
/part/of/my/cmake/prefix/path/deps/include/MoltenVK.framework/Headers/MoltenVK.h
/part/of/my/cmake/prefix/path/deps/MoltenVK.framework/Headers/MoltenVK.h
/part/of/my/cmake/prefix/path/deps/include/MoltenVK.h
/part/of/my/cmake/prefix/path/deps/MoltenVK.h
/part/of/my/cmake/prefix/path/deps/include/MoltenVK/MoltenVK.h
/part/of/my/cmake/prefix/path/deps/MoltenVK/MoltenVK.h
(ignore that MoltenVK doesn’t actually ship a header by this name; I’m just showing that I’m getting correct debug output here).
I’m invoking find_path
the same way I’m invoking find_library
, like so:
find_path(
MoltenVK_INCLUDE_DIR
NAMES MoltenVK.h MoltenVK/MoltenVK.h
HINTS ${PC_MoltenVK_INCLUDE_DIRS}
DOC "MoltenVK include directory"
NO_SYSTEM_ENVIRONMENT_PATH
NO_CMAKE_SYSTEM_PATH
NO_PACKAGE_ROOT_PATH
)
I’m being sure to clear my CMake cache (and in fact removing the whole build directory between generations); does anyone know why find_library
is refusing to enumerate the paths it is searching?