@tchaikov
Latest commit 9f9bd85 Jan 12, 2023 History
* revert use pkg_search_module(.. IMPORTED_TARGET ..) changes
* pass QUIET to pkg_check_modules(). as FPHSA also prints out
  message when checking the required variables. and
  pkg_check_modules() only provides hints to `find_*()` functions.
* use `pkg_check_module()` instead of `pkg_search_module()`,
  as we don't "search" for a module in some candidates, we just
  want to check for a single one. `pkg_check_module()` reflects
  our intention here better.

before the change, `pkg_check_modules(..., IMPORTED_TARGET)` is
used in find modules. but per the discussion at
https://gitlab.kitware.com/cmake/cmake/-/merge_requests/8037,

quote from CMake maintainer Brad King's comment:

> Actually, using `pkg_check_modules` with `IMPORTED_TARGET` is not
> a good pattern for find modules.  Instead, the `pkg_check_modules`
> results should only be used as hints to the main `find_*` code
> path, and then the results should be added as an imported target
> explicitly.  Otherwise features like `CMAKE_FIND_ROOT_PATH` do
> not work correctly.

and recent fixes also echo Brad's comment:

- 64ec338
- 3db15b5

so this is not a recommended practice.

after this change, the change series of
"use pkg_search_module(.. IMPORTED_TARGET ..) ..." are partially
reverted, see f572538 for an
instance of this series. but the following changes are preserved:

- bump the required cmake version to 3.13: because some succeeding
  CMake related changes could depend on the required CMake version.
- do not set <Package>_LIBRARIES or <Package>_INCLUDE_DIRS unless
  the <Package> is found: this change is still relevant.

Signed-off-by: Kefu Chai <tchaikov@gmail.com>
1 contributor

Users who have contributed to this file