From 4bb1540d1d75db41040ad66c8d656a913728bee1 Mon Sep 17 00:00:00 2001 From: Mark Schofield <34426337+MarkSchofield@users.noreply.github.com> Date: Fri, 28 Aug 2026 09:35:24 -0700 Subject: [PATCH] Accommodate a clang hint-path --- Windows.Clang.toolchain.cmake | 20 ++++++++++++++++---- 1 file changed, 16 insertions(+), 4 deletions(-) diff --git a/Windows.Clang.toolchain.cmake b/Windows.Clang.toolchain.cmake index bba0a68..5a55483 100644 --- a/Windows.Clang.toolchain.cmake +++ b/Windows.Clang.toolchain.cmake @@ -39,6 +39,7 @@ # | CMAKE_VS_VERSION_RANGE | A verson range for VS instances to find. For example, '[16.0,17.0)' will find versions '16.*'. Defaults to '[16.0,17.0)' | # | CMAKE_WINDOWS_KITS_10_DIR | The location of the root of the Windows Kits 10 directory. | # | TOOLCHAIN_ADD_VS_NINJA_PATH | Whether the toolchain should add the path to the VS Ninja to the CMAKE_SYSTEM_PROGRAM_PATH. Defaults to 'ON'. | +# | TOOLCHAIN_LLVM_HINT_PATH | A 'hint path' to LLVM. If set, it will be used to find clang/clang-cl in the 'bin' folder. | # | TOOLCHAIN_UPDATE_PROGRAM_PATH | Whether the toolchain should update CMAKE_PROGRAM_PATH. Defaults to 'ON'. | # | VS_INSTALLATION_PATH | The location of the root of the Visual Studio installation. If not specified VSWhere will be used to search for one. | # @@ -226,13 +227,24 @@ unset(TOOLCHAIN_TARGET) # Look for clang/clang-cl. # -# The Visual Studio-distributed clang tools are preferred, followed by the default installation location. -set(TOOLCHAIN_CLANG_HINTS_PATHS "$ENV{ProgramFiles}/LLVM/bin") -list(PREPEND TOOLCHAIN_CLANG_HINTS_PATHS "${VS_INSTALLATION_PATH}/VC/Tools/Llvm/x64/bin") +# The following paths are considered in order: +# 1) 'TOOLCHAIN_LLVM_HINT_PATH' if set. +# 2) '${VS_INSTALLATION_PATH}/VC/Tools/Llvm/arm64' if the host is ARM64. +# 3) '${VS_INSTALLATION_PATH}/VC/Tools/Llvm/x64'. +# 4) '$ENV{ProgramFiles}/LLVM' +# +set(TOOLCHAIN_CLANG_HINTS_PATHS) +if(TOOLCHAIN_LLVM_HINT_PATH) + list(APPEND TOOLCHAIN_CLANG_HINTS_PATHS "${TOOLCHAIN_LLVM_HINT_PATH}/bin") +endif() + if(CMAKE_HOST_SYSTEM_PROCESSOR STREQUAL ARM64) - list(PREPEND TOOLCHAIN_CLANG_HINTS_PATHS "${VS_INSTALLATION_PATH}/VC/Tools/Llvm/arm64/bin") + list(APPEND TOOLCHAIN_CLANG_HINTS_PATHS "${VS_INSTALLATION_PATH}/VC/Tools/Llvm/arm64/bin") endif() +list(APPEND TOOLCHAIN_CLANG_HINTS_PATHS "${VS_INSTALLATION_PATH}/VC/Tools/Llvm/x64/bin") +list(APPEND TOOLCHAIN_CLANG_HINTS_PATHS "$ENV{ProgramFiles}/LLVM/bin") + if(NOT CMAKE_C_COMPILER) set(TOOLCHAIN_C_COMPILER_EXE clang.exe) if(CMAKE_C_COMPILER_FRONTEND_VARIANT STREQUAL MSVC)