Is FindPackageHandleStandardArgs included by default in find modules?

I’m using the following find module in my project:

find_path(LIBVTERM_INCLUDE_DIR vterm.h)
find_library(LIBVTERM_LIBRARY vterm)

find_package_handle_standard_args(libvterm
  REQUIRED_VARS LIBVTERM_INCLUDE_DIR LIBVTERM_LIBRARY)

add_library(libvterm INTERFACE)
target_include_directories(libvterm SYSTEM BEFORE INTERFACE INTERFACE ${LIBVTERM_INCLUDE_DIR})
target_link_libraries(libvterm INTERFACE ${LIBVTERM_LIBRARY})

I then realized that this works just fine even if I don’t include FindPackageHandleStandardArgs. This begs the question: is including FindPackageHandleStandardArgs ever necessary?

Yes, it is necessary to include the module before using it.

In your case, by chance, FindPackageHandleStandardArgs was already included by some other module. But to ensure the correct behavior of your module in all situations, including FindPackageHandleStandardArgs is required.

Wow, so find modules does not have their own scope. I see. OK, thanks for the help.

CMake commands are always global.

And modules don’t have, by default, a scope for variables or policies, but it is easy to manage one with the commands block() and endblock().