shithub: opus

Download patch

ref: 7628d844b4a0435c676fbe9ef03b3c2f8bf3eb5f
parent: 4fc7d874969da418d81b6e0d44b41759c19836aa
author: Nathaniel R. Lewis <linux.robotdude@gmail.com>
date: Thu Apr 9 07:43:09 EDT 2020

CMake Changes

    - Fix typo in OPUS_USE_NEON description.

    - Set OPUS_PRESUME_NEON for iOS platforms as all armv7 and higher
      iOS devices support NEON.

    - Fix detection of aarch64 for OPUS_CPU_ARM and adding sources from
      celt_sources_arm. (previously would miss armcpu.c and arm_celt_map.c)

    - Change "armv7-a" to "arm" in MATCHES checks against
      CMAKE_SYSTEM_PROCESSOR as systems like the RPi3 report as
      "armv7l".

    - Rename OPUS_MAY_SUPPORT_NEON to OPUS_MAY_HAVE_NEON as this name is
      used everywhere else in the CMake build system. Without this,
      runtime capability detection is broken on aarch64.

Signed-off-by: Jean-Marc Valin <jmvalin@jmvalin.ca>

--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -353,7 +353,7 @@
   endif()
 endif()
 
-if(CMAKE_SYSTEM_PROCESSOR MATCHES "(armv7-a)")
+if(CMAKE_SYSTEM_PROCESSOR MATCHES "(arm|aarch64)")
   add_sources_group(opus celt ${celt_sources_arm})
 endif()
 
--- a/opus_config.cmake
+++ b/opus_config.cmake
@@ -26,7 +26,7 @@
   else()
     set(OPUS_CPU_X86 1)
   endif()
-elseif(CMAKE_SYSTEM_PROCESSOR MATCHES "arm")
+elseif(CMAKE_SYSTEM_PROCESSOR MATCHES "(arm|aarch64)")
   set(OPUS_CPU_ARM 1)
 endif()
 
@@ -37,10 +37,12 @@
 elseif(OPUS_CPU_ARM)
   opus_detect_neon(COMPILER_SUPPORT_NEON)
   if(COMPILER_SUPPORT_NEON)
-    option(OPUS_USE_NEON "Option to turn off SSE" ON)
-    option(OPUS_MAY_SUPPORT_NEON "Does runtime check for neon support" ON)
+    option(OPUS_USE_NEON "Option to enable NEON" ON)
+    option(OPUS_MAY_HAVE_NEON "Does runtime check for neon support" ON)
     option(OPUS_PRESUME_NEON "Assume target CPU has NEON support" OFF)
     if(CMAKE_SYSTEM_PROCESSOR MATCHES "aarch64")
+      set(OPUS_PRESUME_NEON ON)
+    elseif(CMAKE_SYSTEM_NAME MATCHES "iOS")
       set(OPUS_PRESUME_NEON ON)
     endif()
   endif()
--- a/opus_functions.cmake
+++ b/opus_functions.cmake
@@ -192,7 +192,7 @@
 endfunction()
 
 function(opus_detect_neon COMPILER_SUPPORT_NEON)
-  if(CMAKE_SYSTEM_PROCESSOR MATCHES "(armv7-a|aarch64)")
+  if(CMAKE_SYSTEM_PROCESSOR MATCHES "(arm|aarch64)")
     message(STATUS "Check NEON support by compiler")
     check_include_file(arm_neon.h HAVE_ARM_NEON_H)
     if(HAVE_ARM_NEON_H)
@@ -209,6 +209,12 @@
   endif()
   if(HAVE_INTRIN_H OR HAVE_CPUID_H)
     set(RUNTIME_CPU_CAPABILITY_DETECTION 1 PARENT_SCOPE)
+  elseif(CMAKE_SYSTEM_PROCESSOR MATCHES "(arm|aarch64)")
+    # ARM cpu detection is implemented for Windows and anything
+    # using a Linux kernel (such as Android).
+    if (CMAKE_SYSTEM_NAME MATCHES "(Windows|Linux|Android)")
+      set(RUNTIME_CPU_CAPABILITY_DETECTION 1 PARENT_SCOPE)
+    endif ()
   else()
     set(RUNTIME_CPU_CAPABILITY_DETECTION 0 PARENT_SCOPE)
   endif()