summaryrefslogtreecommitdiff
path: root/Meta/CMake/flac_spec_tests.cmake
blob: 0d44891ef9a8e5a2587eade045cc92bb91677980 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
include(utils)

if(INCLUDE_FLAC_SPEC_TESTS)
    if (CMAKE_PROJECT_NAME STREQUAL "SerenityOS")
        set(SOURCE_DIR "${SerenityOS_SOURCE_DIR}")
    else()
        set(SOURCE_DIR "${SERENITY_PROJECT_ROOT}")
    endif()
    set(FLAC_SPEC_TEST_GZ_URL https://github.com/ietf-wg-cellar/flac-test-files/archive/refs/heads/main.tar.gz)

    set(FLAC_TEST_PATH ${CMAKE_BINARY_DIR}/Tests/LibAudio/FLAC CACHE PATH "Location of FLAC tests")
    set(FLAC_SPEC_TEST_GZ_PATH ${FLAC_TEST_PATH}/flac-spec-testsuite.tar.gz)
    set(FLAC_SPEC_TEST_PATH ${FLAC_TEST_PATH}/SpecTests)

    if(NOT EXISTS ${FLAC_SPEC_TEST_GZ_PATH})
        message(STATUS "Downloading the IETF CELLAR FLAC testsuite...")
        download_file(${FLAC_SPEC_TEST_GZ_URL} ${FLAC_SPEC_TEST_GZ_PATH})
    endif()

    if(EXISTS ${FLAC_SPEC_TEST_GZ_PATH} AND NOT EXISTS ${FLAC_SPEC_TEST_PATH})
        extract_tar_path(${FLAC_TEST_PATH} ${FLAC_SPEC_TEST_GZ_PATH} "flac-test-files-main/subset/*.flac" ${FLAC_SPEC_TEST_PATH})
        file(RENAME "${FLAC_TEST_PATH}/flac-test-files-main/subset" ${FLAC_SPEC_TEST_PATH})
        file(REMOVE "${FLAC_TEST_PATH}/flac-test-files-main")
    endif()
endif()