1*09537850SAkhilesh Sanikop# Copyright 2019 The libgav1 Authors 2*09537850SAkhilesh Sanikop# 3*09537850SAkhilesh Sanikop# Licensed under the Apache License, Version 2.0 (the "License"); 4*09537850SAkhilesh Sanikop# you may not use this file except in compliance with the License. 5*09537850SAkhilesh Sanikop# You may obtain a copy of the License at 6*09537850SAkhilesh Sanikop# 7*09537850SAkhilesh Sanikop# http://www.apache.org/licenses/LICENSE-2.0 8*09537850SAkhilesh Sanikop# 9*09537850SAkhilesh Sanikop# Unless required by applicable law or agreed to in writing, software 10*09537850SAkhilesh Sanikop# distributed under the License is distributed on an "AS IS" BASIS, 11*09537850SAkhilesh Sanikop# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12*09537850SAkhilesh Sanikop# See the License for the specific language governing permissions and 13*09537850SAkhilesh Sanikop# limitations under the License. 14*09537850SAkhilesh Sanikop 15*09537850SAkhilesh Sanikopif(LIBGAV1_CMAKE_LIBGAV1_CPU_DETECTION_CMAKE_) 16*09537850SAkhilesh Sanikop return() 17*09537850SAkhilesh Sanikopendif() # LIBGAV1_CMAKE_LIBGAV1_CPU_DETECTION_CMAKE_ 18*09537850SAkhilesh Sanikopset(LIBGAV1_CMAKE_LIBGAV1_CPU_DETECTION_CMAKE_ 1) 19*09537850SAkhilesh Sanikop 20*09537850SAkhilesh Sanikop# Detect optimizations available for the current target CPU. 21*09537850SAkhilesh Sanikopmacro(libgav1_optimization_detect) 22*09537850SAkhilesh Sanikop if(LIBGAV1_ENABLE_OPTIMIZATIONS) 23*09537850SAkhilesh Sanikop string(TOLOWER "${CMAKE_SYSTEM_PROCESSOR}" cpu_lowercase) 24*09537850SAkhilesh Sanikop if(cpu_lowercase MATCHES "^arm|^aarch64") 25*09537850SAkhilesh Sanikop set(libgav1_have_neon ON) 26*09537850SAkhilesh Sanikop elseif(cpu_lowercase MATCHES "^x86|amd64") 27*09537850SAkhilesh Sanikop set(libgav1_have_avx2 ON) 28*09537850SAkhilesh Sanikop set(libgav1_have_sse4 ON) 29*09537850SAkhilesh Sanikop endif() 30*09537850SAkhilesh Sanikop endif() 31*09537850SAkhilesh Sanikop 32*09537850SAkhilesh Sanikop if(libgav1_have_avx2 AND LIBGAV1_ENABLE_AVX2) 33*09537850SAkhilesh Sanikop list(APPEND libgav1_defines "LIBGAV1_ENABLE_AVX2=1") 34*09537850SAkhilesh Sanikop else() 35*09537850SAkhilesh Sanikop list(APPEND libgav1_defines "LIBGAV1_ENABLE_AVX2=0") 36*09537850SAkhilesh Sanikop set(libgav1_have_avx2 OFF) 37*09537850SAkhilesh Sanikop endif() 38*09537850SAkhilesh Sanikop 39*09537850SAkhilesh Sanikop if(libgav1_have_neon AND LIBGAV1_ENABLE_NEON) 40*09537850SAkhilesh Sanikop list(APPEND libgav1_defines "LIBGAV1_ENABLE_NEON=1") 41*09537850SAkhilesh Sanikop else() 42*09537850SAkhilesh Sanikop list(APPEND libgav1_defines "LIBGAV1_ENABLE_NEON=0") 43*09537850SAkhilesh Sanikop set(libgav1_have_neon, OFF) 44*09537850SAkhilesh Sanikop endif() 45*09537850SAkhilesh Sanikop 46*09537850SAkhilesh Sanikop if(libgav1_have_sse4 AND LIBGAV1_ENABLE_SSE4_1) 47*09537850SAkhilesh Sanikop list(APPEND libgav1_defines "LIBGAV1_ENABLE_SSE4_1=1") 48*09537850SAkhilesh Sanikop else() 49*09537850SAkhilesh Sanikop list(APPEND libgav1_defines "LIBGAV1_ENABLE_SSE4_1=0") 50*09537850SAkhilesh Sanikop set(libgav1_have_sse4 OFF) 51*09537850SAkhilesh Sanikop endif() 52*09537850SAkhilesh Sanikopendmacro() 53