# How to find all the include folders for a target for a static analyzer?

**URL:** https://discourse.cmake.org/t/how-to-find-all-the-include-folders-for-a-target-for-a-static-analyzer/3233
**Category:** Code
**Created:** [April 28, 2021, 10:40pm UTC](https://discourse.cmake.org/t/how-to-find-all-the-include-folders-for-a-target-for-a-static-analyzer/3233 "2021-04-28T22:40:53Z")
**Posts on this page:** 1
**Showing post:** 3

<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: [April 29, 2021, 10:21am UTC](https://discourse.cmake.org/t/how-to-find-all-the-include-folders-for-a-target-for-a-static-analyzer/3233/3 "2021-04-29T10:21:07Z")

</div>

The `INCLUDE_DIRECTORIES` property at configure time is just the set added explicitly via `target_include_directories` (and maybe `include_directories`, though that may just be stored on the directory and not gathered until generate time). At generate time, the set of linked libraries is finally known and usage requirements from the targets that are linked may be looked up and expanded (with, e.g., platform detection genexes expanded too). It’s not something you can query at configure time, so your `add_custom_command` is one way to do it properly.

You might be able to use [`CMAKE_EXPORT_COMPILE_COMMANDS`](https://cmake.org/cmake/help/latest/variable/CMAKE_EXPORT_COMPILE_COMMANDS.html) to generate `compile_commands.json` and have cppcheck use that instead.

---

_[View the full topic](https://discourse.cmake.org/t/how-to-find-all-the-include-folders-for-a-target-for-a-static-analyzer/3233)._
