Skip to content

Instantly share code, notes, and snippets.

@sleepdefic1t
Last active May 4, 2024 10:54
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")
@Sapd
Copy link

Sapd commented May 13, 2021

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

Also handy

@mcandre
Copy link

mcandre commented Jan 19, 2024

As with all things Homebrew, the source path has changed over the years.

$ ln -s /opt/homebrew/Cellar/llvm/17.0.6_1/bin/clang-format /opt/homebrew/bin/clang-format
$ ln -s /opt/homebrew/Cellar/llvm/17.0.6_1/bin/clang-tidy /opt/homebrew/bin/clang-tidy

brew --prefix should be used to generate the base directory, currently /opt/homebrew.

Naturally, the exact LLVM version will change frequently.

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