From 5471408e2d06f6bdb2067dcf991fdfdba9b95188 Mon Sep 17 00:00:00 2001 From: jathu Date: Tue, 27 May 2025 14:33:25 -0700 Subject: [PATCH] enforce clang on windows --- .github/workflows/build-presets.yml | 18 ++++++------------ CMakeLists.txt | 6 ++++++ 2 files changed, 12 insertions(+), 12 deletions(-) diff --git a/.github/workflows/build-presets.yml b/.github/workflows/build-presets.yml index c4318e3daa5..3115685893a 100644 --- a/.github/workflows/build-presets.yml +++ b/.github/workflows/build-presets.yml @@ -71,6 +71,7 @@ jobs: # Build Arm Zephyr Preset cmake --preset ${{ matrix.preset }} cmake --build cmake-out -j$(( $(nproc) - 1 )) + linux: uses: pytorch/test-infra/.github/workflows/linux_job_v2.yml@main strategy: @@ -117,16 +118,9 @@ jobs: timeout: 90 script: | set -eux - conda init powershell - powershell -Command "& { - \$ErrorActionPreference = 'Stop' - Set-PSDebug -Trace 1 - - conda create --yes --quiet -n et python=3.12 - conda activate et + conda create --yes --quiet -n et python=3.12 + conda activate et - python install_requirements.py - cmake --preset ${{ matrix.preset }} - \$numCores = [System.Environment]::GetEnvironmentVariable('NUMBER_OF_PROCESSORS') - 1 - cmake --build cmake-out -j \$numCores - }" + ./install_requirements.sh + cmake -G "Visual Studio 17 2022" -T ClangCL --preset ${{ matrix.preset }} + cmake --build cmake-out -j$(( $(nproc) - 1 )) diff --git a/CMakeLists.txt b/CMakeLists.txt index cfae0f8b74b..46982f0f17d 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -74,6 +74,12 @@ if(NOT CMAKE_BUILD_TYPE) endif() announce_configured_options(CMAKE_BUILD_TYPE) +if(WIN32) + if(NOT "${CMAKE_GENERATOR_TOOLSET}" STREQUAL "" AND NOT CMAKE_GENERATOR_TOOLSET MATCHES "Clang") + message(FATAL_ERROR "Windows requires clang. Pass '-T ClangCL' in the cmake build command. Current CMAKE_GENERATOR_TOOLSET: ${CMAKE_GENERATOR_TOOLSET}") + endif() +endif() + if(NOT PYTHON_EXECUTABLE) resolve_python_executable() endif()