# cmake when generate Xcode project, clang-tidy command is missing

**URL:** https://discourse.cmake.org/t/cmake-when-generate-xcode-project-clang-tidy-command-is-missing/4115
**Category:** Usage
**Tags:** comp:clang, gen:xcode
**Created:** [September 19, 2021, 10:07pm UTC](https://discourse.cmake.org/t/cmake-when-generate-xcode-project-clang-tidy-command-is-missing/4115 "2021-09-19T22:07:52Z")
**Posts on this page:** 4
**Page:** 1

<div class="post-metadata">

### Author: ![zohar81](https://discourse.cmake.org/user_avatar/discourse.cmake.org/zohar81/32/2252_2.png) [@zohar81](https://discourse.cmake.org/u/zohar81)
#### Post date: [September 19, 2021, 10:07pm UTC](https://discourse.cmake.org/t/cmake-when-generate-xcode-project-clang-tidy-command-is-missing/4115/1 "2021-09-19T22:07:52Z")

</div>

Hi, I’ve added clang-tidy capability to my command line that will be set upon activation. before running it, I’ve made sure that my setup has clang-tidy installed.

here’s the CMake code

```auto
  option(ENABLE_CLANG_TIDY "default is off" OFF)

  if(ENABLE_CLANG_TIDY)
    find_program(CLANG_TIDY clang-tidy)
    if(CLANG_TIDY)
      string(
        CONCAT
          clang_tidy_cmd
          "${CLANG_TIDY}\;-config={Checks: '"
          "*,"
          "-google-runtime-references,"
          .... <more flags> ... )
           set_target_properties(${my_target} PROPERTIES CXX_CLANG_TIDY
                                                      ${clang_tidy_cmd})

However, when I use the Xcode generator (`-G Xcode`) it's omitting the clang-tidy configuration from the compilation, and when setting CMake to generate simple makefile, the clang-tidy reappears in the compilation line of each cpp file.

Any idea why ? is it a bug ? my CMake version is 3.20.2
```

---

<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: [September 20, 2021, 5:24am UTC](https://discourse.cmake.org/t/cmake-when-generate-xcode-project-clang-tidy-command-is-missing/4115/2 "2021-09-20T05:24:08Z")

</div>

This behaviour is documented on for this property, see [https://cmake.org/cmake/help/latest/prop\_tgt/LANG\_CLANG\_TIDY.html](https://cmake.org/cmake/help/latest/prop_tgt/LANG_CLANG_TIDY.html)

For IDEs like Xcode or Visual Studio, a separate configuration is needed.

Hint: instead of configuring clang-tidy checks completely with command line options, use a .clang-tidy file in the top-level source directory. This can then also be used by IDEs.

---

<div class="post-metadata">

### Author: ![zohar81](https://discourse.cmake.org/user_avatar/discourse.cmake.org/zohar81/32/2252_2.png) [@zohar81](https://discourse.cmake.org/u/zohar81)
#### Post date: [September 21, 2021, 5:27am UTC](https://discourse.cmake.org/t/cmake-when-generate-xcode-project-clang-tidy-command-is-missing/4115/3 "2021-09-21T05:27:16Z")

</div>

Hi and thanks for the help @hsattler. Unfortunately, I couldn’t figure out exactly how to make CMake generated Xcode project to run the .clang-tidy file you suggested. The documentation page you provided discuss about the CXX\_CLANG\_TIDY param but doesn’t mention anything about lack of support in IDEs

Once I’ve created .clang-tidy file for the whole project, how should I make cmake/Xcode use it ?

---

<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: [September 21, 2021, 5:37am UTC](https://discourse.cmake.org/t/cmake-when-generate-xcode-project-clang-tidy-command-is-missing/4115/4 "2021-09-21T05:37:52Z")

</div>

I do not know Xcode itself, just Visual Studio which has integrated support for it.
