Add USE_CLANG_TIDY and CLANG_TIDY_TREAT_WARNINGS_AS_ERRORS options to cmake
This commit is contained in:
parent
d91a7358c0
commit
1cb1efab6e
@ -18,6 +18,8 @@ require_clang_version(4.0)
|
|||||||
option(BUILD_TESTING "build test cases" OFF)
|
option(BUILD_TESTING "build test cases" OFF)
|
||||||
option(CRYFS_UPDATE_CHECKS "let cryfs check for updates and security vulnerabilities" ON)
|
option(CRYFS_UPDATE_CHECKS "let cryfs check for updates and security vulnerabilities" ON)
|
||||||
option(DISABLE_OPENMP "allow building without OpenMP libraries. This will cause performance degradations." OFF)
|
option(DISABLE_OPENMP "allow building without OpenMP libraries. This will cause performance degradations." OFF)
|
||||||
|
option(USE_CLANG_TIDY "build with clang-tidy checks enabled" OFF)
|
||||||
|
option(CLANG_TIDY_WARNINGS_AS_ERRORS "treat clang-tidy warnings as errors" OFF)
|
||||||
|
|
||||||
if (MSVC)
|
if (MSVC)
|
||||||
option(DOKAN_PATH "Location of the Dokan library, e.g. C:\\Program Files\\Dokan\\DokanLibrary-1.1.0" "")
|
option(DOKAN_PATH "Location of the Dokan library, e.g. C:\\Program Files\\Dokan\\DokanLibrary-1.1.0" "")
|
||||||
|
@ -32,16 +32,22 @@ function(target_activate_cpp14 TARGET)
|
|||||||
endfunction(target_activate_cpp14)
|
endfunction(target_activate_cpp14)
|
||||||
|
|
||||||
# Find clang-tidy executable (for use in target_enable_style_warnings)
|
# Find clang-tidy executable (for use in target_enable_style_warnings)
|
||||||
find_program(
|
if (USE_CLANG_TIDY)
|
||||||
|
find_program(
|
||||||
CLANG_TIDY_EXE
|
CLANG_TIDY_EXE
|
||||||
NAMES "clang-tidy"
|
NAMES "clang-tidy"
|
||||||
DOC "Path to clang-tidy executable"
|
DOC "Path to clang-tidy executable"
|
||||||
)
|
)
|
||||||
if(NOT CLANG_TIDY_EXE)
|
if(NOT CLANG_TIDY_EXE)
|
||||||
message(WARNING "clang-tidy not found. Checks are disabled")
|
message(FATAL_ERROR "clang-tidy not found. Please install clang-tidy or run without -DUSE_CLANG_TIDY=on.")
|
||||||
else()
|
else()
|
||||||
message(STATUS "clang-tidy found: ${CLANG_TIDY_EXE}")
|
set(CLANG_TIDY_OPTIONS "-system-headers=0")
|
||||||
set(DO_CLANG_TIDY "${CLANG_TIDY_EXE}" "-system-headers=0")
|
if (CLANG_TIDY_WARNINGS_AS_ERRORS)
|
||||||
|
set(CLANG_TIDY_OPTIONS "${CLANG_TIDY_OPTIONS}" "-warnings-as-errors=*")
|
||||||
|
endif()
|
||||||
|
message(STATUS "Clang-tidy is enabled. Executable: ${CLANG_TIDY_EXE} Arguments: ${CLANG_TIDY_OPTIONS}")
|
||||||
|
set(CLANG_TIDY_CLI "${CLANG_TIDY_EXE}" "${CLANG_TIDY_OPTIONS}")
|
||||||
|
endif()
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
#################################################
|
#################################################
|
||||||
@ -57,10 +63,12 @@ function(target_enable_style_warnings TARGET)
|
|||||||
endif()
|
endif()
|
||||||
|
|
||||||
# Enable clang-tidy
|
# Enable clang-tidy
|
||||||
#set_target_properties(
|
if(USE_CLANG_TIDY)
|
||||||
# ${TARGET} PROPERTIES
|
set_target_properties(
|
||||||
# CXX_CLANG_TIDY "${DO_CLANG_TIDY}"
|
${TARGET} PROPERTIES
|
||||||
#)
|
CXX_CLANG_TIDY "${CLANG_TIDY_CLI}"
|
||||||
|
)
|
||||||
|
endif()
|
||||||
endfunction(target_enable_style_warnings)
|
endfunction(target_enable_style_warnings)
|
||||||
|
|
||||||
##################################################
|
##################################################
|
||||||
|
Loading…
x
Reference in New Issue
Block a user