If xxlib is not the modules listed here are part of the CMake distribution.
I want to write a FindXXlib.cmake to find the library.
For the begin, should it use
find_package (like FindXXlib_1.cmake)?
Or directly use
find_path (like FindXXlib_2.cmake) ?
First off, the preferred approach would be for xxlib to provide an
xxlibConfig.cmake file as part of its distribution or installation, as package config files are preferred to find modules. If you can add it to the library or convince its maintainers to add it, that is the best route to take.
Only if that is not an option does it make sense to create a find module. If you find you need to go the find module route, it means xxlib doesn’t provide a package config file, so in that case there is nothing for
find_package(xxlib) to find (that command looks for find modules and package config files only). A find module for xxlib effectively defines the package xxlib for CMake, so it makes no sense for it to