Ver Fonte

cmake: Add ppc64 arch compile options

Xenofon Karamanos há 1 mês atrás
pai
commit
26b8bd414b
1 ficheiros alterados com 32 adições e 0 exclusões
  1. 32 0
      cmake/compiler-specific.cmake

+ 32 - 0
cmake/compiler-specific.cmake

@@ -68,4 +68,36 @@ elseif(CMAKE_SYSTEM_PROCESSOR STREQUAL "aarch64")
     # common INTERFACE -ftree-vectorize -fno-strict-overflow ) endif()
     # common INTERFACE -ftree-vectorize -fno-strict-overflow ) endif()
 
 
   endif()
   endif()
+
+elseif(CMAKE_SYSTEM_PROCESSOR MATCHES "ppc64$")
+  # PowerPC 64-bit specific flags
+  if(CMAKE_C_COMPILER_ID STREQUAL "GNU")
+    target_compile_definitions(common_compiler_flags INTERFACE CC_GCC_LIKE_ASM)
+    target_compile_options(common_compiler_flags INTERFACE -funroll-loops -fsigned-char)
+
+    # Try to get CPUTYPE from the environment, fallback to "powerpc64" if not set
+    if(DEFINED ENV{CPUTYPE} AND NOT "$ENV{CPUTYPE}" STREQUAL "")
+      set(CPUTYPE "$ENV{CPUTYPE}")
+    else()
+      set(CPUTYPE "powerpc64")
+    endif()
+
+    if(CMAKE_C_COMPILER_VERSION VERSION_GREATER_EQUAL 4.2)
+      target_compile_options(
+        common_compiler_flags INTERFACE -ftree-vectorize -fno-strict-overflow -mtune=${CPUTYPE}
+                                        -maltivec
+      )
+    elseif(CMAKE_C_COMPILER_VERSION VERSION_GREATER_EQUAL 4.0)
+      target_compile_options(
+        common_compiler_flags INTERFACE -ftree-vectorize -mtune=${CPUTYPE} -maltivec
+      )
+    elseif(CMAKE_C_COMPILER_VERSION VERSION_LESS 3.0)
+      message(
+        WARNING
+          "GCC version ${CMAKE_C_COMPILER_VERSION} is too old for ppc64. Try GCC 3.0 or newer."
+      )
+    endif()
+    # else()
+    #   message(FATAL_ERROR "Unsupported compiler (${CMAKE_C_COMPILER_ID}) for ppc64. Try GCC.")
+  endif()
 endif()
 endif()