• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
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(decoder_tests)
44add_avif_gtest(incremental_tests)
45add_avif_gtest(reformat_tests)
46
47# Conformance test.
48add_executable(conformance_tests conformance_tests.cc)
49target_include_directories(conformance_tests PRIVATE ${GTEST_INCLUDE_DIR})
50target_include_directories(conformance_tests PRIVATE ${CRABBY_AVIF_INCLUDE_DIR})
51target_link_libraries(conformance_tests PRIVATE ${GTEST_LIBRARIES})
52target_link_libraries(conformance_tests PRIVATE ${GTEST_MAIN_LIBRARIES})
53target_link_libraries(conformance_tests PRIVATE ${CRABBY_AVIF_LIBRARIES})
54add_test(NAME conformance_tests COMMAND conformance_tests ${CARGO_ROOT_DIR}/external/av1-avif/testFiles/)
55