From 1db8fcd344a6257765486445b72c9c65dbb785ef Mon Sep 17 00:00:00 2001 From: Anthony Roberts Date: Thu, 14 Nov 2024 12:01:33 +0000 Subject: [PATCH] Fix Windows ARM64 builds when using MSVC --- CMakeLists.txt | 7 +++++-- src/global.h | 2 +- tests/CMakeLists.txt | 7 +++++-- 3 files changed, 11 insertions(+), 5 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 08d3dc2b..6e860e11 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -224,15 +224,18 @@ if(BUILD_KVAZAAR_BINARY) target_link_libraries(kvazaar-bin PUBLIC kvazaar) endif() +list(APPEND ALLOW_AVX2 "x86_64" "AMD64") + if(MSVC) target_include_directories(kvazaar PUBLIC src/threadwrapper/include) - set_property( SOURCE ${LIB_SOURCES_STRATEGIES_AVX2} APPEND PROPERTY COMPILE_FLAGS "/arch:AVX2" ) + if(${CMAKE_SYSTEM_PROCESSOR} IN_LIST ALLOW_AVX2) + set_property( SOURCE ${LIB_SOURCES_STRATEGIES_AVX2} APPEND PROPERTY COMPILE_FLAGS "/arch:AVX2" ) + endif() else() if(BUILD_KVAZAAR_BINARY) set_target_properties(kvazaar-bin PROPERTIES RUNTIME_OUTPUT_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}/src) endif() set_target_properties(kvazaar PROPERTIES SOVERSION "7" VERSION "7.4.0") - list(APPEND ALLOW_AVX2 "x86_64" "AMD64") if(${CMAKE_SYSTEM_PROCESSOR} IN_LIST ALLOW_AVX2) set_property( SOURCE ${LIB_SOURCES_STRATEGIES_AVX2} APPEND PROPERTY COMPILE_FLAGS "-mavx2 -mbmi -mpopcnt -mlzcnt -mbmi2" ) set_property( SOURCE ${LIB_SOURCES_STRATEGIES_SSE41} APPEND PROPERTY COMPILE_FLAGS "-msse4.1" ) diff --git a/src/global.h b/src/global.h index 12f6f6c2..018e8bd5 100644 --- a/src/global.h +++ b/src/global.h @@ -365,7 +365,7 @@ typedef enum { COLOR_Y = 0, COLOR_U, COLOR_V } color_t; # define COMPILE_POWERPC 0 #endif -#if defined (_M_ARM) || defined(__arm__) || defined(__thumb__) +#if defined (_M_ARM) || defined(_M_ARM64) || defined(__arm__) || defined(__thumb__) # define COMPILE_ARM 1 #else # define COMPILE_ARM 0 diff --git a/tests/CMakeLists.txt b/tests/CMakeLists.txt index 2d386f02..eb95bac1 100644 --- a/tests/CMakeLists.txt +++ b/tests/CMakeLists.txt @@ -15,13 +15,16 @@ if(BUILD_SHARED_LIBS) add_definitions(-DPIC) endif() +list(APPEND ALLOW_AVX2 "x86_64" "AMD64") + if(MSVC) target_include_directories(kvazaar_tests PUBLIC ../src/threadwrapper/include) - set_property( SOURCE ${TEST_SOURCES} APPEND PROPERTY COMPILE_FLAGS "/arch:AVX2" ) + if(${CMAKE_SYSTEM_PROCESSOR} IN_LIST ALLOW_AVX2) + set_property( SOURCE ${TEST_SOURCES} APPEND PROPERTY COMPILE_FLAGS "/arch:AVX2" ) + endif() add_definitions(-DWIN32_LEAN_AND_MEAN -D_WIN32 -DWIN32 -DWIN64) else() - list(APPEND ALLOW_AVX2 "x86_64" "AMD64") if(${CMAKE_SYSTEM_PROCESSOR} IN_LIST ALLOW_AVX2) set_property( SOURCE ${TEST_SOURCES} APPEND PROPERTY COMPILE_FLAGS "-mavx2 -mbmi -mpopcnt -mlzcnt -mbmi2" ) endif()