2020-03-08 20:17:49 +00:00
# This file configures static analysis tools that can be integrated to the build process
2020-03-11 23:16:05 +00:00
option ( ENABLE_CLANG_TIDY "Use 'clang-tidy' static analyzer if present" OFF )
2020-03-08 20:17:49 +00:00
if ( ENABLE_CLANG_TIDY )
if ( ${ CMAKE_VERSION } VERSION_LESS "3.6.0" )
message ( FATAL_ERROR "clang-tidy requires CMake version at least 3.6." )
endif ( )
2020-09-17 10:32:16 +00:00
find_program ( CLANG_TIDY_PATH NAMES "clang-tidy" "clang-tidy-11" "clang-tidy-10" "clang-tidy-9" "clang-tidy-8" )
2020-03-08 20:17:49 +00:00
if ( CLANG_TIDY_PATH )
message ( STATUS "Using clang-tidy: ${CLANG_TIDY_PATH}. The checks will be run during build process. See the .clang-tidy file at the root directory to configure the checks." )
set ( USE_CLANG_TIDY 1 )
2020-04-03 15:14:31 +00:00
# The variable CMAKE_CXX_CLANG_TIDY will be set inside src and base directories with non third-party code.
2020-03-08 20:17:49 +00:00
# set (CMAKE_CXX_CLANG_TIDY "${CLANG_TIDY_PATH}")
2020-08-14 15:44:04 +00:00
elseif ( FAIL_ON_UNSUPPORTED_OPTIONS_COMBINATION )
message ( FATAL_ERROR "clang-tidy is not found" )
2020-03-08 20:17:49 +00:00
else ( )
2020-08-14 15:44:04 +00:00
message ( STATUS "clang-tidy is not found. This is normal - the tool is only used for static code analysis and isn't essential for the build." )
2020-03-08 20:17:49 +00:00
endif ( )
endif ( )