Let’s say that I want to do something like this:
find_package(pkg REQUIRED COMPONENTS x y z)
However, the components that I need depend on what version of pkg
I get, because (for example) the maintainers have shuffled things around between versions, or perhaps they only recently split their package into multiple components.
I don’t want to force a specific version of pkg
in my find_package()
call, because my users expect to be able to use my software in a wide range of environments.
How can I find out what version(s) of pkg
are available before I do the find_package()
call? Should my CMakeLists.txt run cmake as a COMMAND to do a test configuration that runs find_package(pkg QUIET)
, and then use the discovered version information to call the main find_package(pkg COMPONENTS ...)
with the version-specific list of components?