Skip to content

Instantly share code, notes, and snippets.

@balintkissdev
Created March 15, 2021 20:04
Show Gist options
  • Select an option

  • Save balintkissdev/d33a31dd257491cb08eb70977c1b4d1b to your computer and use it in GitHub Desktop.

Select an option

Save balintkissdev/d33a31dd257491cb08eb70977c1b4d1b to your computer and use it in GitHub Desktop.
Using clang-tidy from CMake
Checks: "bugprone-*,clang-diagnostic-*,clang-analyzer-*,modernize-*,performance-*,readability-*"
WarningsAsErrors: ""
HeaderFilterRegex: ""
CheckOptions:
- key: readability-identifier-naming.PrivateMemberSuffix
value: "_"
cmake_minimum_required(VERSION 3.6 FATAL_ERROR)
set(PROJECT_NAME MyProject)
project(${PROJECT_NAME} LANGUAGES CXX)
add_executable(${PROJECT_NAME} "")
find_program(
CLANG_TIDY_EXE
NAMES clang-tidy
)
if (CLANG_TIDY_EXE)
message(STATUS "clang-tidy found: ${CLANG_TIDY_EXE}")
set(DO_CLANG_TIDY
"${CLANG_TIDY_EXE}"
"--header-filter=src/*"
)
set_target_properties(${PROJECT_NAME} PROPERTIES CXX_CLANG_TIDY "${DO_CLANG_TIDY}")
else()
message(STATUS "clang-tidy not found.")
endif()
target_sources(${PROJECT_NAME}
PRIVATE
src/main.cpp
)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment