Move clang-cl detection to cmake and allow it when setting flags

feature/simd
Andrew Cassidy 2 years ago
parent 7ba2225644
commit 04fece2771

@ -1,4 +1,12 @@
cmake_minimum_required(VERSION 3.18)
if(MSVC AND ENV{CC} MATCHES ".*clang-cl.*")
set(CMAKE_GENERATOR_TOOLSET "ClangCL")
set(CLANG_CL TRUE)
else()
set(CLANG_CL FALSE)
endif()
include(tools/CompilerWarnings.cmake)
include(tools/CPUFeatures.cmake)
set(CMAKE_VERBOSE_MAKEFILE ON)

@ -78,7 +78,7 @@ archs = ["auto64"] # arm64 windows builds not yet supported
test-command = "cd /d {project} && python -m unittest --verbose" # windows why is this flag required
# MSVC compiled wheels will just have to be serial ops until distutil supports clang-cl
# https://github.com/python/cpython/pull/18371
environment = { CXX = "clang-cl.exe", CC = "clang-cl.exe" }
environment = { QUICKTEX_HWY_MODE = "SSE4", CXX = "clang-cl.exe", CC = "clang-cl.exe" }
[tool.cibuildwheel.linux]
skip = ["cp37-musllinux*", "*musllinux_aarch64*"] # skip targets without available Pillow wheels

@ -66,8 +66,8 @@ class CMakeBuild(build_ext):
cmake_args += ["-GNinja"]
else:
if 'CC' in os.environ and 'clang-cl' in os.environ['CC']:
cmake_args += ["-T", 'ClangCL'] # https://stackoverflow.com/a/64189112/7645957
# if 'CC' in os.environ and 'clang-cl' in os.environ['CC']:
# cmake_args += ["-T", 'ClangCL'] # https://stackoverflow.com/a/64189112/7645957
# Single config generators are handled "normally"
single_config = any(x in cmake_generator for x in {"NMake", "Ninja"})

@ -42,20 +42,32 @@ function(set_simd_flags target_name)
if (highway_mode STREQUAL "AUTO")
# setting -march=native on an M1 causes Clang to freak out
if (MSVC)
#MSVC has no -march=native equivalent. womp
message(WARNING "Compiling using MSVC without settig an explicit QUICKTEX_HWY_MODE defaults to serial operations. Please compile with Clang if you need vectorization")
if (CLANG_CL)
target_compile_options(${target_name} PUBLIC /clang:-march=native)
else()
#MSVC has no -march=native equivalent. womp
message(WARNING "Compiling using cl.exe without settig an explicit QUICKTEX_HWY_MODE defaults to serial operations. Please compile with clang-cl if you need vectorization")
endif()
elseif (!ARM)
target_compile_options(${target_name} PUBLIC -march=native)
endif ()
elseif (highway_mode STREQUAL "SSSE3")
if (MSVC)
message(SEND_ERROR "Compiling using SSSE3 is not supported with the MSVC compiler. Please use AVX or compile withClang")
if (CLANG_CL)
target_compile_options(${target_name} PUBLIC /clang:-mssse3)
else()
message(SEND_ERROR "Compiling using SSSE3 is not supported with the cl.exe compiler. Please use AVX or compile with clang-cl")
endif()
else ()
target_compile_options(${target_name} PUBLIC -mssse3)
endif ()
elseif (highway_mode STREQUAL "SSE4")
if (MSVC)
message(SEND_ERROR "Compiling using SSE4 is not supported with the MSVC compiler. Please use AVX or compile with Clang")
if (CLANG_CL)
target_compile_options(${target_name} PUBLIC /clang:-msse4)
else()
message(SEND_ERROR "Compiling using SSE4 is not supported with the MSVC compiler. Please use AVX or compile with Clang")
endif()
else ()
target_compile_options(${target_name} PUBLIC -msse4)
endif ()

Loading…
Cancel
Save