# Create Imported Targets before or after find\_package\_handle\_standard\_args() call in Find modules?

**URL:** <https://discourse.cmake.org/t/create-imported-targets-before-or-after-find-package-handle-standard-args-call-in-find-modules/10092>\
**Category:** Code\
**Created:** [February 14, 2024, 5:47pm UTC](https://discourse.cmake.org/t/create-imported-targets-before-or-after-find-package-handle-standard-args-call-in-find-modules/10092 "2024-02-14T17:47:49Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![hwhsu1231](https://discourse.cmake.org/user_avatar/discourse.cmake.org/hwhsu1231/32/5358_2.png) [@hwhsu1231](https://discourse.cmake.org/u/hwhsu1231)\
**Post date:** [February 14, 2024, 5:47pm UTC](https://discourse.cmake.org/t/create-imported-targets-before-or-after-find-package-handle-standard-args-call-in-find-modules/10092/1 "2024-02-14T17:47:49Z")

</div>

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?

---

<div class="post-metadata">

**Author:** ![ben.boeckel](https://discourse.cmake.org/letter_avatar_proxy/v4/letter/b/ea5d25/32.png) [@ben.boeckel](https://discourse.cmake.org/u/ben.boeckel)\
**Post date:** [February 17, 2024, 5:02pm UTC](https://discourse.cmake.org/t/create-imported-targets-before-or-after-find-package-handle-standard-args-call-in-find-modules/10092/2 "2024-02-17T17:02:35Z")

</div>

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.

---

<div class="post-metadata">

**Author:** ![ben.boeckel](https://discourse.cmake.org/letter_avatar_proxy/v4/letter/b/ea5d25/32.png) [@ben.boeckel](https://discourse.cmake.org/u/ben.boeckel)\
**Post date:** [February 17, 2024, 5:03pm UTC](https://discourse.cmake.org/t/create-imported-targets-before-or-after-find-package-handle-standard-args-call-in-find-modules/10092/3 "2024-02-17T17:03:54Z")

</div>

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.
