include(${CMAKE_CURRENT_SOURCE_DIR}/../libSceAudiodec/AudiodecLibrary.cmake)
add_sce_audiodec_library(libSceAudiodec.native)
target_link_libraries(libSceAudiodec.native PRIVATE libSceAjmi libSceAjm.native)
target_sources(libSceAudiodec.native PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}/Export.cpp)

if(BUILD_TESTING)
    add_test_executable(guest_audiodec_ajm_context_tests ${LIBS_INCLUDE_DIR}/tests/GuestAudiodecAjmContext.cpp)
    target_include_directories(guest_audiodec_ajm_context_tests PRIVATE ${LIBS_INCLUDE_DIR})
    target_link_libraries(guest_audiodec_ajm_context_tests PRIVATE libSceAudiodec.native libc ${CMAKE_DL_LIBS})
    configure_windows_unwind(guest_audiodec_ajm_context_tests)
    add_test(NAME guest_audiodec_ajm_context COMMAND guest_audiodec_ajm_context_tests)
    if(WIN32)
        set_tests_properties(guest_audiodec_ajm_context PROPERTIES ENVIRONMENT_MODIFICATION
            "PATH=path_list_prepend:$<TARGET_FILE_DIR:libSceAudiodec.native>")
    endif()
endif()

if(BUILD_TESTING)
    add_test_executable(guest_audiodec_ajm_context_pointer_tests ${LIBS_INCLUDE_DIR}/tests/GuestAudiodecAjmContextPointers.cpp)
    target_include_directories(guest_audiodec_ajm_context_pointer_tests PRIVATE ${LIBS_INCLUDE_DIR})
    target_link_libraries(guest_audiodec_ajm_context_pointer_tests PRIVATE libSceAudiodec.native libc ${CMAKE_DL_LIBS})
    configure_windows_unwind(guest_audiodec_ajm_context_pointer_tests)
    add_test(NAME guest_audiodec_ajm_context_pointer COMMAND guest_audiodec_ajm_context_pointer_tests)
    if(WIN32)
        set_tests_properties(guest_audiodec_ajm_context_pointer PROPERTIES ENVIRONMENT_MODIFICATION
            "PATH=path_list_prepend:$<TARGET_FILE_DIR:libSceAudiodec.native>")
    endif()
endif()

if(BUILD_TESTING)
    add_test_executable(guest_audiodec_native_tests ${LIBS_INCLUDE_DIR}/tests/GuestAudiodecNative.cpp)
    target_include_directories(guest_audiodec_native_tests PRIVATE ${LIBS_INCLUDE_DIR})
    target_link_libraries(guest_audiodec_native_tests PRIVATE libSceAudiodec.native libSceAjm.native libSceAjmi libkernel libc ${CMAKE_DL_LIBS})
    configure_windows_unwind(guest_audiodec_native_tests)
    add_test(NAME guest_audiodec_native COMMAND guest_audiodec_native_tests $<TARGET_FILE:libSceAudiodec.native>)
    if(WIN32)
        set_tests_properties(guest_audiodec_native PROPERTIES ENVIRONMENT_MODIFICATION
            "PATH=path_list_prepend:$<TARGET_FILE_DIR:libSceAudiodec.native>")
    endif()
endif()
