TMP / added REQUIRED to find_program; cmake is now detected by pre-commit.py; fixed makefile problem

This commit is contained in:
2023-03-09 21:34:08 +01:00
parent 854d3d3308
commit 15d41b60bd
4 changed files with 58 additions and 36 deletions

View File

@ -1,5 +1,5 @@
if (DEV_MODE)
find_program(clang_tidy_EXECUTABLE NAMES clang-tidy-13 clang-tidy)
find_program(clang_tidy_EXECUTABLE NAMES clang-tidy-13 clang-tidy REQUIRED)
find_package(Python3 COMPONENTS Interpreter REQUIRED)
# Setup clang-tidy
@ -15,27 +15,42 @@ if (DEV_MODE)
# Display the marker for pre-commit.py at build time
add_custom_target(clang_tidy_marker ALL
COMMAND ${CMAKE_COMMAND} -E echo
"Clang-tidy is enabled (this is a marker for pre-commit.py)")
"Clang-tidy is enabled. This is a marker for pre-commit.py")
# Notify pre-commit.py about CMAKE_BINARY_DIR
# Notify pre-commit.py about CMake settings
execute_process(COMMAND ${Python3_EXECUTABLE} ${tools}/pre-commit.py
set-build-root -- "${CMAKE_BINARY_DIR}"
RESULT_VARIABLE set_build_root_RESULT)
set-build-info -- "${CMAKE_COMMAND}" "${CMAKE_BINARY_DIR}"
RESULT_VARIABLE set_build_info_RESULT)
if(${set_build_root_RESULT})
message(FATAL_ERROR "pre-commit.py set-build-root failed")
if(${set_build_info_RESULT})
message(FATAL_ERROR "pre-commit.py set-build-info failed")
endif()
# Setup pre-commit git hook
if (IS_DIRECTORY "${CMAKE_SOURCE_DIR}/.git/hooks")
if (NOT EXISTS "${CMAKE_SOURCE_DIR}/.git/hooks/pre-commit")
file(WRITE "${CMAKE_SOURCE_DIR}/.git/hooks/pre-commit"
set(pre_commit_hook "${CMAKE_SOURCE_DIR}/.git/hooks/pre-commit")
if (NOT EXISTS "${pre_commit_hook}")
file(WRITE "${pre_commit_hook}"
"#!/bin/sh\n"
"# Progressia autogenerated pre-commit hook\n"
"# You may modify this hook freely "
"(just make sure the checks run)\n"
"/bin/env python3 ${CMAKE_SOURCE_DIR}/tools/pre-commit.py run")
if (${CMAKE_VERSION} VERSION_LESS "3.19.0")
if (${CMAKE_HOST_UNIX})
execute_process(COMMAND chmod "+x" "${pre_commit_hook}"
RESULT_VARIABLE chmod_RESULT)
if (${chmod_RESULT})
message(FATAL_ERROR "Could not make git pre-commit hook executable")
endif()
endif()
else()
file(CHMOD "${pre_commit_hook}"
PERMISSIONS OWNER_EXECUTE GROUP_EXECUTE WORLD_EXECUTE)
endif()
endif()
unset(pre_commit_hook)
endif()
endif()

View File

@ -1,8 +1,11 @@
Checks: "-*,\
clang-analyzer-*,\
cppcoreguidelines-*,\
modernize-*,\
performance-*,\
readability-*,\
clang-diagnostic-*"
#Checks: "-*,\
# clang-analyzer-*,\
# cppcoreguidelines-*,\
# modernize-*,\
# performance-*,\
# readability-*,\
# clang-diagnostic-*"
# OH SO TEMPORARY
# im gonna be mad BIG TIME if this makes it to a public repo
Checks: "-*,clang-analyzer-webkit.NoUncountedMemberChecker"