Переглянути джерело

cmake: simd detection clean-up for Apple multi-arch configs.

Ozkan Sezer 1 тиждень тому
батько
коміт
83bb0f9105
2 змінених файлів з 14 додано та 10 видалено
  1. 6 0
      CMakeLists.txt
  2. 8 10
      cmake/sdlcompilers.cmake

+ 6 - 0
CMakeLists.txt

@@ -80,6 +80,12 @@ include("${SDL3_SOURCE_DIR}/cmake/PreseedNokiaNGageCache.cmake")
 
 SDL_DetectCompiler()
 SDL_DetectTargetCPUArchitectures(SDL_CPUS)
+if(APPLE AND CMAKE_OSX_ARCHITECTURES)
+  list(LENGTH CMAKE_OSX_ARCHITECTURES _num_arches)
+  if(_num_arches GREATER 1)
+    set(APPLE_MULTIARCH TRUE)
+  endif()
+endif()
 
 # Increment this if there is an incompatible change - but if that happens,
 # we should rename the library from SDL3 to SDL4, at which point this would

+ 8 - 10
cmake/sdlcompilers.cmake

@@ -165,20 +165,19 @@ function(check_x86_source_compiles BODY VAR)
   if(ARGN)
     message(FATAL_ERROR "Unknown arguments: ${ARGN}")
   endif()
-  if(APPLE AND DEFINED CMAKE_OSX_ARCHITECTURES)
+  if(APPLE_MULTIARCH AND (SDL_CPU_X86 OR SDL_CPU_X64))
     set(test_conditional 1)
   else()
     set(test_conditional 0)
   endif()
   check_c_source_compiles("
     #if ${test_conditional}
-    # include \"TargetConditionals.h\"
-    # if TARGET_CPU_X86 || TARGET_CPU_X86_64
+    # if defined(__i386__) || defined(__x86_64__)
     #  define test_enabled 1
     # else
-    #  define test_enabled 0
+    #  define test_enabled 0 /* feign success in Apple multi-arch configs */
     # endif
-    #else
+    #else                    /* test normally */
     # define test_enabled 1
     #endif
     #if test_enabled
@@ -196,20 +195,19 @@ function(check_arm_source_compiles BODY VAR)
   if(ARGN)
     message(FATAL_ERROR "Unknown arguments: ${ARGN}")
   endif()
-  if(APPLE AND DEFINED CMAKE_OSX_ARCHITECTURES)
+  if(APPLE_MULTIARCH AND (SDL_CPU_ARM32 OR SDL_CPU_ARM64))
     set(test_conditional 1)
   else()
     set(test_conditional 0)
   endif()
   check_c_source_compiles("
     #if ${test_conditional}
-    # include \"TargetConditionals.h\"
-    # if TARGET_CPU_ARM || TARGET_CPU_ARM64
+    # if defined(__arm__) || defined(__aarch64__)
     #  define test_enabled 1
     # else
-    #  define test_enabled 0
+    #  define test_enabled 0 /* feign success in Apple multi-arch configs */
     # endif
-    #else
+    #else                    /* test normally */
     # define test_enabled 1
     #endif
     #if test_enabled