Skip to content

Commit

Permalink
Add clang-format CMake target
Browse files Browse the repository at this point in the history
  • Loading branch information
curlew committed Dec 5, 2024
1 parent 93c3cd7 commit 4189731
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 0 deletions.
1 change: 1 addition & 0 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ set(CMAKE_POLICY_DEFAULT_CMP0091 NEW)

project(bthief LANGUAGES CXX C)

include(cmake/clang_format.cmake)
include(FetchContent)

FetchContent_Declare(
Expand Down
7 changes: 7 additions & 0 deletions cmake/clang_format.cmake
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
find_program(CLANG_FORMAT NAMES clang-format)

if(CLANG_FORMAT)
file(GLOB_RECURSE CLANG_FORMAT_FILES src/*.cxx src/*.hxx)

add_custom_target(format COMMAND clang-format -i -style=file ${CLANG_FORMAT_FILES})
endif()

0 comments on commit 4189731

Please sign in to comment.