Rules for locating find-module

What “rules” does cmake follow when locating a find-module? This document says " In Module mode, the command searches for a find module: 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:

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!

The find_package 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.

1 Like

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

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…

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.

1 Like

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.

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.

1 Like

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

2 Likes