From 08e299f724810eac8c4fdce50e2ca3be3f41eccf Mon Sep 17 00:00:00 2001 From: Ken Cooke Date: Sat, 6 Feb 2016 10:53:56 -0800 Subject: [PATCH] CMAKE changes to support AVX instructions. Source files in src/avx are compiled with AVX enabled (VEX encoding) and require runtime dispatch to avoid crashing a machine without AVX hardware. --- cmake/macros/SetupHifiLibrary.cmake | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) diff --git a/cmake/macros/SetupHifiLibrary.cmake b/cmake/macros/SetupHifiLibrary.cmake index 9c6cbf6831..5a9ffcc384 100644 --- a/cmake/macros/SetupHifiLibrary.cmake +++ b/cmake/macros/SetupHifiLibrary.cmake @@ -11,10 +11,20 @@ macro(SETUP_HIFI_LIBRARY) project(${TARGET_NAME}) - # grab the implemenation and header files - file(GLOB_RECURSE LIB_SRCS "src/*.h" "src/*.cpp" "src/*.c") + # grab the implementation and header files + file(GLOB_RECURSE LIB_SRCS "src/*.h" "src/*.cpp" "src/*.c" "src/avx/*.h" "src/avx/*.cpp" "src/avx/*.c") list(APPEND ${TARGET_NAME}_SRCS ${LIB_SRCS}) + # add compiler flags to AVX source files + file(GLOB_RECURSE AVX_SRCS "src/avx/*.cpp" "src/avx/*.c") + foreach(SRC ${AVX_SRCS}) + if (WIN32) + set_source_files_properties(${SRC} PROPERTIES COMPILE_FLAGS /arch:AVX) + elseif (APPLE OR UNIX) + set_source_files_properties(${SRC} PROPERTIES COMPILE_FLAGS -mavx) + endif() + endforeach() + setup_memory_debugger() # create a library and set the property so it can be referenced later