Commit 44f43bd62144b8c08fb52c6fac75e4fa82f3e457

Authored by Henry Fredrick Schreiner
1 parent 101c926d

Adding clang tidy details

.clang-tidy 0 → 100644
  1 +#Checks: '*,-clang-analyzer-alpha.*'
  2 +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*'
  3 +HeaderFilterRegex: '.*hpp'
  4 +CheckOptions:
  5 +- key: readability-braces-around-statements.ShortStatementLines
  6 + value: '1'
  7 +
CMakeLists.txt
@@ -22,6 +22,24 @@ else() @@ -22,6 +22,24 @@ else()
22 endif() 22 endif()
23 23
24 24
  25 +if(CMAKE_VERSION VERSION_GREATER 3.6)
  26 +# Add clang-tidy if available
  27 + option(CLANG_TIDY_FIX "Perform fixes for Clang-Tidy (resets to OFF)" OFF)
  28 + find_program(
  29 + CLANG_TIDY_EXE
  30 + NAMES "clang-tidy"
  31 + DOC "Path to clang-tidy executable"
  32 + )
  33 +
  34 + if(CLANG_TIDY_EXE)
  35 + if(CLANG_TIDY_FIX)
  36 + set(DO_CLANG_TIDY "${CLANG_TIDY_EXE}" "-fix")
  37 + else()
  38 + set(DO_CLANG_TIDY "${CLANG_TIDY_EXE}")
  39 + endif()
  40 + endif()
  41 +endif()
  42 +
25 43
26 if(CMAKE_BUILD_TYPE STREQUAL Coverage) 44 if(CMAKE_BUILD_TYPE STREQUAL Coverage)
27 include(CodeCoverage) 45 include(CodeCoverage)
@@ -64,3 +82,4 @@ if(CLI_EXAMPLES) @@ -64,3 +82,4 @@ if(CLI_EXAMPLES)
64 add_subdirectory(examples) 82 add_subdirectory(examples)
65 endif() 83 endif()
66 84
  85 +set(CLANG_TIDY_FIX OFF CACHE BOOL "Perform fixes for Clang-Tidy (resets to OFF)" FORCE)
examples/CMakeLists.txt
1 -add_executable(try try.cpp ${CLI_headers})  
2 -target_link_libraries(try PUBLIC CLI11) 1 +function(add_cli_exe T)
  2 + add_executable(${T} ${ARGN} ${CLI_headers})
  3 + target_link_libraries(${T} PUBLIC CLI11)
3 4
4 -add_executable(try1 try1.cpp ${CLI_headers})  
5 -target_link_libraries(try1 PUBLIC CLI11) 5 + if(CLANG_TIDY_EXE)
  6 + set_target_properties(
  7 + ${T} PROPERTIES
  8 + CXX_CLANG_TIDY "${DO_CLANG_TIDY}"
  9 + )
  10 + endif()
  11 +endfunction()
6 12
7 -add_executable(try2 try2.cpp ${CLI_headers})  
8 -target_link_libraries(try2 PUBLIC CLI11) 13 +add_cli_exe(try try.cpp)
  14 +add_cli_exe(try1 try1.cpp)
  15 +add_cli_exe(try2 try2.cpp)