Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: add support for clang-tidy-cache #35

Draft
wants to merge 3 commits into
base: main
Choose a base branch
from
Draft
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
21 changes: 20 additions & 1 deletion src/StaticAnalyzers.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,26 @@ endmacro()

# Enable static analysis with clang-tidy
macro(enable_clang_tidy)
find_program(CLANGTIDY clang-tidy)
# https://github.com/ejfitzgerald/clang-tidy-cache
find_program(
CLANGTIDY_CACHE
NAMES "clang-tidy-cache"
"clang-tidy-cache-windows-amd64"
"clang-tidy-cache-linux-amd64"
"clang-tidy-cache-darwin-amd64")
if(CLANGTIDY_CACHE)
# use clang-tidy-cache if found
set($ENV{CLANG_TIDY_CACHE_BINARY} ${CLANGTIDY_CACHE})
set(CLANGTIDY
${CLANGTIDY_CACHE}
-p
"${CMAKE_CURRENT_BINARY_DIR}"
--export-fixes
"${CMAKE_CURRENT_BINARY_DIR}/clang_tidy_fixes.yaml")
else()
# otherwise use clang-tidy directly
find_program(CLANGTIDY clang-tidy)
endif()
if(CLANGTIDY)

# clang-tidy only works with clang when PCH is enabled
Expand Down