Skip to content

Commit

Permalink
build: add clang-format cmake target (#272)
Browse files Browse the repository at this point in the history
  • Loading branch information
FlayaN authored Apr 18, 2024
1 parent 39cb189 commit 1edc187
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 0 deletions.
12 changes: 12 additions & 0 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -120,6 +120,18 @@ target_sources(
${CMAKE_CURRENT_BINARY_DIR}/cmake/FeatureVersions.h
)

# #######################################################################################################################
# # clang-format
# #######################################################################################################################

find_program(CLANG_FORMAT_PATH clang-format)
if(CLANG_FORMAT_PATH)
add_custom_target(FORMAT_CODE
COMMAND ${CLANG_FORMAT_PATH} -i -style=file ${CPP_SOURCES};${HLSL_FILES}
COMMENT "Running clang format for cpp and hlsl files"
)
endif()

# #######################################################################################################################
# # Automatic deployment
# #######################################################################################################################
Expand Down
4 changes: 4 additions & 0 deletions cmake/AddCXXFiles.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,10 @@ function(add_cxx_files TARGET)

set(HLSL_FILES ${HLSL_FILES} PARENT_SCOPE)

list(APPEND CPP_SOURCES ${HEADER_FILES})
list(APPEND CPP_SOURCES ${SOURCE_FILES})
set(CPP_SOURCES ${CPP_SOURCES} PARENT_SCOPE)

source_group(TREE ${CMAKE_CURRENT_SOURCE_DIR}/
PREFIX "HLSL Files"
FILES ${HLSL_FILES})
Expand Down

0 comments on commit 1edc187

Please sign in to comment.