mirror of
https://github.com/SFML/SFML.git
synced 2024-11-24 20:31:05 +08:00
Check for minimum required clang-tidy version
This commit is contained in:
parent
75642ef7aa
commit
ad416ab531
@ -534,7 +534,10 @@ endif()
|
||||
|
||||
sfml_set_option(CLANG_FORMAT_EXECUTABLE clang-format STRING "Override clang-format executable, requires version 12, 13, or 14")
|
||||
add_custom_target(format
|
||||
COMMAND ${CMAKE_COMMAND} "-DCLANG_FORMAT_EXECUTABLE=${CLANG_FORMAT_EXECUTABLE}" -P ./cmake/Format.cmake
|
||||
WORKING_DIRECTORY "${PROJECT_SOURCE_DIR}" VERBATIM)
|
||||
COMMAND ${CMAKE_COMMAND} -DCLANG_FORMAT_EXECUTABLE=${CLANG_FORMAT_EXECUTABLE} -P ./cmake/Format.cmake
|
||||
WORKING_DIRECTORY ${PROJECT_SOURCE_DIR} VERBATIM)
|
||||
|
||||
add_custom_target(tidy COMMAND run-clang-tidy -p ${PROJECT_BINARY_DIR} VERBATIM)
|
||||
sfml_set_option(CLANG_TIDY_EXECUTABLE clang-tidy STRING "Override clang-tidy executable, requires minimum version 12")
|
||||
add_custom_target(tidy
|
||||
COMMAND ${CMAKE_COMMAND} -DCLANG_TIDY_EXECUTABLE=${CLANG_TIDY_EXECUTABLE} -DPROJECT_BINARY_DIR=${PROJECT_BINARY_DIR} -P ./cmake/Tidy.cmake
|
||||
WORKING_DIRECTORY ${PROJECT_SOURCE_DIR} VERBATIM)
|
||||
|
23
cmake/Tidy.cmake
Normal file
23
cmake/Tidy.cmake
Normal file
@ -0,0 +1,23 @@
|
||||
# Check executable exists
|
||||
if(NOT EXISTS ${CLANG_TIDY_EXECUTABLE})
|
||||
find_program(CLANG_TIDY_EXEC_TEMP ${CLANG_TIDY_EXECUTABLE})
|
||||
if(CLANG_TIDY_EXEC_TEMP)
|
||||
set(CLANG_TIDY_EXECUTABLE ${CLANG_TIDY_EXEC_TEMP})
|
||||
unset(CLANG_TIDY_EXEC_TEMP)
|
||||
else()
|
||||
message(FATAL_ERROR "Unable to find clang-tidy executable: \"${CLANG_TIDY_EXECUTABLE}\"")
|
||||
endif()
|
||||
endif()
|
||||
|
||||
# Check executable version
|
||||
execute_process(COMMAND ${CLANG_TIDY_EXECUTABLE} --version OUTPUT_VARIABLE CLANG_TIDY_VERSION)
|
||||
string(REGEX MATCH "version ([0-9]+)" CLANG_TIDY_VERSION ${CLANG_TIDY_VERSION})
|
||||
unset(CLANG_TIDY_VERSION)
|
||||
if(CMAKE_MATCH_1 GREATER_EQUAL 12)
|
||||
message(STATUS "Using clang-tidy version ${CMAKE_MATCH_1}")
|
||||
else()
|
||||
message(FATAL_ERROR "clang-tidy version ${CMAKE_MATCH_1} is too low")
|
||||
endif()
|
||||
|
||||
# Run
|
||||
execute_process(COMMAND run-clang-tidy -clang-tidy-binary ${CLANG_TIDY_EXECUTABLE} -p ${PROJECT_BINARY_DIR})
|
Loading…
Reference in New Issue
Block a user