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

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

  option(ENABLE_CLANG_TIDY "default is off" OFF)

    find_program(CLANG_TIDY clang-tidy)
          "${CLANG_TIDY}\;-config={Checks: '"
          .... <more flags> ... )
           set_target_properties(${my_target} PROPERTIES CXX_CLANG_TIDY

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

This behaviour is documented on for this property, see

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.

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 ?

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