From de37cfc224adc573ac02eb5518949cb66e255b8f Mon Sep 17 00:00:00 2001 From: Richard Yoo Date: Mon, 21 Jul 2014 13:26:50 -0700 Subject: [PATCH] Enable Intel AVX/AVX2 compilation on Windows. --- cmake/OpenCVCompilerOptions.cmake | 8 -------- cmake/OpenCVModule.cmake | 12 ++++++++++-- 2 files changed, 10 insertions(+), 10 deletions(-) diff --git a/cmake/OpenCVCompilerOptions.cmake b/cmake/OpenCVCompilerOptions.cmake index 7de23a66bc..9aade70b7c 100644 --- a/cmake/OpenCVCompilerOptions.cmake +++ b/cmake/OpenCVCompilerOptions.cmake @@ -220,14 +220,6 @@ if(MSVC) set(OPENCV_EXTRA_FLAGS_RELEASE "${OPENCV_EXTRA_FLAGS_RELEASE} /Zi") endif() - if(ENABLE_AVX AND NOT MSVC_VERSION LESS 1600) - set(OPENCV_EXTRA_FLAGS "${OPENCV_EXTRA_FLAGS} /arch:AVX") - endif() - - if(ENABLE_AVX2 AND NOT MSVC_VERSION LESS 1800) - set(OPENCV_EXTRA_FLAGS "${OPENCV_EXTRA_FLAGS} /arch:AVX2") - endif() - if(ENABLE_SSE4_1 AND CV_ICC AND NOT OPENCV_EXTRA_FLAGS MATCHES "/arch:") set(OPENCV_EXTRA_FLAGS "${OPENCV_EXTRA_FLAGS} /arch:SSE4.1") endif() diff --git a/cmake/OpenCVModule.cmake b/cmake/OpenCVModule.cmake index f9d333f8d9..c3367d480d 100644 --- a/cmake/OpenCVModule.cmake +++ b/cmake/OpenCVModule.cmake @@ -529,14 +529,22 @@ macro(ocv_glob_module_sources) if(ENABLE_AVX) file(GLOB avx_srcs "src/avx/*.cpp") foreach(src ${avx_srcs}) - set_source_files_properties(${src} PROPERTIES COMPILE_FLAGS -mavx) + if(CMAKE_COMPILER_IS_GNUCXX) + set_source_files_properties(${src} PROPERTIES COMPILE_FLAGS -mavx) + elseif(MSVC AND NOT MSVC_VERSION LESS 1600) + set_source_files_properties(${src} PROPERTIES COMPILE_FLAGS /arch:AVX) + endif() endforeach() endif() if(ENABLE_AVX2) file(GLOB avx2_srcs "src/avx2/*.cpp") foreach(src ${avx2_srcs}) - set_source_files_properties(${src} PROPERTIES COMPILE_FLAGS -mavx2) + if(CMAKE_COMPILER_IS_GNUCXX) + set_source_files_properties(${src} PROPERTIES COMPILE_FLAGS -mavx2) + elseif(MSVC AND NOT MSVC_VERSION LESS 1800) + set_source_files_properties(${src} PROPERTIES COMPILE_FLAGS /arch:AVX2) + endif() endforeach() endif()