# Rules for locating find-module

**URL:** <https://discourse.cmake.org/t/rules-for-locating-find-module/7340>\
**Category:** Code\
**Created:** [January 27, 2023, 11:22pm UTC](https://discourse.cmake.org/t/rules-for-locating-find-module/7340 "2023-01-27T23:22:54Z")\
**Posts on this page:** 7\
**Page:** 1

<div class="post-metadata">

**Author:** ![tomoreilly](https://discourse.cmake.org/letter_avatar_proxy/v4/letter/t/439d5e/32.png) [@tomoreilly](https://discourse.cmake.org/u/tomoreilly)\
**Post date:** [January 27, 2023, 11:22pm UTC](https://discourse.cmake.org/t/rules-for-locating-find-module/7340/1 "2023-01-27T23:22:54Z")

</div>

What “rules” does cmake follow when locating a find-module? [This document says](https://cmake.org/cmake/help/book/mastering-cmake/chapter/Finding%20Packages.html) " In Module mode, the command searches for a [`find module`](https://cmake.org/cmake/help/latest/manual/cmake-developer.7.html#manual:cmake-developer(7)): a file named `Find<Package>.cmake`."

For example:

find\_package(PROJ MODULE\_ONLY)

I.e. the package is “PROJ” (not “Proj”). I have a find-module named “FindProj.cmake”. I do NOT have a find-module called “FindPROJ.cmake”.

cmake 3.22.1 seems to look only for FindPROJ.cmake, and cannot find it, printing this message:

```auto
CMake Warning at CMakeLists.txt:33 (find_package):
  By not providing "FindPROJ.cmake" in CMAKE_MODULE_PATH this project has
  asked CMake to find a package configuration file provided by "PROJ", but
  CMake did not find one.

```

But cmake 3.25 finds and runs “FindProj.cmake” - it seems this version of cmake doesn’t care about case of the find-module’s \<Package\> component. Can someone point to a document that clearly specifies how cmake locates a find-module for a specified package?  
Thanks!

---

<div class="post-metadata">

**Author:** ![jtxa](https://discourse.cmake.org/user_avatar/discourse.cmake.org/jtxa/32/1535_2.png) [@jtxa](https://discourse.cmake.org/u/jtxa)\
**Post date:** [January 27, 2023, 11:39pm UTC](https://discourse.cmake.org/t/rules-for-locating-find-module/7340/2 "2023-01-27T23:39:08Z")

</div>

The [find\_package](https://cmake.org/cmake/help/latest/command/find_package.html) itself describes the search steps. Although a case insensitivity is only specified for Config mode.

Calling cmake with `--debug-find-pkg=PROJ` maybe gives you some more insights.

---

<div class="post-metadata">

**Author:** ![tomoreilly](https://discourse.cmake.org/letter_avatar_proxy/v4/letter/t/439d5e/32.png) [@tomoreilly](https://discourse.cmake.org/u/tomoreilly)\
**Post date:** [January 28, 2023, 12:14am UTC](https://discourse.cmake.org/t/rules-for-locating-find-module/7340/3 "2023-01-28T00:14:17Z")

</div>

Thanks for the suggestion - when I call cmake with --debug-find-pkg=PROJ, the output contains entries like this:

```auto
CMake Debug Log at build-utils/FindPROJ.cmake:34 (FIND_LIBRARY):
  find_library(PROJ_LIBRARY) added replacement path /opt/local/lib/ to
  PATH_SUFFIXES for architecture suffix '64'

```

But there is no file called “build-utils/FindPROJ.cmake” - there is build-utils/FindProj.cmake. Very confusing…

---

<div class="post-metadata">

**Author:** ![ben.boeckel](https://discourse.cmake.org/letter_avatar_proxy/v4/letter/b/ea5d25/32.png) [@ben.boeckel](https://discourse.cmake.org/u/ben.boeckel)\
**Post date:** [January 29, 2023, 1:18pm UTC](https://discourse.cmake.org/t/rules-for-locating-find-module/7340/4 "2023-01-29T13:18:40Z")

</div>

> [@tomoreilly](#):
>
> But there is no file called “build-utils/FindPROJ.cmake” - there is build-utils/FindProj.cmake. Very confusing…

Is this on macOS? The filesystem is case-insensitive (by default and convention), so `find_package(PROJ)` will pick up `FindProj.cmake`, but the package “name” will be what was requested.

---

<div class="post-metadata">

**Author:** ![tomoreilly](https://discourse.cmake.org/letter_avatar_proxy/v4/letter/t/439d5e/32.png) [@tomoreilly](https://discourse.cmake.org/u/tomoreilly)\
**Post date:** [February 1, 2023, 4:52pm UTC](https://discourse.cmake.org/t/rules-for-locating-find-module/7340/5 "2023-02-01T16:52:42Z")

</div>

I see the different behavior on two ubuntu systems running different cmake versions, not MacOS. But that’s an interesting point @ben.boeckel - and a bit annoying that cmake’s search algorithm would behave in a subtle but significant way depending on OS.

---

<div class="post-metadata">

**Author:** ![jtxa](https://discourse.cmake.org/user_avatar/discourse.cmake.org/jtxa/32/1535_2.png) [@jtxa](https://discourse.cmake.org/u/jtxa)\
**Post date:** [February 1, 2023, 7:13pm UTC](https://discourse.cmake.org/t/rules-for-locating-find-module/7340/6 "2023-02-01T19:13:48Z")

</div>

Debian 12 also has CMake 3.25.1 installed, and I cannot confirm such problem.  
Please check on which filesystem you are running. FAT or VM shared folders might also be case-insensitive, regardless of the OS.

---

<div class="post-metadata">

**Author:** ![ben.boeckel](https://discourse.cmake.org/letter_avatar_proxy/v4/letter/b/ea5d25/32.png) [@ben.boeckel](https://discourse.cmake.org/u/ben.boeckel)\
**Post date:** [February 1, 2023, 9:48pm UTC](https://discourse.cmake.org/t/rules-for-locating-find-module/7340/7 "2023-02-01T21:48:30Z")

</div>

> [@tomoreilly](#):
>
> and a bit annoying that cmake’s search algorithm would behave in a subtle but significant way depending on OS.

Filesystems that are case-insensitive were a bad decision IMO. It should have been a UI thing, but here we are.
