1cc1dc7a3Sopenharmony_ci# SPDX-License-Identifier: Apache-2.0 2cc1dc7a3Sopenharmony_ci# ---------------------------------------------------------------------------- 3cc1dc7a3Sopenharmony_ci# Copyright 2020-2023 Arm Limited 4cc1dc7a3Sopenharmony_ci# 5cc1dc7a3Sopenharmony_ci# Licensed under the Apache License, Version 2.0 (the "License"); you may not 6cc1dc7a3Sopenharmony_ci# use this file except in compliance with the License. You may obtain a copy 7cc1dc7a3Sopenharmony_ci# of the License at: 8cc1dc7a3Sopenharmony_ci# 9cc1dc7a3Sopenharmony_ci# http://www.apache.org/licenses/LICENSE-2.0 10cc1dc7a3Sopenharmony_ci# 11cc1dc7a3Sopenharmony_ci# Unless required by applicable law or agreed to in writing, software 12cc1dc7a3Sopenharmony_ci# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT 13cc1dc7a3Sopenharmony_ci# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the 14cc1dc7a3Sopenharmony_ci# License for the specific language governing permissions and limitations 15cc1dc7a3Sopenharmony_ci# under the License. 16cc1dc7a3Sopenharmony_ci# ---------------------------------------------------------------------------- 17cc1dc7a3Sopenharmony_ci 18cc1dc7a3Sopenharmony_ciset(ASTCENC_TEST test-unit-${ASTCENC_ISA_SIMD}) 19cc1dc7a3Sopenharmony_ci 20cc1dc7a3Sopenharmony_ciadd_executable(${ASTCENC_TEST}) 21cc1dc7a3Sopenharmony_ci 22cc1dc7a3Sopenharmony_ci# Enable LTO under the conditions where the codec library will use LTO. 23cc1dc7a3Sopenharmony_ci# The library link will fail if the settings don't match 24cc1dc7a3Sopenharmony_ciif(${ASTCENC_CLI}) 25cc1dc7a3Sopenharmony_ci set_property(TARGET ${ASTCENC_TEST} 26cc1dc7a3Sopenharmony_ci PROPERTY 27cc1dc7a3Sopenharmony_ci INTERPROCEDURAL_OPTIMIZATION_RELEASE True) 28cc1dc7a3Sopenharmony_ciendif() 29cc1dc7a3Sopenharmony_ci 30cc1dc7a3Sopenharmony_citarget_sources(${ASTCENC_TEST} 31cc1dc7a3Sopenharmony_ci PRIVATE 32cc1dc7a3Sopenharmony_ci test_simd.cpp 33cc1dc7a3Sopenharmony_ci test_softfloat.cpp 34cc1dc7a3Sopenharmony_ci test_decode.cpp 35cc1dc7a3Sopenharmony_ci ../astcenc_mathlib_softfloat.cpp) 36cc1dc7a3Sopenharmony_ci 37cc1dc7a3Sopenharmony_citarget_include_directories(${ASTCENC_TEST} 38cc1dc7a3Sopenharmony_ci PRIVATE 39cc1dc7a3Sopenharmony_ci ${gtest_SOURCE_DIR}/include) 40cc1dc7a3Sopenharmony_ci 41cc1dc7a3Sopenharmony_citarget_link_libraries(${ASTCENC_TEST} 42cc1dc7a3Sopenharmony_ci PRIVATE 43cc1dc7a3Sopenharmony_ci astcenc-${ASTCENC_ISA_SIMD}-static) 44cc1dc7a3Sopenharmony_ci 45cc1dc7a3Sopenharmony_citarget_compile_options(${ASTCENC_TEST} 46cc1dc7a3Sopenharmony_ci PRIVATE 47cc1dc7a3Sopenharmony_ci # Use pthreads on Linux/macOS 48cc1dc7a3Sopenharmony_ci $<$<PLATFORM_ID:Linux,Darwin>:-pthread> 49cc1dc7a3Sopenharmony_ci 50cc1dc7a3Sopenharmony_ci # MSVC compiler defines 51cc1dc7a3Sopenharmony_ci $<$<CXX_COMPILER_ID:MSVC>:/EHsc> 52cc1dc7a3Sopenharmony_ci 53cc1dc7a3Sopenharmony_ci # G++ and Clang++ compiler defines 54cc1dc7a3Sopenharmony_ci $<$<NOT:$<CXX_COMPILER_ID:MSVC>>:-Wall> 55cc1dc7a3Sopenharmony_ci $<$<NOT:$<CXX_COMPILER_ID:MSVC>>:-Wextra> 56cc1dc7a3Sopenharmony_ci $<$<NOT:$<CXX_COMPILER_ID:MSVC>>:-Wpedantic> 57cc1dc7a3Sopenharmony_ci $<$<NOT:$<CXX_COMPILER_ID:MSVC>>:-Werror> 58cc1dc7a3Sopenharmony_ci $<$<NOT:$<CXX_COMPILER_ID:MSVC>>:-Wshadow> 59cc1dc7a3Sopenharmony_ci $<$<NOT:$<CXX_COMPILER_ID:MSVC>>:-Wno-c++98-compat-pedantic> 60cc1dc7a3Sopenharmony_ci $<$<NOT:$<CXX_COMPILER_ID:MSVC>>:-Wno-c++98-c++11-compat-pedantic> 61cc1dc7a3Sopenharmony_ci $<$<NOT:$<CXX_COMPILER_ID:MSVC>>:-Wno-float-equal> 62cc1dc7a3Sopenharmony_ci 63cc1dc7a3Sopenharmony_ci # Ignore things that the googletest build triggers 64cc1dc7a3Sopenharmony_ci $<$<NOT:$<CXX_COMPILER_ID:MSVC>>:-Wno-unknown-warning-option> 65cc1dc7a3Sopenharmony_ci $<$<NOT:$<CXX_COMPILER_ID:MSVC>>:-Wno-double-promotion> 66cc1dc7a3Sopenharmony_ci $<$<NOT:$<CXX_COMPILER_ID:MSVC>>:-Wno-undef> 67cc1dc7a3Sopenharmony_ci $<$<NOT:$<CXX_COMPILER_ID:MSVC>>:-Wno-reserved-identifier> 68cc1dc7a3Sopenharmony_ci $<$<NOT:$<CXX_COMPILER_ID:MSVC>>:-Wno-global-constructors>) 69cc1dc7a3Sopenharmony_ci 70cc1dc7a3Sopenharmony_ci# Set up configuration for SIMD ISA builds 71cc1dc7a3Sopenharmony_ciif(${ASTCENC_ISA_SIMD} MATCHES "none") 72cc1dc7a3Sopenharmony_ci target_compile_definitions(${ASTCENC_TEST} 73cc1dc7a3Sopenharmony_ci PRIVATE 74cc1dc7a3Sopenharmony_ci ASTCENC_NEON=0 75cc1dc7a3Sopenharmony_ci ASTCENC_SSE=0 76cc1dc7a3Sopenharmony_ci ASTCENC_AVX=0 77cc1dc7a3Sopenharmony_ci ASTCENC_POPCNT=0 78cc1dc7a3Sopenharmony_ci ASTCENC_F16C=0) 79cc1dc7a3Sopenharmony_ci 80cc1dc7a3Sopenharmony_cielseif(${ASTCENC_ISA_SIMD} MATCHES "neon") 81cc1dc7a3Sopenharmony_ci target_compile_definitions(${ASTCENC_TEST} 82cc1dc7a3Sopenharmony_ci PRIVATE 83cc1dc7a3Sopenharmony_ci ASTCENC_NEON=1 84cc1dc7a3Sopenharmony_ci ASTCENC_SSE=0 85cc1dc7a3Sopenharmony_ci ASTCENC_AVX=0 86cc1dc7a3Sopenharmony_ci ASTCENC_POPCNT=0 87cc1dc7a3Sopenharmony_ci ASTCENC_F16C=0) 88cc1dc7a3Sopenharmony_ci 89cc1dc7a3Sopenharmony_cielseif(${ASTCENC_ISA_SIMD} MATCHES "sse2") 90cc1dc7a3Sopenharmony_ci target_compile_definitions(${ASTCENC_TEST} 91cc1dc7a3Sopenharmony_ci PRIVATE 92cc1dc7a3Sopenharmony_ci ASTCENC_NEON=0 93cc1dc7a3Sopenharmony_ci ASTCENC_SSE=20 94cc1dc7a3Sopenharmony_ci ASTCENC_AVX=0 95cc1dc7a3Sopenharmony_ci ASTCENC_POPCNT=0 96cc1dc7a3Sopenharmony_ci ASTCENC_F16C=0) 97cc1dc7a3Sopenharmony_ci 98cc1dc7a3Sopenharmony_ci target_compile_options(${ASTCENC_TEST} 99cc1dc7a3Sopenharmony_ci PRIVATE 100cc1dc7a3Sopenharmony_ci $<$<CXX_COMPILER_ID:${GNU_LIKE}>:-msse2>) 101cc1dc7a3Sopenharmony_ci 102cc1dc7a3Sopenharmony_cielseif(${ASTCENC_ISA_SIMD} MATCHES "sse4.1") 103cc1dc7a3Sopenharmony_ci target_compile_definitions(${ASTCENC_TEST} 104cc1dc7a3Sopenharmony_ci PRIVATE 105cc1dc7a3Sopenharmony_ci ASTCENC_NEON=0 106cc1dc7a3Sopenharmony_ci ASTCENC_SSE=41 107cc1dc7a3Sopenharmony_ci ASTCENC_AVX=0 108cc1dc7a3Sopenharmony_ci ASTCENC_POPCNT=1 109cc1dc7a3Sopenharmony_ci ASTCENC_F16C=0) 110cc1dc7a3Sopenharmony_ci 111cc1dc7a3Sopenharmony_ci target_compile_options(${ASTCENC_TEST} 112cc1dc7a3Sopenharmony_ci PRIVATE 113cc1dc7a3Sopenharmony_ci $<$<NOT:$<CXX_COMPILER_ID:MSVC>>:-msse4.1 -mpopcnt>) 114cc1dc7a3Sopenharmony_ci 115cc1dc7a3Sopenharmony_cielseif(${ASTCENC_ISA_SIMD} MATCHES "avx2") 116cc1dc7a3Sopenharmony_ci target_compile_definitions(${ASTCENC_TEST} 117cc1dc7a3Sopenharmony_ci PRIVATE 118cc1dc7a3Sopenharmony_ci ASTCENC_NEON=0 119cc1dc7a3Sopenharmony_ci ASTCENC_SSE=41 120cc1dc7a3Sopenharmony_ci ASTCENC_AVX=2 121cc1dc7a3Sopenharmony_ci ASTCENC_POPCNT=1 122cc1dc7a3Sopenharmony_ci ASTCENC_F16C=1) 123cc1dc7a3Sopenharmony_ci 124cc1dc7a3Sopenharmony_ci target_compile_options(${ASTCENC_TEST} 125cc1dc7a3Sopenharmony_ci PRIVATE 126cc1dc7a3Sopenharmony_ci $<$<NOT:$<CXX_COMPILER_ID:MSVC>>:-mavx2 -mpopcnt -mf16c> 127cc1dc7a3Sopenharmony_ci $<$<CXX_COMPILER_ID:MSVC>:/arch:AVX2>) 128cc1dc7a3Sopenharmony_ci 129cc1dc7a3Sopenharmony_ciendif() 130cc1dc7a3Sopenharmony_ci 131cc1dc7a3Sopenharmony_citarget_link_libraries(${ASTCENC_TEST} 132cc1dc7a3Sopenharmony_ci PRIVATE 133cc1dc7a3Sopenharmony_ci gtest_main) 134cc1dc7a3Sopenharmony_ci 135cc1dc7a3Sopenharmony_ciadd_test(NAME ${ASTCENC_TEST} 136cc1dc7a3Sopenharmony_ci COMMAND ${ASTCENC_TEST}) 137cc1dc7a3Sopenharmony_ci 138cc1dc7a3Sopenharmony_ciinstall(TARGETS ${ASTCENC_TEST}) 139