summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorlittleblack111 <littleblack11111@gmail.com>2025-06-22 11:05:28 +0800
committerlittleblack111 <littleblack11111@gmail.com>2025-06-22 11:05:28 +0800
commit7a4ffacb0094bc9c19202dea26f5e246002d5509 (patch)
treea46f5a30b9b01d826cb084a0ca1f5c33d0477fb7
parent45cb2b703a080b7b791781bdb76ff557753652a4 (diff)
cmake: fix clang-format and clang-tidy
-rw-r--r--CMakeLists.txt13
-rw-r--r--Makefile7
2 files changed, 18 insertions, 2 deletions
diff --git a/CMakeLists.txt b/CMakeLists.txt
index 639fe3e..a493396 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -23,9 +23,22 @@ find_package(PkgConfig REQUIRED)
pkg_check_modules(FTXUI REQUIRED IMPORTED_TARGET ftxui)
file(GLOB_RECURSE SOURCES CONFIGURE_DEPENDS "src/*.cpp")
+file(GLOB_RECURSE HEADERS CONFIGURE_DEPENDS "src/*.hpp" "include/*.hpp")
add_executable(${PROJECT_NAME} ${SOURCES})
+add_custom_target(
+ clang-format
+ COMMAND clang-format -i ${SOURCES} ${HEADERS}
+ COMMENT "clang-format"
+ VERBATIM)
+
+add_custom_target(
+ clang-tidy
+ COMMAND clang-tidy -fix-errors ${SOURCES} -- ${CMAKE_CXX_FLAGS}
+ COMMENT "clang-tidy"
+ VERBATIM)
+
target_compile_features(${PROJECT_NAME} PRIVATE cxx_std_26)
add_compile_options(-Wall -Wextra -Wpedantic -Wconversion -Wsign-conversion
diff --git a/Makefile b/Makefile
index 3abc4f2..65fa99e 100644
--- a/Makefile
+++ b/Makefile
@@ -24,7 +24,10 @@ install:
uninstall:
xargs rm < ./build/install_manifest.txt
-format:
- find src -name "*.cpp" -o -name "*.hpp" | xargs clang-format -i
+clang-format:
+ cmake --build ./build --target clang-format
+
+clang-tidy:
+ cmake --build ./build --target clang-tidy
.PHONY: stub release debug clean all install uninstall format