include(${CMAKE_CURRENT_SOURCE_DIR}/FontLibrary.cmake)
add_sce_font_library(libSceFont)

if(BUILD_TESTING)
    add_test_executable(guest_font_tests ${LIBS_INCLUDE_DIR}/tests/GuestFont.cpp)
    target_include_directories(guest_font_tests PRIVATE ${LIBS_INCLUDE_DIR})
    target_link_libraries(guest_font_tests PRIVATE libSceFont libSceFontFt libc)
    configure_windows_unwind(guest_font_tests)
    add_test(NAME guest_font COMMAND guest_font_tests)
    add_test_executable(guest_system_font_tests ${LIBS_INCLUDE_DIR}/tests/GuestSystemFont.cpp)
    target_include_directories(guest_system_font_tests PRIVATE ${LIBS_INCLUDE_DIR})
    target_link_libraries(guest_system_font_tests PRIVATE libSceFont libSceFontFt libc)
    configure_windows_unwind(guest_system_font_tests)
    add_test(NAME guest_system_font COMMAND guest_system_font_tests)
    if(WIN32)
        set_tests_properties(guest_font guest_system_font PROPERTIES ENVIRONMENT_MODIFICATION
            "PATH=path_list_prepend:$<TARGET_FILE_DIR:libSceFont>")
    endif()
    add_test_executable(guest_font_writing_line_tests ${LIBS_INCLUDE_DIR}/tests/GuestFontWritingLine.cpp)
    target_include_directories(guest_font_writing_line_tests PRIVATE ${LIBS_INCLUDE_DIR})
    target_link_libraries(guest_font_writing_line_tests PRIVATE libSceFont libc)
    configure_windows_unwind(guest_font_writing_line_tests)
    add_test(NAME guest_font_writing_line COMMAND guest_font_writing_line_tests)
    if(WIN32)
        set_tests_properties(guest_font_writing_line PROPERTIES ENVIRONMENT_MODIFICATION
            "PATH=path_list_prepend:$<TARGET_FILE_DIR:libSceFont>")
    endif()
    add_test_executable(font_face_lifetime_tests ${LIBS_INCLUDE_DIR}/tests/FontFaceLifetime.cpp
            ${CMAKE_CURRENT_SOURCE_DIR}/src/State.cpp)
    target_include_directories(font_face_lifetime_tests PRIVATE ${LIBS_INCLUDE_DIR})
    target_link_libraries(font_face_lifetime_tests PRIVATE freetype libc)
    configure_windows_unwind(font_face_lifetime_tests)
    add_test(NAME font_face_lifetime COMMAND font_face_lifetime_tests)
    add_test(NAME font_face_lifetime_replace COMMAND font_face_lifetime_tests replace)
    add_test(NAME font_face_lifetime_churn COMMAND font_face_lifetime_tests churn)
    set_tests_properties(font_face_lifetime font_face_lifetime_replace font_face_lifetime_churn PROPERTIES TIMEOUT 30)
    if(WIN32)
        set_tests_properties(font_face_lifetime font_face_lifetime_replace font_face_lifetime_churn PROPERTIES ENVIRONMENT_MODIFICATION
                "PATH=path_list_prepend:$<TARGET_FILE_DIR:libc>")
    endif()
endif()
