mirror of
https://github.com/slsdetectorgroup/slsDetectorPackage.git
synced 2025-06-05 17:40:40 +02:00
check for clang-format version
This commit is contained in:
parent
8ff9b0cdac
commit
31ec3c8cf7
@ -1,6 +1,4 @@
|
|||||||
# Find Clang format
|
# Find Clang format
|
||||||
#
|
|
||||||
#
|
|
||||||
if(NOT ClangFormat_BIN_NAME)
|
if(NOT ClangFormat_BIN_NAME)
|
||||||
set(ClangFormat_BIN_NAME clang-format)
|
set(ClangFormat_BIN_NAME clang-format)
|
||||||
endif()
|
endif()
|
||||||
@ -27,8 +25,15 @@ mark_as_advanced(
|
|||||||
ClangFormat_BIN)
|
ClangFormat_BIN)
|
||||||
|
|
||||||
if(ClangFormat_FOUND)
|
if(ClangFormat_FOUND)
|
||||||
# A CMake script to find all source files and setup clang-format targets for them
|
EXEC_PROGRAM(${ClangFormat_BIN} ${CMAKE_CURRENT_SOURCE_DIR} ARGS --version OUTPUT_VARIABLE CLANG_VERSION)
|
||||||
include(clang-format)
|
STRING(REGEX REPLACE ".*([0-9]+)\\.[0-9]+\\.[0-9]+.*" "\\1" CLANG_MAJOR_VERSION ${CLANG_VERSION})
|
||||||
|
if((${CLANG_MAJOR_VERSION} GREATER "9") OR (${CLANG_MAJOR_VERSION} EQUAL "9"))
|
||||||
|
# A CMake script to find all source files and setup clang-format targets for them
|
||||||
|
message(STATUS "found clang-format ${CLANG_VERSION} adding formatting targets")
|
||||||
|
include(clang-format)
|
||||||
|
else()
|
||||||
|
message(STATUS "clang-format version ${CLANG_VERSION} found but need at least 9. Not setting up format targets")
|
||||||
|
endif()
|
||||||
else()
|
else()
|
||||||
message("clang-format not found. Not setting up format targets")
|
message(STATUS "clang-format not found. Not setting up format targets")
|
||||||
endif()
|
endif()
|
||||||
|
@ -17,6 +17,7 @@ foreach (SOURCE_FILE ${ALL_SOURCE_FILES})
|
|||||||
endforeach ()
|
endforeach ()
|
||||||
endforeach ()
|
endforeach ()
|
||||||
|
|
||||||
|
#target for formatting soruce files
|
||||||
add_custom_target(format
|
add_custom_target(format
|
||||||
COMMENT "Running clang-format to change files"
|
COMMENT "Running clang-format to change files"
|
||||||
COMMAND ${ClangFormat_BIN}
|
COMMAND ${ClangFormat_BIN}
|
||||||
@ -25,7 +26,8 @@ add_custom_target(format
|
|||||||
${ALL_SOURCE_FILES}
|
${ALL_SOURCE_FILES}
|
||||||
)
|
)
|
||||||
|
|
||||||
#put back i
|
|
||||||
|
#target to check format on source files
|
||||||
add_custom_target(format-check
|
add_custom_target(format-check
|
||||||
COMMENT "Checking clang-format changes"
|
COMMENT "Checking clang-format changes"
|
||||||
# Use ! to negate the result for correct output
|
# Use ! to negate the result for correct output
|
||||||
@ -37,7 +39,7 @@ add_custom_target(format-check
|
|||||||
| grep -q "replacement offset"
|
| grep -q "replacement offset"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
# debug to check which file will be formatted
|
||||||
add_custom_target(
|
add_custom_target(
|
||||||
listformatfiles
|
listformatfiles
|
||||||
COMMAND
|
COMMAND
|
||||||
|
Loading…
x
Reference in New Issue
Block a user