build: add clang-format target

Through the power of CMake itself, we can format our files

Signed-off-by: Seth Flynn <getchoo@tuta.io>
(cherry picked from commit 686ad72e03)
This commit is contained in:
Seth Flynn 2025-12-22 04:11:12 -05:00 committed by Trial97
parent c806f61a02
commit 3b23752f73
No known key found for this signature in database
GPG key ID: 55EF5DA53DB36318

View file

@ -1667,3 +1667,15 @@ if(WIN32 OR (UNIX AND APPLE))
COMPONENT bundle
)
endif()
find_program(CLANG_FORMAT clang-format OPTIONAL)
if(CLANG_FORMAT)
message(STATUS "Creating clang-format target")
add_custom_target(
clang-format
COMMAND ${CLANG_FORMAT} -i --style=file:${CMAKE_SOURCE_DIR}/.clang-format ${LOGIC_SOURCES} ${LAUNCHER_SOURCES} ${PRISMUPDATER_SOURCES} ${LINKEXE_SOURCES} ${PRECOMPILED_HEADERS}
WORKING_DIRECTORY ${PROJECT_SOURCE_DIR}
)
else()
message(WARNING "Unable to find `clang-format`. Not creating custom target")
endif()