From f0fc65a4b949a6e5a44250d405ce219b8e547859 Mon Sep 17 00:00:00 2001 From: Damjan Marion Date: Thu, 31 Aug 2023 17:00:16 +0200 Subject: [PATCH] build: add option to specify native -march= flag with VPP_BUILD_NATIVE_ARCH Type: improvement Change-Id: I98eeba1ad2f9ed0531a7c615e0e70e535f24f813 Signed-off-by: Damjan Marion --- src/cmake/cpu.cmake | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/src/cmake/cpu.cmake b/src/cmake/cpu.cmake index b54155d4bb3..69f83c98b8d 100644 --- a/src/cmake/cpu.cmake +++ b/src/cmake/cpu.cmake @@ -59,13 +59,6 @@ endif() option(VPP_BUILD_NATIVE_ONLY "Build only for native CPU." OFF) -if(VPP_BUILD_NATIVE_ONLY) - check_c_compiler_flag("-march=native" compiler_flag_march_native) - if(NOT compiler_flag_march_native) - message(FATAL_ERROR "Native-only build not supported by compiler") - endif() -endif() - macro(add_vpp_march_variant v) cmake_parse_arguments(ARG "OFF" @@ -112,7 +105,14 @@ macro(add_vpp_march_variant v) endmacro() if(VPP_BUILD_NATIVE_ONLY) - set(VPP_DEFAULT_MARCH_FLAGS -march=native) + set(VPP_BUILD_NATIVE_ARCH "native" CACHE STRING "native CPU -march= value.") + set(VPP_DEFAULT_MARCH_FLAGS -march=${VPP_BUILD_NATIVE_ARCH}) + if(VPP_BUILD_NATIVE_ONLY) + check_c_compiler_flag(${VPP_DEFAULT_MARCH_FLAGS} compiler_flag_march) + if(NOT compiler_flag_march) + message(FATAL_ERROR "Native-only build with ${VPP_DEFAULT_MARCH_FLAGS} is not supported by compiler") + endif() + endif() set(MARCH_VARIANTS_NAMES "native-only") elseif(CMAKE_SYSTEM_PROCESSOR MATCHES "amd64.*|x86_64.*|AMD64.*") set(VPP_DEFAULT_MARCH_FLAGS -march=corei7 -mtune=corei7-avx) -- 2.16.6