From 7e22d302ad126dbb0cd2cd58ddf2aac915012fd7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Paul=20Lie=CC=81tar?= Date: Thu, 30 Jan 2020 20:31:20 +0000 Subject: [PATCH] Don't use our own loop to find clang-format find_program can do that for us. Additionally that loop was resetting the CLANG_FORMAT every time ninja was run, making it impossible to pass a specific -DCLANG_FORMAT=... to cmake. I've tried version 6 to 8 and formatting remains stable. clang 9 is when it breaks down because of AfterCaseLabel. --- CMakeLists.txt | 14 +++----------- 1 file changed, 3 insertions(+), 11 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 5ccce1a..076717c 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -29,10 +29,10 @@ endmacro() macro(clangformat_targets) # The clang-format tool is installed under a variety of different names. Try - # to find a sensible one. Only look for 6.0 and 7.0 versions explicitly - we - # don't know whether our clang-format file will work with newer versions of the + # to find a sensible one. Only look for versions 6 to 8 explicitly - we don't + # know whether our clang-format file will work with newer versions of the # tool - set(CLANG_FORMAT_NAMES + find_program(CLANG_FORMAT NAMES clang-format-8 clang-format-7.0 clang-format-6.0 @@ -40,14 +40,6 @@ macro(clangformat_targets) clang-format60 clang-format) - # Loop over each of the possible names of clang-format and try to find one. - set(CLANG_FORMAT CLANG_FORMAT-NOTFOUND) - foreach (NAME IN ITEMS ${CLANG_FORMAT_NAMES}) - if (${CLANG_FORMAT} STREQUAL "CLANG_FORMAT-NOTFOUND") - find_program(CLANG_FORMAT ${NAME}) - endif () - endforeach() - # If we've found a clang-format tool, generate a target for it, otherwise emit # a warning. if (${CLANG_FORMAT} STREQUAL "CLANG_FORMAT-NOTFOUND")