Consider the FLTK library. After building, this library provides only the configuration file without version support(i.e. FLTKConfig.cmake
only).
However, in my project I would like to using this library with the minimum version specified(i.e. find_package(FLTK <verion>)
). Obviously, such a request will fail.
Therefore, I plan to develop a find module for my project. Inside the module, I will have to search for the configuration file, in a similar way:
#MyProj/cmake/Modules/FindFLTK.cmake
unset(FLTK_FIND_VERSION_COMPLETE)
find_package(FLTK CONFIG)
find_package_handle_standard_args(FLTK CONFIG_MODE)
To be honest, it looks bad because we forget the FLTK_FIND_VERSION_COMPLETE
variable so that the search is performed without taking into account the requested version, since we want to check it ourselves.
Unfortunately, that the documentation does not guarantee that forgetting just this variable is enough, there are many other package interface variables exists.
What is the most idiomatic correct way to solve the described problem? At a minimum, the trick of forgetting a variable does not look right, since it is not documented.
I’m new to CMake. So comments from experienced users are welcome.
Of course, we are talking about modern cmake (3.29 and higher)