# \--debug-find not showing paths searched for find\_library

**URL:** <https://discourse.cmake.org/t/debug-find-not-showing-paths-searched-for-find-library/11687>\
**Category:** Code\
**Created:** [September 15, 2024, 3:54am UTC](https://discourse.cmake.org/t/debug-find-not-showing-paths-searched-for-find-library/11687 "2024-09-15T03:54:40Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![jcm](https://discourse.cmake.org/letter_avatar_proxy/v4/letter/j/58f4c7/32.png) [@jcm](https://discourse.cmake.org/u/jcm)\
**Post date:** [September 15, 2024, 3:54am UTC](https://discourse.cmake.org/t/debug-find-not-showing-paths-searched-for-find-library/11687/1 "2024-09-15T03:54:40Z")

</div>

(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:

```auto
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`:

```auto
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:

```auto
  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:

```auto
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?

---

<div class="post-metadata">

**Author:** ![craig.scott](https://discourse.cmake.org/user_avatar/discourse.cmake.org/craig.scott/32/20_2.png) [@craig.scott](https://discourse.cmake.org/u/craig.scott)\
**Post date:** [September 15, 2024, 6:02am UTC](https://discourse.cmake.org/t/debug-find-not-showing-paths-searched-for-find-library/11687/2 "2024-09-15T06:02:35Z")

</div>

Perhaps it found the library at the first path it checked. From what I recall, `--debug-find` might only show the paths up to the point it found what it was looking for, so if the first path contains the library, there won’t be any paths printed.

---

<div class="post-metadata">

**Author:** ![jcm](https://discourse.cmake.org/letter_avatar_proxy/v4/letter/j/58f4c7/32.png) [@jcm](https://discourse.cmake.org/u/jcm)\
**Post date:** [September 15, 2024, 4:05pm UTC](https://discourse.cmake.org/t/debug-find-not-showing-paths-searched-for-find-library/11687/3 "2024-09-15T16:05:14Z")

</div>

That seems to have been it. I guess by just removing the library from the intended spot I can check what all is being enumerated. Thanks for the help.
