Skip to content

Commit abfdadd

Browse files
[CMake] Look for clang-format only if UR_FORMAT_CPP_STYLE is on
1 parent 2161dfa commit abfdadd

File tree

2 files changed

+13
-11
lines changed

2 files changed

+13
-11
lines changed

CMakeLists.txt

Lines changed: 7 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -130,18 +130,15 @@ if(UR_USE_MSAN)
130130
add_sanitizer_flag(memory)
131131
endif()
132132

133-
find_program(CLANG_FORMAT NAMES clang-format-15 clang-format-15.0 clang-format)
134-
135-
set(CLANG_FORMAT_REQUIRED "15.0")
133+
# Check if clang-format (in correct version) is available for Cpp code formatting.
134+
if(UR_FORMAT_CPP_STYLE)
135+
find_program(CLANG_FORMAT NAMES clang-format-15 clang-format-15.0 clang-format)
136136

137-
if(CLANG_FORMAT)
138-
get_program_version_major_minor(${CLANG_FORMAT} CLANG_FORMAT_VERSION)
139-
message(STATUS "Found clang-format: ${CLANG_FORMAT} (version: ${CLANG_FORMAT_VERSION})")
140-
endif()
137+
if(CLANG_FORMAT)
138+
get_program_version_major_minor(${CLANG_FORMAT} CLANG_FORMAT_VERSION)
139+
message(STATUS "Found clang-format: ${CLANG_FORMAT} (version: ${CLANG_FORMAT_VERSION})")
141140

142-
# Check if the correct version of clang-format is available
143-
if(UR_FORMAT_CPP_STYLE)
144-
if(CLANG_FORMAT)
141+
set(CLANG_FORMAT_REQUIRED "15.0")
145142
if(NOT (CLANG_FORMAT_VERSION VERSION_EQUAL CLANG_FORMAT_REQUIRED))
146143
message(FATAL_ERROR "required clang-format version is ${CLANG_FORMAT_REQUIRED}")
147144
endif()

README.md

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@
1414
- [Weekly tags](#weekly-tags)
1515
3. [Third-Party tools](#third-party-tools)
1616
4. [Building](#building)
17+
- [Requirements](#requirements)
1718
- [Windows](#windows)
1819
- [Linux](#linux)
1920
- [CMake standard options](#cmake-standard-options)
@@ -71,9 +72,13 @@ Tools can be acquired via instructions in [third_party](/third_party/README.md).
7172

7273
## Building
7374

74-
Requirements:
75+
### Requirements
76+
77+
Required packages:
7578
- C++ compiler with C++17 support
7679
- [CMake](https://cmake.org/) >= 3.14.0
80+
81+
For development and contributions:
7782
- clang-format-15.0 (can be installed with `python -m pip install clang-format==15.0.7`)
7883

7984
### Windows

0 commit comments

Comments
 (0)