If find_package not support some library

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_library and find_path (like FindXXlib_2.cmake) ?

FindXXlib_1.cmake

find_package(xxlib REQUIRED)

find_library(XX_LIB
    NAMES XX
)
find_path(XX_INCLUDE_DIR
    NAMES XX.h
)

FindXXlib_2.cmake


find_library(XX_LIB
    NAMES XX
)
find_path(XX_INCLUDE_DIR
    NAMES XX.h
)

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 find_package(xxlib)