-
-
Notifications
You must be signed in to change notification settings - Fork 23
/
RuntimeSIMDLib.cmake
32 lines (29 loc) · 1.33 KB
/
RuntimeSIMDLib.cmake
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
include(CheckCXXCompilerFlag)
function(make_lib_simd_runtime name)
set(multiValueArgs SOURCES)
cmake_parse_arguments(ARG "" "" "${multiValueArgs}" ${ARGN})
add_library(${name}_sse_or_arm STATIC)
target_sources(${name}_sse_or_arm PRIVATE ${ARG_SOURCES})
add_library(${name}_avx STATIC)
target_sources(${name}_avx PRIVATE ${ARG_SOURCES})
target_compile_definitions(${name}_avx PRIVATE BYOD_COMPILING_WITH_AVX=1)
if(WIN32)
CHECK_CXX_COMPILER_FLAG("/arch:AVX" COMPILER_OPT_ARCH_AVX_SUPPORTED)
if(COMPILER_OPT_ARCH_AVX_SUPPORTED)
message(STATUS "Compiler supports flags: /arch:AVX")
target_compile_options(${name}_avx PRIVATE /arch:AVX)
else()
message(STATUS "Compiler DOES NOT supports flags: /arch:AVX")
endif()
else()
CHECK_CXX_COMPILER_FLAG("-mavx -mfma" COMPILER_OPT_ARCH_AVX_SUPPORTED)
if(COMPILER_OPT_ARCH_AVX_SUPPORTED)
message(STATUS "Compiler supports flags: -mavx -mfma")
target_compile_options(${name}_avx PRIVATE -mavx -mfma -Wno-unused-command-line-argument)
else()
message(STATUS "Compiler DOES NOT supports flags: -mavx -mfma")
endif()
endif()
add_library(${name} INTERFACE)
target_link_libraries(${name} INTERFACE ${name}_sse_or_arm ${name}_avx)
endfunction()