From 81363283b45b9be1642d4ab2c8fab68340a1c8cd Mon Sep 17 00:00:00 2001 From: Lokomojo <2168418+Lokomojo@users.noreply.github.com> Date: Mon, 8 Dec 2025 18:52:32 +0000 Subject: [PATCH] Copy .clang-format to bin root to prevent upstream settings being used by mistake --- cmake/modules/HCT.cmake | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/cmake/modules/HCT.cmake b/cmake/modules/HCT.cmake index bce41f5ec0..f6ffe5d5e4 100644 --- a/cmake/modules/HCT.cmake +++ b/cmake/modules/HCT.cmake @@ -13,6 +13,16 @@ if (NOT CLANG_FORMAT_EXE) endif () endif () +# If an upstream folder contains a .clang-format, incorrect formatting may be +# applied which causes the build to fail. Create a copy in the build dir +# to ensure the right formatting is applied. +get_filename_component(HLSL_SRC_ROOT "${CMAKE_CURRENT_LIST_DIR}/../.." ABSOLUTE) +get_filename_component(HLSL_BIN_ROOT "${CMAKE_CURRENT_BINARY_DIR}/../.." ABSOLUTE) +if (EXISTS "${HLSL_SRC_ROOT}/.clang-format") + file(MAKE_DIRECTORY "${HLSL_BIN_ROOT}") + file(CREATE_LINK "${HLSL_SRC_ROOT}/.clang-format" "${HLSL_BIN_ROOT}/.clang-format" COPY_ON_ERROR) +endif() + if (WIN32 AND NOT DEFINED HLSL_AUTOCRLF) find_program(git_executable NAMES git git.exe git.cmd) execute_process(COMMAND ${git_executable} config --get core.autocrlf