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_metrics_tests ${LIBS_INCLUDE_DIR}/tests/GuestFontMetrics.cpp)
    target_include_directories(guest_font_metrics_tests PRIVATE ${LIBS_INCLUDE_DIR})
    target_link_libraries(guest_font_metrics_tests PRIVATE libSceFont libSceFontFt libc)
    configure_windows_unwind(guest_font_metrics_tests)
    add_test(NAME guest_font_metrics COMMAND guest_font_metrics_tests)
    if(WIN32)
        set_tests_properties(guest_font_metrics PROPERTIES ENVIRONMENT_MODIFICATION
            "PATH=path_list_prepend:$<TARGET_FILE_DIR:libSceFont>")
    endif()
    add_test_executable(guest_font_style_information_tests ${LIBS_INCLUDE_DIR}/tests/GuestFontStyleInformation.cpp)
    target_include_directories(guest_font_style_information_tests PRIVATE ${LIBS_INCLUDE_DIR})
    target_link_libraries(guest_font_style_information_tests PRIVATE libSceFont libSceFontFt libc)
    configure_windows_unwind(guest_font_style_information_tests)
    add_test(NAME guest_font_style_information COMMAND guest_font_style_information_tests)
    if(WIN32)
        set_tests_properties(guest_font_style_information PROPERTIES ENVIRONMENT_MODIFICATION
            "PATH=path_list_prepend:$<TARGET_FILE_DIR:libSceFont>")
    endif()
    add_test_executable(guest_font_outline_profile_tests ${LIBS_INCLUDE_DIR}/tests/GuestFontOutlineProfile.cpp)
    target_include_directories(guest_font_outline_profile_tests PRIVATE ${LIBS_INCLUDE_DIR})
    target_link_libraries(guest_font_outline_profile_tests PRIVATE libSceFont libSceFontFt libc)
    configure_windows_unwind(guest_font_outline_profile_tests)
    add_test(NAME guest_font_outline_profile COMMAND guest_font_outline_profile_tests)
    if(WIN32)
        set_tests_properties(guest_font_outline_profile 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(guest_font_graphics_tests ${LIBS_INCLUDE_DIR}/tests/GuestFontGraphics.cpp)
    target_include_directories(guest_font_graphics_tests PRIVATE ${LIBS_INCLUDE_DIR})
    target_link_libraries(guest_font_graphics_tests PRIVATE libSceFont libc)
    configure_windows_unwind(guest_font_graphics_tests)
    add_test(NAME guest_font_graphics COMMAND guest_font_graphics_tests)
    if(WIN32)
        set_tests_properties(guest_font_graphics 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()
    add_test_executable(guest_font_words_tests ${LIBS_INCLUDE_DIR}/tests/GuestFontWords.cpp)
    target_include_directories(guest_font_words_tests PRIVATE ${LIBS_INCLUDE_DIR})
    target_link_libraries(guest_font_words_tests PRIVATE libSceFont libc)
    configure_windows_unwind(guest_font_words_tests)
    add_test(NAME guest_font_words COMMAND guest_font_words_tests)
    if(WIN32)
        set_tests_properties(guest_font_words PROPERTIES ENVIRONMENT_MODIFICATION
            "PATH=path_list_prepend:$<TARGET_FILE_DIR:libSceFont>")
    endif()
endif()
