-
Notifications
You must be signed in to change notification settings - Fork 15
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add clang-format to CMake (not working now)
- Loading branch information
Showing
1 changed file
with
21 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
# Find clang-format | ||
find_program(CLANG_FORMAT_BIN clang-format) | ||
|
||
if (NOT CLANG_FORMAT_BIN) | ||
message(FATAL_ERROR "clang-format not found!") | ||
endif() | ||
|
||
# List of file extensions to format | ||
set(FORMAT_EXTENSIONS cpp h hpp c) | ||
|
||
# Recursively find all files with the specified extensions | ||
file(GLOB_RECURSE ALL_SOURCE_FILES | ||
${PROJECT_SOURCE_DIR}/*.[ch]pp | ||
${PROJECT_SOURCE_DIR}/*.[ch]) | ||
|
||
# Define clang-format target | ||
add_custom_target(clang-format | ||
COMMAND ${CLANG_FORMAT_BIN} -i ${ALL_SOURCE_FILES} | ||
WORKING_DIRECTORY ${PROJECT_SOURCE_DIR} | ||
COMMENT "Running clang-format" | ||
) |