Skip to content
This repository was archived by the owner on Mar 22, 2023. It is now read-only.

Commit 7e2a005

Browse files
author
Pawel Karczewski
committed
Make cpp-format targets always working
As cpp-format targets are always generated anyway, they should work even if CHECK_CPP_STYLE flag is disabled.
1 parent f1f199d commit 7e2a005

File tree

2 files changed

+8
-5
lines changed

2 files changed

+8
-5
lines changed

CMakeLists.txt

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -189,12 +189,15 @@ add_custom_target(copyright-format
189189
BSD-3-Clause -d)
190190

191191

192+
find_program(CLANG_FORMAT NAMES clang-format-9 clang-format-9.0 clang-format)
193+
set(CLANG_FORMAT_REQUIRED "9.0")
194+
if(CLANG_FORMAT)
195+
get_program_version_major_minor(${CLANG_FORMAT} CLANG_FORMAT_VERSION)
196+
message(STATUS "Found clang-format: ${CLANG_FORMAT} (version: ${CLANG_FORMAT_VERSION})")
197+
endif()
198+
192199
if(CHECK_CPP_STYLE)
193-
find_program(CLANG_FORMAT NAMES clang-format clang-format-9 clang-format-9.0)
194-
set(CLANG_FORMAT_REQUIRED "9.0")
195200
if(CLANG_FORMAT)
196-
get_program_version_major_minor(${CLANG_FORMAT} CLANG_FORMAT_VERSION)
197-
message(STATUS "Found clang-format: ${CLANG_FORMAT} (version: ${CLANG_FORMAT_VERSION})")
198201
if(NOT (CLANG_FORMAT_VERSION VERSION_EQUAL CLANG_FORMAT_REQUIRED))
199202
message(FATAL_ERROR "required clang-format version is ${CLANG_FORMAT_REQUIRED}")
200203
endif()

cmake/functions.cmake

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -99,7 +99,7 @@ endmacro()
9999
# instead.
100100
# ${name} must be unique.
101101
function(add_cppstyle name)
102-
if(NOT CLANG_FORMAT)
102+
if(NOT CLANG_FORMAT OR NOT (CLANG_FORMAT_VERSION VERSION_EQUAL CLANG_FORMAT_REQUIRED))
103103
return()
104104
endif()
105105

0 commit comments

Comments
 (0)