cmake_minimum_required(VERSION 3.22)
project(ziran_audio_native C)
include("${CMAKE_CURRENT_LIST_DIR}/AudioCodecs.cmake")
set(codec_targets)
if(DEFINED OPUS_DIR OR DEFINED SAMPLERATE_DIR)
    ziran_audio_codecs("${OPUS_DIR}" "${SAMPLERATE_DIR}")
    list(APPEND codec_targets opus samplerate)
endif()
if(DEFINED ZIRAN_STDLIB)
    include("${ZIRAN_STDLIB}/native/AudioCodecs.cmake")
    ziran_audio_mp3()
    list(APPEND codec_targets ziran_mp3)
    option(AUDIO_CORE_VORBIS "Build the core Vorbis archives for cross targets" ON)
    if(AUDIO_CORE_VORBIS)
        ziran_audio_vorbis()
        list(APPEND codec_targets vorbisfile)
    endif()
endif()
if(NOT codec_targets)
    message(FATAL_ERROR "Pass OPUS_DIR and SAMPLERATE_DIR, ZIRAN_STDLIB, or both")
endif()
add_custom_target(codecs ALL DEPENDS ${codec_targets})
