]> git.ipfire.org Git - thirdparty/zlib-ng.git/commitdiff
Check if compiler supports -march=native or -mcpu=native.
authorMika Lindqvist <postmaster@raasu.org>
Thu, 21 Dec 2023 08:19:54 +0000 (10:19 +0200)
committerHans Kristian Rosbach <hk-github@circlestorm.org>
Sun, 24 Dec 2023 14:41:29 +0000 (15:41 +0100)
CMakeLists.txt

index 9170ed5871b53ec92d347506269c76c1b05e40c5..b7d15699cec81d9a5223c76148ce3d541da709a2 100644 (file)
@@ -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()