mirror of
https://github.com/mpusz/mp-units.git
synced 2025-06-24 16:51:33 +02:00
build: additional options added to clang-tidy command and clang-tidy-18 hardcoded as an executable to use
This commit is contained in:
@ -3,6 +3,7 @@ Checks: '
|
||||
-abseil-*,
|
||||
-altera-*,
|
||||
-cert-dcl37-c,
|
||||
-cert-dcl21-cpp,
|
||||
-cert-dcl50-cpp,
|
||||
-cert-dcl51-cpp,
|
||||
-cert-dcl58-cpp,
|
||||
|
@ -48,6 +48,7 @@ if(${projectPrefix}DEV_IWYU)
|
||||
|
||||
include(include-what-you-use)
|
||||
enable_iwyu(
|
||||
REQUIRED
|
||||
MAPPING_FILE "${PROJECT_SOURCE_DIR}/.mp-units.imp"
|
||||
NO_FORWARD_DECLARATIONS QUOTED_INCLUDES_FIRST
|
||||
MAX_LINE_LENGTH 120
|
||||
@ -55,7 +56,7 @@ if(${projectPrefix}DEV_IWYU)
|
||||
)
|
||||
elseif(${projectPrefix}DEV_CLANG_TIDY)
|
||||
include(static_analysis)
|
||||
enable_clang_tidy()
|
||||
enable_clang_tidy(PROGRAM clang-tidy-18 REQUIRED)
|
||||
else()
|
||||
# set restrictive compilation warnings
|
||||
# (some gcc warnings are not recognized by IWYU which is based on clang)
|
||||
|
@ -22,14 +22,59 @@
|
||||
|
||||
cmake_minimum_required(VERSION 3.5)
|
||||
|
||||
macro(enable_clang_tidy)
|
||||
find_program(clang_tidy_cmd NAMES "clang-tidy")
|
||||
if(NOT clang_tidy_cmd)
|
||||
message(WARNING "clang-tidy not found!")
|
||||
else()
|
||||
#
|
||||
# enable_clang_tidy([PROGRAM] # clang-tidy by default
|
||||
# [QUIET] [REQUIRED])
|
||||
#
|
||||
function(enable_clang_tidy)
|
||||
set(_options QUIET REQUIRED)
|
||||
set(_one_value_args PROGRAM)
|
||||
set(_multi_value_args)
|
||||
cmake_parse_arguments(PARSE_ARGV 0 _enable_clang_tidy "${_options}" "${_one_value_args}" "${_multi_value_args}")
|
||||
|
||||
# validate and process arguments
|
||||
if(_enable_clang_tidy_UNPARSED_ARGUMENTS)
|
||||
message(FATAL_ERROR "Invalid arguments '${_enable_clang_tidy_UNPARSED_ARGUMENTS}'")
|
||||
endif()
|
||||
|
||||
if(_enable_clang_tidy_KEYWORDS_MISSING_VALUES)
|
||||
message(FATAL_ERROR "No value provided for '${_enable_clang_tidy_KEYWORDS_MISSING_VALUES}'")
|
||||
endif()
|
||||
|
||||
if(NOT _enable_iwyu_QUIET)
|
||||
message(STATUS "Enabling clang-tidy${log_postfix}")
|
||||
endif()
|
||||
|
||||
if(${_enable_clang_tidy_REQUIRED})
|
||||
set(_error_log_level FATAL_ERROR)
|
||||
elseif(NOT _enable_clang_tidy_QUIET)
|
||||
set(_error_log_level STATUS)
|
||||
endif()
|
||||
|
||||
if(NOT DEFINED _enable_clang_tidy_PROGRAM)
|
||||
set(_enable_clang_tidy_PROGRAM clang-tidy)
|
||||
endif()
|
||||
|
||||
find_program(_clang_tidy_path ${_enable_clang_tidy_PROGRAM})
|
||||
if(_clang_tidy_path)
|
||||
if(NOT _enable_clang_tidy_QUIET)
|
||||
message(STATUS " Executable: ${_clang_tidy_path}")
|
||||
endif()
|
||||
if(NOT EXISTS "${CMAKE_SOURCE_DIR}/.clang-tidy")
|
||||
message(FATAL_ERROR "'${CMAKE_SOURCE_DIR}/.clang-tidy' configuration file not found!")
|
||||
endif()
|
||||
set(CMAKE_CXX_CLANG_TIDY "${clang_tidy_cmd}")
|
||||
set(CMAKE_CXX_CLANG_TIDY "${clang_tidy_cmd}" PARENT_SCOPE)
|
||||
else()
|
||||
if(DEFINED _error_log_level)
|
||||
message(${_error_log_level} " '${_enable_clang_tidy_PROGRAM}' executable was not found")
|
||||
endif()
|
||||
if(NOT _enable_iwyu_QUIET)
|
||||
message(STATUS "Enabling clang-tidy${log_postfix} - failed")
|
||||
endif()
|
||||
return()
|
||||
endif()
|
||||
endmacro()
|
||||
|
||||
if(NOT _enable_iwyu_QUIET)
|
||||
message(STATUS "Enabling clang-tidy${log_postfix} - done")
|
||||
endif()
|
||||
endfunction()
|
||||
|
Reference in New Issue
Block a user