The only variable that is still a must-define is the
<packageName>_FOUND
variable, which indicates thefind_package()
call was successful, and thefind_package()
command will ensure that is set unless the config file or Find module explicitly sets it to false.
Unless FetchContent_MakeAvailable
is setting that variable, that is not consistent with the results I’m seeing. I am setting up CMAKE_MODULE_PATH
to point at a repository of Find modules—used across my suite of projects—that mostly just FetchContent_Declare
and FetchContent_MakeAvailable
(and maybe apply some workarounds that haven’t been upstreamed yet). Then I just use find_package
and it works without complaint.
In short, avoid writing Find modules at all if you can
I’ve been planning to create my own “rails,” but this and other statements above makes me think I’m heading off in the wrong direction. That said, using FindModules is the only clean solution I’ve found to the problems outlined in this post.