From 6b5842d2fff98c9045ab50bcc4352010d8d2d01c Mon Sep 17 00:00:00 2001 From: Geoffrey McRae Date: Thu, 28 Jan 2021 08:07:42 +1100 Subject: [PATCH] [host] cmake: use `-march=nehalem` by default Nehalem is the minimum requirement for the host application as it makes use of SSE4.1 instructions, as such we should default to compling with it instead of `-march=native` so that when the binary is distributed it will operate on foreign systems. Fixed #416 --- host/CMakeLists.txt | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/host/CMakeLists.txt b/host/CMakeLists.txt index 0b4bd11a..a5bb203c 100644 --- a/host/CMakeLists.txt +++ b/host/CMakeLists.txt @@ -6,12 +6,17 @@ set(CMAKE_MODULE_PATH "${PROJECT_SOURCE_DIR}/cmake/") include(CheckCCompilerFlag) include(FeatureSummary) -option(OPTIMIZE_FOR_NATIVE "Build with -march=native" ON) +option(OPTIMIZE_FOR_NATIVE "Build with -march=native" OFF) if(OPTIMIZE_FOR_NATIVE) CHECK_C_COMPILER_FLAG("-march=native" COMPILER_SUPPORTS_MARCH_NATIVE) if(COMPILER_SUPPORTS_MARCH_NATIVE) add_compile_options("-march=native") endif() +else() + CHECK_C_COMPILER_FLAG("-march=nehalem" COMPILER_SUPPORTS_MARCH_NEHALEM) + if(COMPILER_SUPPORTS_MARCH_NEHALEM) + add_compile_options("-march=nehalem") + endif() endif() option(ENABLE_BACKTRACE "Enable backtrace support on crash" ON)