# PkgConfig: cflags must be usage requirements for \`IMPORTED\_TARGET\`s

**URL:** https://discourse.cmake.org/t/pkgconfig-cflags-must-be-usage-requirements-for-imported-target-s/15152
**Category:** Development
**Tags:** tool:cmake
**Created:** [September 4, 2025, 4:41pm UTC](https://discourse.cmake.org/t/pkgconfig-cflags-must-be-usage-requirements-for-imported-target-s/15152 "2025-09-04T16:41:41Z")
**Posts on this page:** 2
**Page:** 1

<div class="post-metadata">

### Author: ![skittishdev](https://discourse.cmake.org/user_avatar/discourse.cmake.org/skittishdev/32/5794_2.png) [@skittishdev](https://discourse.cmake.org/u/skittishdev)
#### Post date: [September 4, 2025, 4:41pm UTC](https://discourse.cmake.org/t/pkgconfig-cflags-must-be-usage-requirements-for-imported-target-s/15152/1 "2025-09-04T16:41:41Z")

</div>

Hi,

I recently discovered that when linking to a PkgConfig dependency, the cflags specified in the `.pc` file are not automatically added to the target compile command. I think it’d be fantastic to have cflags be usage requirements for `IMPORTED_TARGET`s (just like include dirs).

Please see detailed repro steps in this related issue here: [How to correctly generate compile\_commands.json for library dependency using PkgConfig?](https://discourse.cmake.org/t/how-to-correctly-generate-compile-commands-json-for-library-dependency-using-pkgconfig/15135)

---

<div class="post-metadata">

### Author: ![skittishdev](https://discourse.cmake.org/user_avatar/discourse.cmake.org/skittishdev/32/5794_2.png) [@skittishdev](https://discourse.cmake.org/u/skittishdev)
#### Post date: [September 4, 2025, 4:49pm UTC](https://discourse.cmake.org/t/pkgconfig-cflags-must-be-usage-requirements-for-imported-target-s/15152/2 "2025-09-04T16:49:37Z")

</div>

If I understand [this code](https://gitlab.kitware.com/cmake/cmake/-/blob/master/Modules/FindPkgConfig.cmake?ref_type=heads#L801-803) correctly, the `#{prefix}_CFLAGS_OTHER` property is already set on the target. Which makes me wonder if `#{prefix}_CFLAGS` was intentionally not set. If so, why?
