[cmake] case insensitive simd check

This commit is contained in:
akallabeth
2024-12-13 23:25:03 +01:00
parent 2f72eeddf8
commit 9f02fb017f

View File

@@ -18,19 +18,21 @@ macro(set_simd_source_file_properties INTRINSIC_TYPE)
# see https://cmake.org/cmake/help/latest/variable/CMAKE_LANG_COMPILER_ID.html
set(GCC_CLANG_NAMES "AppleClang;Clang;CrayClang;FujitsuClang;GNU;IntelLLVM;TIClang;XLClang;IBMClang")
set(SSE_X86_LIST "i686;x86;X86")
set(SSE_LIST "x86_64;ia64;x64;AMD64;IA64;EM64T;${SSE_X86_LIST}")
set(SSE_X86_LIST "i686;x86")
set(SSE_LIST "x86_64;ia64;x64;amd64;ia64;em64t;${SSE_X86_LIST}")
set(NEON_LIST "arm;armv7;armv8b;armv8l")
set(SUPPORTED_INTRINSICS_LIST "neon;sse2;sse3;ssse3;sse4.1;sse4.2;avx2")
string(TOLOWER "${CMAKE_SYSTEM_PROCESSOR}" SYSTEM_PROCESSOR)
if(NOT "${INTRINSIC_TYPE}" IN_LIST SUPPORTED_INTRINSICS_LIST)
message(WARNING "Intrinsic type ${INTRINSIC_TYPE} not supported, only ${SUPPORTED_INTRINSICS_LIST} are available")
else()
set(SIMD_LINK_ARG "")
if(MSVC)
# https://learn.microsoft.com/en-us/cpp/build/reference/arch-x64?view=msvc-140
if("${CMAKE_SYSTEM_PROCESSOR}" IN_LIST SSE_LIST)
if("${CMAKE_SYSTEM_PROCESSOR}" IN_LIST SSE_X86_LIST)
if("${SYSTEM_PROCESSOR}" IN_LIST SSE_LIST)
if("${SYSTEM_PROCESSOR}" IN_LIST SSE_X86_LIST)
# /arch:SSE2 is the default, so do nothing
set(SIMD_LINK_ARG "ignore")
if("${INTRINSIC_TYPE}" STREQUAL "avx2")
@@ -53,7 +55,7 @@ macro(set_simd_source_file_properties INTRINSIC_TYPE)
set(HAVE_SSE_AVX ON)
endif()
endforeach()
if("${CMAKE_SYSTEM_PROCESSOR}" IN_LIST SSE_LIST OR HAVE_SSE_AVX)
if("${SYSTEM_PROCESSOR}" IN_LIST SSE_LIST OR HAVE_SSE_AVX)
if("${INTRINSIC_TYPE}" STREQUAL "sse2")
set(SIMD_LINK_ARG "-msse2")
elseif("${INTRINSIC_TYPE}" STREQUAL "sse3")
@@ -79,7 +81,7 @@ macro(set_simd_source_file_properties INTRINSIC_TYPE)
set(HAVE_NEON ON)
endif()
endforeach()
if("${CMAKE_SYSTEM_PROCESSOR}" IN_LIST NEON_LIST OR HAVE_NEON)
if("${SYSTEM_PROCESSOR}" IN_LIST NEON_LIST OR HAVE_NEON)
if(MSVC)
set(SIMD_LINK_ARG "/arch:VFPv4")
elseif("${CMAKE_C_COMPILER_ID}" IN_LIST GCC_CLANG_NAMES)