Commit c7ff438b830d8ebeac684f3f8ad3229587c88373

James Le Cuirot 2023-09-10T13:00:31

cmake: Only use pkg-config for .pc files, not for building binaries Using `pkg_check_modules(FOO IMPORTED_TARGET foo)` with `target_link_libraries()` leads to `INTERFACE_LINK_LIBRARIES` in the resulting export file having `\$<LINK_ONLY:PkgConfig::FOO>` rather than the currently expected `\$<LINK_ONLY:FOO::FOO>`, leading to breakage. This can be worked around like so: target_link_libraries(UseFoo PUBLIC "$<BUILD_INTERFACE:PkgConfig::FOO>" INTERFACE "$<INSTALL_INTERFACE:FOO::FOO>" ) However, following some discussion, it is preferable to primarily use find modules as before and only use `pkg_check_modules` for correctly populating the .pc file. Also move `find_package()` calls earlier so that builds fail faster when dependencies are missing.