aboutsummaryrefslogtreecommitdiffstats
path: root/src/cmake
diff options
context:
space:
mode:
authorDamjan Marion <damarion@cisco.com>2023-08-31 17:00:16 +0200
committerOle Tr�an <otroan@employees.org>2023-09-06 18:57:54 +0000
commitf0fc65a4b949a6e5a44250d405ce219b8e547859 (patch)
treeffde22b15d7c9f8a6b5fbbdad7dabfeef5a5ab86 /src/cmake
parent579a6fb89baf325d96fe49bc52e9fec5f98a780c (diff)
build: add option to specify native -march= flag with VPP_BUILD_NATIVE_ARCH
Type: improvement Change-Id: I98eeba1ad2f9ed0531a7c615e0e70e535f24f813 Signed-off-by: Damjan Marion <damarion@cisco.com>
Diffstat (limited to 'src/cmake')
-rw-r--r--src/cmake/cpu.cmake16
1 files 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)