1# SPDX-License-Identifier: Apache-2.0 2# ---------------------------------------------------------------------------- 3# Copyright 2020-2022 Arm Limited 4# 5# Licensed under the Apache License, Version 2.0 (the "License"); you may not 6# use this file except in compliance with the License. You may obtain a copy 7# of the License at: 8# 9# http://www.apache.org/licenses/LICENSE-2.0 10# 11# Unless required by applicable law or agreed to in writing, software 12# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT 13# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the 14# License for the specific language governing permissions and limitations 15# under the License. 16# ---------------------------------------------------------------------------- 17 18# Overwrite the LTO flags to force fat LTO; worth 3-4% performance 19# See https://gitlab.kitware.com/cmake/cmake/-/issues/16808 20if(CMAKE_CXX_COMPILER_ID MATCHES "GNU|Clang" AND ${CLI}) 21 set(CMAKE_CXX_COMPILE_OPTIONS_IPO "-flto") 22endif() 23 24if(${DECOMPRESSOR}) 25 set(CODEC dec) 26else() 27 set(CODEC enc) 28endif() 29 30if(${UNIVERSAL_BUILD}) 31 if(${ISA_AVX2}) 32 set(ISA_SIMD "avx2") 33 elseif(${ISA_SSE41}) 34 set(ISA_SIMD "sse4.1") 35 elseif(${ISA_SSE2}) 36 set(ISA_SIMD "sse2") 37 endif() 38 include(cmake_core.cmake) 39else() 40 set(ARTIFACTS native none neon avx2 sse4.1 sse2) 41 set(CONFIGS ${ISA_NATIVE} ${ISA_NONE} ${ISA_NEON} ${ISA_AVX2} ${ISA_SSE41} ${ISA_SSE2}) 42 list(LENGTH ARTIFACTS ARTIFACTS_LEN) 43 math(EXPR ARTIFACTS_LEN "${ARTIFACTS_LEN} - 1") 44 45 foreach(INDEX RANGE ${ARTIFACTS_LEN}) 46 list(GET ARTIFACTS ${INDEX} ARTIFACT) 47 list(GET CONFIGS ${INDEX} CONFIG) 48 if(${CONFIG}) 49 set(ISA_SIMD ${ARTIFACT}) 50 include(cmake_core.cmake) 51 endif() 52 endforeach() 53endif() 54 55# - - - - - - - - - - - - - - - - - - 56# Unit testing 57if(${UNITTEST}) 58 set(INSTALL_GTEST OFF CACHE BOOL "" FORCE) 59 add_subdirectory(GoogleTest) 60 enable_testing() 61 add_subdirectory(UnitTest) 62endif() 63