make clang-format custom targets in CMake similar to the ones in GNU make

This commit is contained in:
Axel Kohlmeyer
2021-08-23 18:36:44 -04:00
parent 6b6e63f77f
commit d44edeb32e
2 changed files with 9 additions and 4 deletions

View File

@ -55,9 +55,7 @@ add_subdirectory(force-styles)
find_package(ClangFormat 8.0)
if(ClangFormat_FOUND)
set(UNITTEST_SOURCES)
file(GLOB_RECURSE UNITTEST_SOURCES *.cpp *.h)
add_custom_target(format-tests
COMMAND ${ClangFormat_EXECUTABLE} --verbose -i -style=file ${UNITTEST_SOURCES}
DEPENDS ${UNITTEST_SOURCES})
COMMAND ${ClangFormat_EXECUTABLE} --verbose -i -style=file */*.cpp */*.h
WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR})
endif()