Skip to content

Instantly share code, notes, and snippets.

@sleepdefic1t
Last active September 30, 2024 11:09
Show Gist options
  • Save sleepdefic1t/e9bdb1a66b05aa043ab9a2ab6c929509 to your computer and use it in GitHub Desktop.
Save sleepdefic1t/e9bdb1a66b05aa043ab9a2ab6c929509 to your computer and use it in GitHub Desktop.
brew clang-tidy on macOS
brew install llvm
ln -s "/usr/local/opt/llvm/bin/clang-format" "/usr/local/bin/clang-format"
ln -s "/usr/local/opt/llvm/bin/clang-tidy" "/usr/local/bin/clang-tidy"

use cmake file

  find_program(CLANG_TIDY_BIN clang-tidy)
  find_program(RUN_CLANG_TIDY_BIN /usr/local/Cellar/llvm/10.0.0_3/share/clang/run-clang-tidy.py)
    list(APPEND RUN_CLANG_TIDY_BIN_ARGS
         -clang-tidy-binary ${CLANG_TIDY_BIN}
         -header-filter="\".*\\b(cpp-client/src)\""
         -checks=clan*,cert*,misc*,perf*,cppc*,read*,mode*,-cert-err58-cpp,-misc-noexcept-move-constructor,-cppcoreguidelines-*)

    add_custom_target(tidy
                      COMMAND ${RUN_CLANG_TIDY_BIN} ${RUN_CLANG_TIDY_BIN_ARGS}
                      COMMENT "running clang tidy")
@eXpl0it3r
Copy link

ln -s "$(brew --prefix llvm)/share/clang/run-clang-tidy.py" "/usr/local/bin/run-clang-tidy.py"

Also handy

Not sure when it changed, but on LLVM 19, it's:

ln -s "$(brew --prefix llvm)/bin/run-clang-tidy" "/usr/local/bin/run-clang-tidy"

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment