mirror of
https://github.com/mpusz/mp-units.git
synced 2025-06-25 01:01: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:
@ -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