[all] make OPTIMIZE_FOR_NATIVE a tristate option

This commit is contained in:
arcnmx 2021-07-23 18:21:26 -07:00 committed by Geoffrey McRae
parent be664c49c8
commit 38cb348201
3 changed files with 7 additions and 3 deletions

View File

@ -8,6 +8,7 @@ include(GNUInstallDirs)
include(CheckCCompilerFlag)
include(FeatureSummary)
set(OPTIMIZE_FOR_NATIVE_DEFAULT ON)
include(OptimizeForNative) # option(OPTIMIZE_FOR_NATIVE)
find_package(PkgConfig)

View File

@ -1,10 +1,12 @@
option(OPTIMIZE_FOR_NATIVE "Build with -march=native" OFF)
if(OPTIMIZE_FOR_NATIVE)
set(OPTIMIZE_FOR_NATIVE AUTO CACHE STRING "Build with -march=native")
set_property(CACHE OPTIMIZE_FOR_NATIVE PROPERTY STRINGS AUTO ON OFF GENERIC)
if(OPTIMIZE_FOR_NATIVE STREQUAL "ON" OR (OPTIMIZE_FOR_NATIVE STREQUAL "AUTO" AND OPTIMIZE_FOR_NATIVE_DEFAULT))
CHECK_C_COMPILER_FLAG("-march=native" COMPILER_SUPPORTS_MARCH_NATIVE)
if(COMPILER_SUPPORTS_MARCH_NATIVE)
add_compile_options("-march=native")
endif()
else()
elseif(OPTIMIZE_FOR_NATIVE STREQUAL "AUTO" OR OPTIMIZE_FOR_NATIVE STREQUAL "GENERIC")
CHECK_C_COMPILER_FLAG("-march=x86-64-v2" COMPILER_SUPPORTS_MARCH_X86_64_V2)
if(COMPILER_SUPPORTS_MARCH_X86_64_V2)
add_compile_options("-march=x86-64-v2")

View File

@ -8,6 +8,7 @@ include(GNUInstallDirs)
include(CheckCCompilerFlag)
include(FeatureSummary)
set(OPTIMIZE_FOR_NATIVE_DEFAULT ON)
include(OptimizeForNative) # option(OPTIMIZE_FOR_NATIVE)
option(ENABLE_BACKTRACE "Enable backtrace support on crash" ON)