From: Mika Lindqvist Date: Thu, 21 Dec 2023 08:19:54 +0000 (+0200) Subject: Check if compiler supports -march=native or -mcpu=native. X-Git-Tag: 2.1.6~19 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=0756ec4643f6d540df05dd44e4ede676f3fad259;p=thirdparty%2Fzlib-ng.git Check if compiler supports -march=native or -mcpu=native. --- diff --git a/CMakeLists.txt b/CMakeLists.txt index 9170ed58..b7d15699 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -252,11 +252,18 @@ endif() # Set native march/mcpu if(WITH_NATIVE_INSTRUCTIONS) if(CMAKE_C_COMPILER_ID MATCHES "GNU" OR CMAKE_C_COMPILER_ID MATCHES "Clang") - if(BASEARCH_PPC_FOUND) - set(NATIVEFLAG "-mcpu=native") - else() + check_c_compiler_flag(-march=native HAVE_MARCH_NATIVE) + if(HAVE_MARCH_NATIVE) set(NATIVEFLAG "-march=native") + else() + check_c_compiler_flag(-mcpu=native HAVE_MCPU_NATIVE) + if(HAVE_MCPU_NATIVE) + set(NATIVEFLAG "-mcpu=native") + endif() endif() + # Fall through + endif() + if(NATIVEFLAG) # Apply flag to all source files and compilation checks add_compile_options(${NATIVEFLAG}) else()