Skip to content

Commit

Permalink
cmake: warning instead of error if clang-format not found
Browse files Browse the repository at this point in the history
clang-format is used to format an auto generated file which is rarely
used. The whole compilation process failed if clang-format not
found. This is too restrictive.
  • Loading branch information
caballa committed Oct 10, 2022
1 parent 6494e33 commit ed76603
Showing 1 changed file with 16 additions and 7 deletions.
23 changes: 16 additions & 7 deletions tools/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
add_definitions(-D__STDC_CONSTANT_MACROS)
add_definitions(-D__STDC_LIMIT_MACROS)
find_program(CLANG-FORMAT NAMES clang-format clang-format-mp-12 clang-format-12 REQUIRED)
find_program(CLANG-FORMAT NAMES clang-format clang-format-mp-14 clang-format-14)

set(LLVM_LINK_COMPONENTS
irreader
Expand Down Expand Up @@ -34,12 +34,21 @@ endif()
message(${CMAKE_CURRENT_SOURCE_DIR})

if (CMAKE_C_COMPILER_ID MATCHES Clang)
add_custom_command(
OUTPUT libc.spec.c
COMMAND libcSpecGen
COMMAND ${CLANG-FORMAT} -i libc.spec.c
DEPENDS libcSpecGen
)
if (NOT CLANG-FORMAT)
message(WARNING "clang-format not found: libc.spec.c cannot be formatted")
add_custom_command(
OUTPUT libc.spec.c
COMMAND libcSpecGen
DEPENDS libcSpecGen
)
else()
add_custom_command(
OUTPUT libc.spec.c
COMMAND libcSpecGen
COMMAND ${CLANG-FORMAT} -i libc.spec.c
DEPENDS libcSpecGen
)
endif()

add_library(LibcSpec-64 OBJECT libc.spec.c)
target_compile_options(LibcSpec-64 BEFORE PRIVATE -emit-llvm)
Expand Down

0 comments on commit ed76603

Please sign in to comment.