# How to prevent clang-tidy to check sources added with FetchContents?

**URL:** https://discourse.cmake.org/t/how-to-prevent-clang-tidy-to-check-sources-added-with-fetchcontents/2871
**Category:** Code
**Created:** [March 2, 2021, 6:26pm UTC](https://discourse.cmake.org/t/how-to-prevent-clang-tidy-to-check-sources-added-with-fetchcontents/2871 "2021-03-02T18:26:09Z")
**Posts on this page:** 4
**Page:** 2

<div class="post-metadata">

### Author: ![ClausKlein](https://discourse.cmake.org/user_avatar/discourse.cmake.org/clausklein/32/352_2.png) [@ClausKlein](https://discourse.cmake.org/u/ClausKlein)
#### Post date: [May 3, 2024, 5:00am UTC](https://discourse.cmake.org/t/how-to-prevent-clang-tidy-to-check-sources-added-with-fetchcontents/2871/21 "2024-05-03T05:00:10Z")

</div>

**But with a big difference:** Normally you will compile the extern sources under `build/_deps`. But you must not check them!

Simply use i.e.: `run-clang-tidy -p build sources examples tests`

---

<div class="post-metadata">

### Author: ![hsattler](https://discourse.cmake.org/letter_avatar_proxy/v4/letter/h/59ef9b/32.png) [@hsattler](https://discourse.cmake.org/u/hsattler)
#### Post date: [May 3, 2024, 5:08am UTC](https://discourse.cmake.org/t/how-to-prevent-clang-tidy-to-check-sources-added-with-fetchcontents/2871/22 "2024-05-03T05:08:06Z")

</div>

Just dump a .clang-tidy file in the \_deps directory that disables all tests.

Works with whatever way you invoke clang-tidy and even in IDEs.

I also do that for the build folder to exclude generated files.

---

<div class="post-metadata">

### Author: ![anthonya](https://discourse.cmake.org/user_avatar/discourse.cmake.org/anthonya/32/4128_2.png) [@anthonya](https://discourse.cmake.org/u/anthonya)
#### Post date: [May 3, 2024, 6:44am UTC](https://discourse.cmake.org/t/how-to-prevent-clang-tidy-to-check-sources-added-with-fetchcontents/2871/23 "2024-05-03T06:44:38Z")

</div>

That’s a clever idea, how did you integrate that with cmake?

---

<div class="post-metadata">

### Author: ![ClausKlein](https://discourse.cmake.org/user_avatar/discourse.cmake.org/clausklein/32/352_2.png) [@ClausKlein](https://discourse.cmake.org/u/ClausKlein)
#### Post date: [May 3, 2024, 8:48am UTC](https://discourse.cmake.org/t/how-to-prevent-clang-tidy-to-check-sources-added-with-fetchcontents/2871/24 "2024-05-03T08:48:08Z")

</div>

**NOTE** : You have to remove or override all existing `.clang-tidy` files too!

[Previous page](https://discourse.cmake.org/t/how-to-prevent-clang-tidy-to-check-sources-added-with-fetchcontents/2871.md?page=1)
