CMake Gurus,
I have a question about maintaining module-mode FindPackage.cmake files. To wit, the documentation for find_package says:
The
Find<PackageName>.cmakefile is not typically provided by the package itself. Rather, it is normally provided by something external to the package, such as the operating system, CMake itself, or even the project from which thefind_package()command was called. Being externally provided, Find Modules tend to be heuristic in nature and are susceptible to becoming out-of-date. They typically search for certain libraries, files and other package artifacts.
So, my question involves a package (ESMF) that does nicely provide a FindESMF.cmake file in its source code for its users, but does not install it. (It is a large and established enough library that converting to CMake would be a daunting task, so Config mode is probably a long-term dream/goal.)
Recently, I realized that this file does indeed change at times, and I’d missed that and moved to update the version I carried in my code. But then I had a thought: “Well, the library itself could install the file when you install the library into, say, prefix/lib/cmake/esmf” or whatever. Luckily I build ESMF in a way where I can–“outside” of their make system–do a simple “copy this file to directory foo” and then have my code know to set CMAKE_MODULE_PATH to that directory to find it. This way, I get any updates for free and if at some point FindESMF.cmake changes in such a way that it isn’t backwardsly compatible, I’m guaranteed to have the right file for that version of the library. (Might never happen…but it’s not impossible.)
Now the official advice does say it’s not really up to the package itself to provide it, but is there any “unofficial” advice for packages like this with a FindPackage.cmake file provided as a courtesy by the package? I had thought of making a PR to the package saying they could install it for us…but then the question is where? Should a module-mode FindPackage.cmake file go in prefix/lib/cmake/package/? prefix/share/package/?
Thanks for any help,
Matt
Note: Obviously the “dream scenario” for me is FindESMF.cmake is built into CMake itself, but ESMF is niche enough that it probably doesn’t warrant that…though FindNetCDF.cmake isn’t built in either…)