Create Imported Targets before or after find_package_handle_standard_args() call in Find modules?

Hello, CMake Team.

Based on the statistical results, it appears that most of the CMake’s built-in Find modules create Imported Targets after the find_package_handle_standard_args() call in Find modules.

  1. Before find_package_handle_standard_args() call:

  2. After find_package_handle_standard_args() call:

I’m curious about what are the benefits of this practice?

And is it generally recommended to create Imported Targets after the find_package_handle_standard_args() call in Find modules?

It is better to make the targets only if the package is actually found as a whole. This avoids “FOUND is false, but I still have targets?”. I’ll fix at least VTK’s FFMPEG module. Thanks.

Ah…FFMPEG is a bit special in that it has a lot wrapped up in functions. Splitting that out seems a bit more than a quick fix.