Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
29 changes: 24 additions & 5 deletions cmake/option.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -38,13 +38,20 @@ set(ARCH_OPTIONS
ENABLE_ARMV8.5A ENABLE_ARMV8.6A
)

set(AUTO_DETECT_ARCH ON)
option(AUTO_DETECT_ARCH
"Auto-detect architecture flags when no explicit ENABLE_* arch option is set"
ON)
set(_EXPLICIT_ARCH_SELECTED OFF)
foreach(opt IN LISTS ARCH_OPTIONS)
if(${opt})
set(AUTO_DETECT_ARCH OFF)
set(_EXPLICIT_ARCH_SELECTED ON)
break()
endif()
endforeach()
if(_EXPLICIT_ARCH_SELECTED)
# Explicit architecture options always win over auto-detection.
set(AUTO_DETECT_ARCH OFF)
endif()

include(CheckCCompilerFlag)

Expand Down Expand Up @@ -89,11 +96,23 @@ function(_detect_armv8_best)
endfunction()

function(_detect_x86_best)
if(NOT CMAKE_CROSSCOMPILING)
# For native builds, match the actual host CPU capabilities.
check_c_compiler_flag("-march=native" _COMP_SUPP_native)
if(_COMP_SUPP_native)
_AppendFlags(CMAKE_C_FLAGS "-march=native")
_AppendFlags(CMAKE_CXX_FLAGS "-march=native")
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS}" PARENT_SCOPE)
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS}" PARENT_SCOPE)
return()
endif()
endif()

set(_x86_flags
"graniterapids" "emeraldrapids" "sapphirerapids"
"skylake-avx512" "skylake"
"broadwell" "haswell" "sandybridge" "nehalem"
"haswell" "broadwell" "skylake"
"sandybridge" "nehalem"
"znver3" "znver2" "znver1"
"x86-64-v2" "x86-64"
)
foreach(_arch IN LISTS _x86_flags)
check_c_compiler_flag("-march=${_arch}" _COMP_SUPP_${_arch})
Expand Down
8 changes: 8 additions & 0 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -174,6 +174,14 @@ manylinux-aarch64-image = "manylinux_2_28"
# Skip 32-bit builds and musllinux
skip = ["*-manylinux_i686", "*-musllinux*"]

[[tool.cibuildwheel.overrides]]
select = "*-manylinux_x86_64"
environment = { CMAKE_ARGS = "-DAUTO_DETECT_ARCH=OFF -DENABLE_HASWELL=ON" }

[[tool.cibuildwheel.overrides]]
select = "*-manylinux_aarch64"
environment = { CMAKE_ARGS = "-DAUTO_DETECT_ARCH=OFF -DENABLE_ARMV8A=ON" }

[tool.cibuildwheel.macos]
archs = ["arm64"]
environment = { MACOSX_DEPLOYMENT_TARGET = "11.0" }
Expand Down