Skip to content

Commit fb05e58

Browse files
CMake: disable format validation if clang-format fails to run
1 parent fe88154 commit fb05e58

File tree

1 file changed

+8
-0
lines changed

1 file changed

+8
-0
lines changed

BuildTools/CMakeLists.txt

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,14 @@ if(CMAKE_HOST_SYSTEM_NAME STREQUAL "Windows")
66
set(CLANG_FORMAT_EXECUTABLE "${CMAKE_CURRENT_SOURCE_DIR}/FormatValidation/clang-format_10.0.0.exe" CACHE INTERNAL "clang-format executable path")
77
elseif(CMAKE_HOST_SYSTEM_NAME STREQUAL "Linux")
88
set(CLANG_FORMAT_EXECUTABLE "${CMAKE_CURRENT_SOURCE_DIR}/FormatValidation/clang-format_linux_10.0.0" CACHE INTERNAL "clang-format executable path")
9+
execute_process(
10+
COMMAND "${CLANG_FORMAT_EXECUTABLE}" --version
11+
RESULT_VARIABLE CLANG_FORMAT_EXIT_CODE
12+
)
13+
if (NOT CLANG_FORMAT_EXIT_CODE EQUAL 0)
14+
message(WARNING "${CLANG_FORMAT_EXECUTABLE} failed to run. Format validation will be disabled.")
15+
unset(CLANG_FORMAT_EXECUTABLE CACHE)
16+
endif()
917
elseif(CMAKE_HOST_SYSTEM_NAME STREQUAL "Darwin")
1018
set(CLANG_FORMAT_EXECUTABLE "${CMAKE_CURRENT_SOURCE_DIR}/FormatValidation/clang-format_mac_10.0.0" CACHE INTERNAL "clang-format executable path")
1119
endif()

0 commit comments

Comments
 (0)