From 05912474750b6a577990a8c38184922876993e65 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Pawe=C5=82=20Bylica?= Date: Mon, 11 Jan 2021 22:30:24 +0100 Subject: [PATCH] cmake: Add option to select micro-arch, use x86-64-v2 by default --- CMakeLists.txt | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/CMakeLists.txt b/CMakeLists.txt index a009a11a5a..d970ea0d4a 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -72,6 +72,16 @@ set(CMAKE_C_VISIBILITY_PRESET hidden) set(CMAKE_CXX_VISIBILITY_PRESET hidden) set(CMAKE_VISIBILITY_INLINES_HIDDEN YES) +if(CMAKE_SYSTEM_PROCESSOR STREQUAL x86_64) + # Setup options for x86_64 micro-architecture levels. + # https://clang.llvm.org/docs/UsersManual.html#x86 + set(X86_64_ARCH_LEVEL 2 CACHE STRING "The x86_64 micro-architecture level") + if(X86_64_ARCH_LEVEL GREATER 0) + add_compile_options(-march=x86-64-v${X86_64_ARCH_LEVEL}) + message(STATUS "x86_64 micro-architecture level: ${X86_64_ARCH_LEVEL}") + endif() +endif() + include(GNUInstallDirs) if(EVMONE_FUZZING)