1
0
mirror of https://github.com/CLIUtils/CLI11.git synced 2025-05-01 13:13:53 +00:00

Adding clang tidy details

This commit is contained in:
Henry Fredrick Schreiner 2017-05-31 10:44:09 -04:00
parent 101c926dac
commit 44f43bd621
3 changed files with 39 additions and 6 deletions

7
.clang-tidy Normal file
View File

@ -0,0 +1,7 @@
#Checks: '*,-clang-analyzer-alpha.*'
Checks: '-*,google-readability-casting,llvm-namespace-comment,performance-unnecessary-value-param,llvm-include-order,misc-throw-by-value-catch-by-reference,readability-container-size-empty,google-runtime-references,modernize*'
HeaderFilterRegex: '.*hpp'
CheckOptions:
- key: readability-braces-around-statements.ShortStatementLines
value: '1'

View File

@ -22,6 +22,24 @@ else()
endif() endif()
if(CMAKE_VERSION VERSION_GREATER 3.6)
# Add clang-tidy if available
option(CLANG_TIDY_FIX "Perform fixes for Clang-Tidy (resets to OFF)" OFF)
find_program(
CLANG_TIDY_EXE
NAMES "clang-tidy"
DOC "Path to clang-tidy executable"
)
if(CLANG_TIDY_EXE)
if(CLANG_TIDY_FIX)
set(DO_CLANG_TIDY "${CLANG_TIDY_EXE}" "-fix")
else()
set(DO_CLANG_TIDY "${CLANG_TIDY_EXE}")
endif()
endif()
endif()
if(CMAKE_BUILD_TYPE STREQUAL Coverage) if(CMAKE_BUILD_TYPE STREQUAL Coverage)
include(CodeCoverage) include(CodeCoverage)
@ -64,3 +82,4 @@ if(CLI_EXAMPLES)
add_subdirectory(examples) add_subdirectory(examples)
endif() endif()
set(CLANG_TIDY_FIX OFF CACHE BOOL "Perform fixes for Clang-Tidy (resets to OFF)" FORCE)

View File

@ -1,8 +1,15 @@
add_executable(try try.cpp ${CLI_headers}) function(add_cli_exe T)
target_link_libraries(try PUBLIC CLI11) add_executable(${T} ${ARGN} ${CLI_headers})
target_link_libraries(${T} PUBLIC CLI11)
add_executable(try1 try1.cpp ${CLI_headers}) if(CLANG_TIDY_EXE)
target_link_libraries(try1 PUBLIC CLI11) set_target_properties(
${T} PROPERTIES
CXX_CLANG_TIDY "${DO_CLANG_TIDY}"
)
endif()
endfunction()
add_executable(try2 try2.cpp ${CLI_headers}) add_cli_exe(try try.cpp)
target_link_libraries(try2 PUBLIC CLI11) add_cli_exe(try1 try1.cpp)
add_cli_exe(try2 try2.cpp)