1# Copyright 2024 Google LLC 2# 3# Licensed under the Apache License, Version 2.0 (the "License"); 4# you may not use this file except in compliance with the License. 5# You may obtain a copy of the License at 6# 7# http://www.apache.org/licenses/LICENSE-2.0 8# 9# Unless required by applicable law or agreed to in writing, software 10# distributed under the License is distributed on an "AS IS" BASIS, 11# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12# See the License for the specific language governing permissions and 13# limitations under the License. 14 15cmake_minimum_required(VERSION 3.10) 16 17project(crabby_avif_c_api_tests) 18 19enable_testing() 20 21set(CMAKE_C_COMPILER "clang") 22set(CMAKE_CXX_COMPILER "clang++") 23 24cmake_path(GET CMAKE_CURRENT_SOURCE_DIR PARENT_PATH CARGO_ROOT_DIR) 25 26set(GTEST_INCLUDE_DIR "${CARGO_ROOT_DIR}/external/googletest/googletest/include") 27set(GTEST_LIBRARIES "${CARGO_ROOT_DIR}/external/googletest/build/lib/libgtest.a") 28set(GTEST_MAIN_LIBRARIES "${CARGO_ROOT_DIR}/external/googletest/build/lib/libgtest_main.a") 29 30set(CRABBY_AVIF_INCLUDE_DIR "${CARGO_ROOT_DIR}/include") 31set(CRABBY_AVIF_LIBRARIES "${CARGO_ROOT_DIR}/target/release/libcrabby_avif.so") 32 33macro(add_avif_gtest TEST_NAME) 34 add_executable(${TEST_NAME} ${TEST_NAME}.cc) 35 target_include_directories(${TEST_NAME} PRIVATE ${GTEST_INCLUDE_DIR}) 36 target_include_directories(${TEST_NAME} PRIVATE ${CRABBY_AVIF_INCLUDE_DIR}) 37 target_link_libraries(${TEST_NAME} PRIVATE ${GTEST_LIBRARIES}) 38 target_link_libraries(${TEST_NAME} PRIVATE ${GTEST_MAIN_LIBRARIES}) 39 target_link_libraries(${TEST_NAME} PRIVATE ${CRABBY_AVIF_LIBRARIES}) 40 add_test(NAME ${TEST_NAME} COMMAND ${TEST_NAME} ${CARGO_ROOT_DIR}/tests/data/) 41endmacro() 42 43add_avif_gtest(avifalphanoispetest) 44add_avif_gtest(avifanimationtest) 45add_avif_gtest(avifcapitest) 46add_avif_gtest(avifclaptest) 47add_avif_gtest(avifcllitest) 48add_avif_gtest(avifdecodetest) 49add_avif_gtest(avifgainmaptest) 50add_avif_gtest(avifimagetest) 51add_avif_gtest(avifincrtest) 52add_avif_gtest(avifiotest) 53add_avif_gtest(avifkeyframetest) 54add_avif_gtest(avifmetadatatest) 55add_avif_gtest(avifprogressivetest) 56add_avif_gtest(avifreformattest) 57add_avif_gtest(avifscaletest) 58add_avif_gtest(aviftest) 59 60# Conformance test. 61add_executable(conformance_tests conformance_tests.cc) 62target_include_directories(conformance_tests PRIVATE ${GTEST_INCLUDE_DIR}) 63target_include_directories(conformance_tests PRIVATE ${CRABBY_AVIF_INCLUDE_DIR}) 64target_link_libraries(conformance_tests PRIVATE ${GTEST_LIBRARIES}) 65target_link_libraries(conformance_tests PRIVATE ${GTEST_MAIN_LIBRARIES}) 66target_link_libraries(conformance_tests PRIVATE ${CRABBY_AVIF_LIBRARIES}) 67add_test(NAME conformance_tests COMMAND conformance_tests ${CARGO_ROOT_DIR}/external/av1-avif/testFiles/) 68