-if(CMAKE_SYSTEM_PROCESSOR MATCHES "amd64.*|x86_64.*|AMD64.*")
- set(CMAKE_C_FLAGS "-march=corei7 -mtune=corei7-avx ${CMAKE_C_FLAGS}")
- check_c_compiler_flag("-march=core-avx2" compiler_flag_march_core_avx2)
- if(compiler_flag_march_core_avx2)
- list(APPEND MARCH_VARIANTS "avx2\;-march=core-avx2 -mtune=core-avx2")
+macro(add_vpp_march_variant v)
+ cmake_parse_arguments(ARG
+ "OFF"
+ "N_PREFETCHES;CACHE_PREFETCH_BYTES"
+ "FLAGS"
+ ${ARGN}
+ )
+
+ if(ARG_FLAGS)
+ set(flags_ok 1)
+ set(fs "")
+ foreach(f ${ARG_FLAGS})
+ string(APPEND fs " ${f}")
+ string(REGEX REPLACE "[-=+]" "_" sfx ${f})
+ if(NOT DEFINED compiler_flag${sfx})
+ check_c_compiler_flag(${f} compiler_flag${sfx})
+ endif()
+ if(NOT compiler_flag${sfx})
+ unset(flags_ok)
+ endif()
+ endforeach()
+ if(ARG_N_PREFETCHES)
+ string(APPEND fs " -DCLIB_N_PREFETCHES=${ARG_N_PREFETCHES}")
+ endif()
+ if(ARG_CACHE_PREFETCH_BYTES)
+ set_log2_cacheline_size(log2 ${ARG_CACHE_PREFETCH_BYTES})
+ string(APPEND fs " -DCLIB_LOG2_CACHE_PREFETCH_BYTES=${log2}")
+ endif()
+ if(flags_ok)
+ string(TOUPPER ${v} uv)
+ if(ARG_OFF)
+ option(VPP_MARCH_VARIANT_${uv} "Build ${v} multiarch variant." OFF)
+ else()
+ option(VPP_MARCH_VARIANT_${uv} "Build ${v} multiarch variant." ON)
+ endif()
+ if (VPP_MARCH_VARIANT_${uv})
+ list(APPEND MARCH_VARIANTS "${v}\;${fs}")
+ else()
+ list(APPEND MARCH_VARIANTS_DISABLED "${v}\;${fs}")
+ endif()
+ endif()