I am trying to use an external library that has recently started providing Config.cmake files for itself. Before this, cmake was providing a Find.cmake module for this library. The library provides an imported target that I can use in my cmake files, which is desired. The module Find does not.
Is there anyway I can tell cmake to ignore the Find.cmake file and only use the config scripts, so I can rely on using the imported target in my target_link_libraries() call?
Interestingly, when I provide a HINT to the find_package() call, cmake pulls in the imported target. Providing that same path in the CMAKE_PREFIX_PATH but omitting it from the find_package() does not pull in the target.
I’m not sure if this is a bug in cmake or a bug in the Find.cmake file.
You can pass CONFIG to find_package to prefer the config file (it will use FindFoo if possible; NO_MODULE can be used instead to force usage of a config file).
Which package started doing this? We can update FindFoo.cmake in CMake to:
chain off to the config file if available
provide a compatible (ish?) imported target when it does the work.