Skip to content

Correct way to set up clang-tidy with CMake and Visual Studio/MSVC? #61994

@dograt

Description

@dograt

Hi all, I have tracked down a few threads online that seem to imply that something like this should work using Visual Studio with CMake.

find_program(
      CLANG_TIDY_COMMAND
      NAMES
         clang-tidy
      NO_CACHE
)
cmake
      set(MY_CXX_CLANG_TIDY "${CLANG_TIDY_COMMAND};--extra-arg-before=--driver-mode=cl;--extra-arg=--std=c++17;--format-style=file" CACHE INTERNAL "")

set_target_properties(${TARGET_NAME} 
    PROPERTIES 
        CXX_CLANG_TIDY "${MY_CXX_CLANG_TIDY}"

However, the above setup isn't working for me. I'm getting a bunch of clang-diagnostic errors, even though my code compiles and runs just fine when Clang-Tidy is disabled. I've also tried the command with no additional flags at all, and it gives me the same result.

Error	G13DA7946	use of undeclared identifier 'value' [clang-diagnostic-error]	
Error	G13DA7946	use of undeclared identifier 'value' [clang-diagnostic-error]	
Error	G13DA7946	use of undeclared identifier 'value' [clang-diagnostic-error]	
Error	G13DA7946	use of undeclared identifier 'value' [clang-diagnostic-error]	
Error	G13DA7946	use of undeclared identifier 'value' [clang-diagnostic-error]	

Any ideas on where I can start poking around to diagnose what is going on?

Metadata

Metadata

Assignees

No one assigned

    Labels

    clang-tidyplatform:windowsquestionA question, not bug report. Check out https://llvm.org/docs/GettingInvolved.html instead!

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions