From 7316c1c46c7171619db232c0763b5bc352098d5b Mon Sep 17 00:00:00 2001 From: arcnmx Date: Fri, 23 Jul 2021 18:28:10 -0700 Subject: [PATCH] [all] include OPTIMIZE_FOR_NATIVE in feature summary --- cmake/OptimizeForNative.cmake | 20 ++++++++++++++++---- 1 file changed, 16 insertions(+), 4 deletions(-) diff --git a/cmake/OptimizeForNative.cmake b/cmake/OptimizeForNative.cmake index c5dbf179..35322630 100644 --- a/cmake/OptimizeForNative.cmake +++ b/cmake/OptimizeForNative.cmake @@ -1,19 +1,31 @@ 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)) +set(OPTIMIZE_FOR_NATIVE_ARCH "none") +if(OPTIMIZE_FOR_NATIVE 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") + set(OPTIMIZE_FOR_NATIVE_ARCH "native") + set(OPTIMIZE_FOR_NATIVE_ON ON) endif() 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") + set(OPTIMIZE_FOR_NATIVE_ARCH "x86-64-v2") else() CHECK_C_COMPILER_FLAG("-march=nehalem" COMPILER_SUPPORTS_MARCH_NEHALEM) if(COMPILER_SUPPORTS_MARCH_NEHALEM) - add_compile_options("-march=nehalem") + set(OPTIMIZE_FOR_NATIVE_ARCH "nehalem") endif() endif() +elseif(NOT OPTIMIZE_FOR_NATIVE) +else() + set(OPTIMIZE_FOR_NATIVE_ARCH "${OPTIMIZE_FOR_NATIVE}") + set(OPTIMIZE_FOR_NATIVE_ON ON) endif() + +if(NOT OPTIMIZE_FOR_NATIVE_ARCH STREQUAL "none") + add_compile_options("-march=${OPTIMIZE_FOR_NATIVE_ARCH}") +endif() + +add_feature_info(OPTIMIZE_FOR_NATIVE OPTIMIZE_FOR_NATIVE_ON "Optimized for ${OPTIMIZE_FOR_NATIVE_ARCH}")