add_library(libcairo SHARED EXCLUDE_FROM_ALL Export.cpp Matrix.cpp Surface.cpp Png.cpp Context.cpp FontOptions.cpp Region.cpp Glyph.cpp FontFace.cpp)
target_sources(libcairo PRIVATE ToyText.cpp FontPipeline.cpp Device.cpp)
target_sources(libcairo PRIVATE Mesh.cpp)
target_include_directories(libcairo PRIVATE ${LIBS_INCLUDE_DIR})
include(${CMAKE_SOURCE_DIR}/cmake/Cairo.cmake)
target_link_libraries(libcairo PRIVATE cairo_backend)
configure_windows_unwind(libcairo)
target_sources(libcairo PRIVATE SurfacePattern.cpp)
target_sources(libcairo PRIVATE GlyphDrawing.cpp)
target_sources(libcairo PRIVATE ContextFontOptions.cpp)
if(MINGW OR CMAKE_SYSTEM_NAME STREQUAL "Linux")
    target_link_options(libcairo PRIVATE LINKER:--exclude-libs,ALL)
elseif(APPLE)
    target_link_options(libcairo PRIVATE
        LINKER:-unexported_symbol,_aps5_cairo_*
        LINKER:-unexported_symbol,_pixman_*
        LINKER:-unexported_symbol,__pixman_*
        LINKER:-unexported_symbol,_png_*)
endif()

target_sources(libcairo PRIVATE ScaledFont.cpp)

if(BUILD_TESTING)
    add_test_executable(guest_cairo_device_tests ${LIBS_INCLUDE_DIR}/tests/GuestCairoDevice.cpp)
    target_include_directories(guest_cairo_device_tests PRIVATE ${LIBS_INCLUDE_DIR})
    target_link_libraries(guest_cairo_device_tests PRIVATE libcairo cairo_backend)
    configure_windows_unwind(guest_cairo_device_tests)
    add_test(NAME guest_cairo_device COMMAND guest_cairo_device_tests)
    set_tests_properties(guest_cairo_device PROPERTIES TIMEOUT 20)
    if(WIN32)
        set_tests_properties(guest_cairo_device PROPERTIES ENVIRONMENT_MODIFICATION
            "PATH=path_list_prepend:$<TARGET_FILE_DIR:libcairo>")
    endif()

    add_test_executable(guest_cairo_font_pipeline_tests
        ${LIBS_INCLUDE_DIR}/tests/GuestCairoFontPipeline.cpp
        ${LIBS_INCLUDE_DIR}/tests/GuestCairoFontPipelineReference.cpp)
    target_include_directories(guest_cairo_font_pipeline_tests PRIVATE ${LIBS_INCLUDE_DIR})
    target_link_libraries(guest_cairo_font_pipeline_tests PRIVATE libcairo cairo_backend libc)
    configure_windows_unwind(guest_cairo_font_pipeline_tests)
    foreach(mode creation conversion contexts errors faces)
        add_test(NAME guest_cairo_font_pipeline_${mode} COMMAND guest_cairo_font_pipeline_tests ${mode})
        set_tests_properties(guest_cairo_font_pipeline_${mode} PROPERTIES TIMEOUT 20)
        if(WIN32)
            set_tests_properties(guest_cairo_font_pipeline_${mode} PROPERTIES ENVIRONMENT_MODIFICATION
                "PATH=path_list_prepend:$<TARGET_FILE_DIR:libcairo>")
        endif()
    endforeach()

    add_test_executable(guest_cairo_scaled_font_tests
        ${LIBS_INCLUDE_DIR}/tests/GuestCairoScaledFont.cpp ScaledFont.cpp Context.cpp)
    target_include_directories(guest_cairo_scaled_font_tests PRIVATE ${LIBS_INCLUDE_DIR})
    target_link_libraries(guest_cairo_scaled_font_tests PRIVATE libc cairo_backend)
    configure_windows_unwind(guest_cairo_scaled_font_tests)
    add_test(NAME guest_cairo_scaled_font COMMAND guest_cairo_scaled_font_tests)
    set_tests_properties(guest_cairo_scaled_font PROPERTIES TIMEOUT 30)

    add_test_executable(guest_cairo_scaled_font_export_tests
        ${LIBS_INCLUDE_DIR}/tests/GuestCairoScaledFontExports.cpp)
    target_include_directories(guest_cairo_scaled_font_export_tests PRIVATE ${LIBS_INCLUDE_DIR})
    target_link_libraries(guest_cairo_scaled_font_export_tests PRIVATE libcairo libc)
    configure_windows_unwind(guest_cairo_scaled_font_export_tests)
    add_test(NAME guest_cairo_scaled_font_exports COMMAND guest_cairo_scaled_font_export_tests)
    set_tests_properties(guest_cairo_scaled_font_exports PROPERTIES TIMEOUT 20)
    if(WIN32)
        set_tests_properties(guest_cairo_scaled_font_exports PROPERTIES ENVIRONMENT_MODIFICATION
            "PATH=path_list_prepend:$<TARGET_FILE_DIR:libcairo>")
    endif()
    add_test_executable(guest_cairo_ft_scaled_font_tests ${LIBS_INCLUDE_DIR}/tests/GuestCairoFtScaledFont.cpp)
    target_include_directories(guest_cairo_ft_scaled_font_tests PRIVATE ${LIBS_INCLUDE_DIR})
    target_link_libraries(guest_cairo_ft_scaled_font_tests PRIVATE libcairo libc cairo_backend)
    configure_windows_unwind(guest_cairo_ft_scaled_font_tests)
    add_test(NAME guest_cairo_ft_scaled_font COMMAND guest_cairo_ft_scaled_font_tests)
    set_tests_properties(guest_cairo_ft_scaled_font PROPERTIES TIMEOUT 20)
    if(WIN32)
        set_tests_properties(guest_cairo_ft_scaled_font PROPERTIES ENVIRONMENT_MODIFICATION
            "PATH=path_list_prepend:$<TARGET_FILE_DIR:libcairo>")
    endif()
    add_test_executable(guest_cairo_mesh_tests ${LIBS_INCLUDE_DIR}/tests/GuestCairoMesh.cpp)
    target_include_directories(guest_cairo_mesh_tests PRIVATE ${LIBS_INCLUDE_DIR})
    target_link_libraries(guest_cairo_mesh_tests PRIVATE libcairo cairo_backend)
    configure_windows_unwind(guest_cairo_mesh_tests)
    foreach(mode geometry errors raster)
        add_test(NAME guest_cairo_mesh_${mode} COMMAND guest_cairo_mesh_tests ${mode})
        set_tests_properties(guest_cairo_mesh_${mode} PROPERTIES TIMEOUT 20)
        if(WIN32)
            set_tests_properties(guest_cairo_mesh_${mode} PROPERTIES ENVIRONMENT_MODIFICATION
                "PATH=path_list_prepend:$<TARGET_FILE_DIR:libcairo>")
        endif()
    endforeach()

    add_test_executable(guest_cairo_surface_pattern_tests ${LIBS_INCLUDE_DIR}/tests/GuestCairoSurfacePattern.cpp)
    target_include_directories(guest_cairo_surface_pattern_tests PRIVATE ${LIBS_INCLUDE_DIR})
    target_link_libraries(guest_cairo_surface_pattern_tests PRIVATE libcairo cairo_backend)
    configure_windows_unwind(guest_cairo_surface_pattern_tests)
    foreach(mode patterns source mask)
        add_test(NAME guest_cairo_surface_pattern_${mode} COMMAND guest_cairo_surface_pattern_tests ${mode})
        set_tests_properties(guest_cairo_surface_pattern_${mode} PROPERTIES TIMEOUT 20)
        if(WIN32)
            set_tests_properties(guest_cairo_surface_pattern_${mode} PROPERTIES ENVIRONMENT_MODIFICATION
                "PATH=path_list_prepend:$<TARGET_FILE_DIR:libcairo>")
        endif()
    endforeach()

    add_test_executable(guest_cairo_glyph_drawing_tests ${LIBS_INCLUDE_DIR}/tests/GuestCairoGlyphDrawing.cpp)
    target_include_directories(guest_cairo_glyph_drawing_tests PRIVATE ${LIBS_INCLUDE_DIR})
    target_link_libraries(guest_cairo_glyph_drawing_tests PRIVATE libcairo cairo_backend)
    configure_windows_unwind(guest_cairo_glyph_drawing_tests)
    foreach(mode show errors path)
        add_test(NAME guest_cairo_glyph_drawing_${mode} COMMAND guest_cairo_glyph_drawing_tests ${mode})
        set_tests_properties(guest_cairo_glyph_drawing_${mode} PROPERTIES TIMEOUT 20)
        if(WIN32)
            set_tests_properties(guest_cairo_glyph_drawing_${mode} PROPERTIES ENVIRONMENT_MODIFICATION
                "PATH=path_list_prepend:$<TARGET_FILE_DIR:libcairo>")
        endif()
    endforeach()

    add_test_executable(guest_cairo_context_font_options_tests
        ${LIBS_INCLUDE_DIR}/tests/GuestCairoContextFontOptions.cpp
        ${LIBS_INCLUDE_DIR}/tests/GuestCairoContextFontOptionsReference.cpp)
    target_include_directories(guest_cairo_context_font_options_tests PRIVATE ${LIBS_INCLUDE_DIR})
    target_link_libraries(guest_cairo_context_font_options_tests PRIVATE libcairo cairo_backend)
    configure_windows_unwind(guest_cairo_context_font_options_tests)
    foreach(mode values render errors)
        add_test(NAME guest_cairo_context_font_options_${mode} COMMAND guest_cairo_context_font_options_tests ${mode})
        set_tests_properties(guest_cairo_context_font_options_${mode} PROPERTIES TIMEOUT 20)
        if(WIN32)
            set_tests_properties(guest_cairo_context_font_options_${mode} PROPERTIES ENVIRONMENT_MODIFICATION
                "PATH=path_list_prepend:$<TARGET_FILE_DIR:libcairo>")
        endif()
    endforeach()

    add_test_executable(guest_cairo_png_tests ${LIBS_INCLUDE_DIR}/tests/GuestCairoPng.cpp)
    target_include_directories(guest_cairo_png_tests PRIVATE ${LIBS_INCLUDE_DIR})
    target_link_libraries(guest_cairo_png_tests PRIVATE libcairo libc decoder_png)
    configure_windows_unwind(guest_cairo_png_tests)
    add_test(NAME guest_cairo_png COMMAND guest_cairo_png_tests)
    set_tests_properties(guest_cairo_png PROPERTIES TIMEOUT 20)
    if(WIN32)
        set_tests_properties(guest_cairo_png PROPERTIES ENVIRONMENT_MODIFICATION
            "PATH=path_list_prepend:$<TARGET_FILE_DIR:libcairo>")
    endif()

    add_test_executable(guest_cairo_matrix_tests ${LIBS_INCLUDE_DIR}/tests/GuestCairoMatrix.cpp)
    target_include_directories(guest_cairo_matrix_tests PRIVATE ${LIBS_INCLUDE_DIR})
    target_link_libraries(guest_cairo_matrix_tests PRIVATE libcairo libc)
    configure_windows_unwind(guest_cairo_matrix_tests)
    add_test(NAME guest_cairo_matrix COMMAND guest_cairo_matrix_tests)
    set_tests_properties(guest_cairo_matrix PROPERTIES TIMEOUT 20)
    if(WIN32)
        set_tests_properties(guest_cairo_matrix PROPERTIES ENVIRONMENT_MODIFICATION
            "PATH=path_list_prepend:$<TARGET_FILE_DIR:libcairo>")
    endif()
    add_test_executable(guest_cairo_matrix_guest_pointer_tests ${LIBS_INCLUDE_DIR}/tests/GuestCairoMatrixGuestPointers.cpp)
    target_include_directories(guest_cairo_matrix_guest_pointer_tests PRIVATE ${LIBS_INCLUDE_DIR})
    target_link_libraries(guest_cairo_matrix_guest_pointer_tests PRIVATE libcairo libc)
    configure_windows_unwind(guest_cairo_matrix_guest_pointer_tests)
    add_test(NAME guest_cairo_matrix_guest_pointers COMMAND guest_cairo_matrix_guest_pointer_tests)
    set_tests_properties(guest_cairo_matrix_guest_pointers PROPERTIES TIMEOUT 20)
    if(WIN32)
        set_tests_properties(guest_cairo_matrix_guest_pointers PROPERTIES ENVIRONMENT_MODIFICATION
            "PATH=path_list_prepend:$<TARGET_FILE_DIR:libcairo>")
    endif()
    add_test_executable(guest_cairo_surface_tests ${LIBS_INCLUDE_DIR}/tests/GuestCairoSurface.cpp)
    target_include_directories(guest_cairo_surface_tests PRIVATE ${LIBS_INCLUDE_DIR})
    target_link_libraries(guest_cairo_surface_tests PRIVATE libcairo libc)
    configure_windows_unwind(guest_cairo_surface_tests)
    add_test(NAME guest_cairo_surface COMMAND guest_cairo_surface_tests)
    set_tests_properties(guest_cairo_surface PROPERTIES TIMEOUT 20)
    if(WIN32)
        set_tests_properties(guest_cairo_surface PROPERTIES ENVIRONMENT_MODIFICATION
            "PATH=path_list_prepend:$<TARGET_FILE_DIR:libcairo>")
    endif()
    add_test_executable(guest_cairo_surface_user_data_tests ${LIBS_INCLUDE_DIR}/tests/GuestCairoSurfaceUserData.cpp)
    target_include_directories(guest_cairo_surface_user_data_tests PRIVATE ${LIBS_INCLUDE_DIR})
    target_link_libraries(guest_cairo_surface_user_data_tests PRIVATE libcairo libc)
    configure_windows_unwind(guest_cairo_surface_user_data_tests)
    add_test(NAME guest_cairo_surface_user_data COMMAND guest_cairo_surface_user_data_tests)
    set_tests_properties(guest_cairo_surface_user_data PROPERTIES TIMEOUT 20)
    if(WIN32)
        set_tests_properties(guest_cairo_surface_user_data PROPERTIES ENVIRONMENT_MODIFICATION
            "PATH=path_list_prepend:$<TARGET_FILE_DIR:libcairo>")
    endif()
    add_test_executable(guest_cairo_surface_user_data_allocation_tests
        ${LIBS_INCLUDE_DIR}/tests/GuestCairoSurfaceUserDataAllocation.cpp Surface.cpp)
    target_include_directories(guest_cairo_surface_user_data_allocation_tests PRIVATE ${LIBS_INCLUDE_DIR})
    target_link_libraries(guest_cairo_surface_user_data_allocation_tests PRIVATE cairo_backend libc)
    configure_windows_unwind(guest_cairo_surface_user_data_allocation_tests)
    add_test(NAME guest_cairo_surface_user_data_allocation COMMAND guest_cairo_surface_user_data_allocation_tests)
    set_tests_properties(guest_cairo_surface_user_data_allocation PROPERTIES TIMEOUT 20)
    if(WIN32)
        set_tests_properties(guest_cairo_surface_user_data_allocation PROPERTIES ENVIRONMENT_MODIFICATION
            "PATH=path_list_prepend:$<TARGET_FILE_DIR:libc>")
    endif()
    add_test_executable(guest_cairo_context_tests ${LIBS_INCLUDE_DIR}/tests/GuestCairoContext.cpp)
    target_include_directories(guest_cairo_context_tests PRIVATE ${LIBS_INCLUDE_DIR})
    target_link_libraries(guest_cairo_context_tests PRIVATE libcairo libc)
    configure_windows_unwind(guest_cairo_context_tests)
    add_test(NAME guest_cairo_context COMMAND guest_cairo_context_tests)
    set_tests_properties(guest_cairo_context PROPERTIES TIMEOUT 20)
    if(WIN32)
        set_tests_properties(guest_cairo_context PROPERTIES ENVIRONMENT_MODIFICATION
            "PATH=path_list_prepend:$<TARGET_FILE_DIR:libcairo>")
    endif()
    add_test_executable(guest_cairo_font_options_tests ${LIBS_INCLUDE_DIR}/tests/GuestCairoFontOptions.cpp)
    target_include_directories(guest_cairo_font_options_tests PRIVATE ${LIBS_INCLUDE_DIR})
    target_link_libraries(guest_cairo_font_options_tests PRIVATE libcairo libc)
    configure_windows_unwind(guest_cairo_font_options_tests)
    add_test(NAME guest_cairo_font_options COMMAND guest_cairo_font_options_tests)
    set_tests_properties(guest_cairo_font_options PROPERTIES TIMEOUT 20)
    if(WIN32)
        set_tests_properties(guest_cairo_font_options PROPERTIES ENVIRONMENT_MODIFICATION
            "PATH=path_list_prepend:$<TARGET_FILE_DIR:libcairo>")
    endif()
    add_test_executable(guest_cairo_regions_tests ${LIBS_INCLUDE_DIR}/tests/GuestCairoRegions.cpp)
    target_include_directories(guest_cairo_regions_tests PRIVATE ${LIBS_INCLUDE_DIR})
    target_link_libraries(guest_cairo_regions_tests PRIVATE libcairo libc)
    configure_windows_unwind(guest_cairo_regions_tests)
    add_test(NAME guest_cairo_regions COMMAND guest_cairo_regions_tests)
    set_tests_properties(guest_cairo_regions PROPERTIES TIMEOUT 20)
    if(WIN32)
        set_tests_properties(guest_cairo_regions PROPERTIES ENVIRONMENT_MODIFICATION
            "PATH=path_list_prepend:$<TARGET_FILE_DIR:libcairo>")
    endif()
    add_test_executable(guest_cairo_graphics_state_tests ${LIBS_INCLUDE_DIR}/tests/GuestCairoGraphicsState.cpp)
    target_include_directories(guest_cairo_graphics_state_tests PRIVATE ${LIBS_INCLUDE_DIR})
    target_link_libraries(guest_cairo_graphics_state_tests PRIVATE libcairo libc)
    configure_windows_unwind(guest_cairo_graphics_state_tests)
    add_test(NAME guest_cairo_graphics_state COMMAND guest_cairo_graphics_state_tests)
    set_tests_properties(guest_cairo_graphics_state PROPERTIES TIMEOUT 20)
    if(WIN32)
        set_tests_properties(guest_cairo_graphics_state PROPERTIES ENVIRONMENT_MODIFICATION
            "PATH=path_list_prepend:$<TARGET_FILE_DIR:libcairo>")
    endif()
    add_test_executable(guest_cairo_font_face_tests ${LIBS_INCLUDE_DIR}/tests/GuestCairoFontFace.cpp)
    target_include_directories(guest_cairo_font_face_tests PRIVATE ${LIBS_INCLUDE_DIR})
    target_link_libraries(guest_cairo_font_face_tests PRIVATE libcairo libc)
    configure_windows_unwind(guest_cairo_font_face_tests)
    add_test(NAME guest_cairo_font_face COMMAND guest_cairo_font_face_tests)
    set_tests_properties(guest_cairo_font_face PROPERTIES TIMEOUT 20)
    if(WIN32)
        set_tests_properties(guest_cairo_font_face PROPERTIES ENVIRONMENT_MODIFICATION
            "PATH=path_list_prepend:$<TARGET_FILE_DIR:libcairo>")
    endif()
    add_test_executable(guest_cairo_path_tests ${LIBS_INCLUDE_DIR}/tests/GuestCairoPath.cpp)
    target_include_directories(guest_cairo_path_tests PRIVATE ${LIBS_INCLUDE_DIR})
    target_link_libraries(guest_cairo_path_tests PRIVATE libcairo libc)
    configure_windows_unwind(guest_cairo_path_tests)
    add_test(NAME guest_cairo_path COMMAND guest_cairo_path_tests)
    set_tests_properties(guest_cairo_path PROPERTIES TIMEOUT 20)
    if(WIN32)
        set_tests_properties(guest_cairo_path PROPERTIES ENVIRONMENT_MODIFICATION
            "PATH=path_list_prepend:$<TARGET_FILE_DIR:libcairo>")
    endif()
    add_test_executable(guest_cairo_glyph_tests ${LIBS_INCLUDE_DIR}/tests/GuestCairoGlyph.cpp)
    target_include_directories(guest_cairo_glyph_tests PRIVATE ${LIBS_INCLUDE_DIR})
    target_link_libraries(guest_cairo_glyph_tests PRIVATE libcairo libc)
    configure_windows_unwind(guest_cairo_glyph_tests)
    add_test(NAME guest_cairo_glyph COMMAND guest_cairo_glyph_tests)
    set_tests_properties(guest_cairo_glyph PROPERTIES TIMEOUT 20)
    if(WIN32)
        set_tests_properties(guest_cairo_glyph PROPERTIES ENVIRONMENT_MODIFICATION
            "PATH=path_list_prepend:$<TARGET_FILE_DIR:libcairo>")
    endif()
    add_test_executable(guest_cairo_geometry_tests ${LIBS_INCLUDE_DIR}/tests/GuestCairoGeometry.cpp)
    target_include_directories(guest_cairo_geometry_tests PRIVATE ${LIBS_INCLUDE_DIR})
    target_link_libraries(guest_cairo_geometry_tests PRIVATE libcairo libc)
    configure_windows_unwind(guest_cairo_geometry_tests)
    add_test(NAME guest_cairo_geometry COMMAND guest_cairo_geometry_tests)
    set_tests_properties(guest_cairo_geometry PROPERTIES TIMEOUT 20)
    if(WIN32)
        set_tests_properties(guest_cairo_geometry PROPERTIES ENVIRONMENT_MODIFICATION
            "PATH=path_list_prepend:$<TARGET_FILE_DIR:libcairo>")
    endif()
    add_test_executable(guest_cairo_path_extents_tests ${LIBS_INCLUDE_DIR}/tests/GuestCairoPathExtents.cpp)
    target_include_directories(guest_cairo_path_extents_tests PRIVATE ${LIBS_INCLUDE_DIR})
    target_link_libraries(guest_cairo_path_extents_tests PRIVATE libcairo libc)
    configure_windows_unwind(guest_cairo_path_extents_tests)
    add_test(NAME guest_cairo_path_extents COMMAND guest_cairo_path_extents_tests)
    set_tests_properties(guest_cairo_path_extents PROPERTIES TIMEOUT 20)
    if(WIN32)
        set_tests_properties(guest_cairo_path_extents PROPERTIES ENVIRONMENT_MODIFICATION
            "PATH=path_list_prepend:$<TARGET_FILE_DIR:libcairo>")
    endif()
    add_test_executable(guest_cairo_drawing_tests ${LIBS_INCLUDE_DIR}/tests/GuestCairoDrawing.cpp)
    target_include_directories(guest_cairo_drawing_tests PRIVATE ${LIBS_INCLUDE_DIR})
    target_link_libraries(guest_cairo_drawing_tests PRIVATE libcairo libc)
    configure_windows_unwind(guest_cairo_drawing_tests)
    add_test(NAME guest_cairo_drawing COMMAND guest_cairo_drawing_tests)
    set_tests_properties(guest_cairo_drawing PROPERTIES TIMEOUT 20)
    if(WIN32)
        set_tests_properties(guest_cairo_drawing PROPERTIES ENVIRONMENT_MODIFICATION
            "PATH=path_list_prepend:$<TARGET_FILE_DIR:libcairo>")
    endif()
    add_test_executable(guest_cairo_context_guest_pointers_tests ${LIBS_INCLUDE_DIR}/tests/GuestCairoContextGuestPointers.cpp)
    target_include_directories(guest_cairo_context_guest_pointers_tests PRIVATE ${LIBS_INCLUDE_DIR})
    target_link_libraries(guest_cairo_context_guest_pointers_tests PRIVATE libcairo cairo_backend libc)
    configure_windows_unwind(guest_cairo_context_guest_pointers_tests)
    add_test(NAME guest_cairo_context_guest_pointers COMMAND guest_cairo_context_guest_pointers_tests)
    set_tests_properties(guest_cairo_context_guest_pointers PROPERTIES TIMEOUT 20)
    if(WIN32)
        set_tests_properties(guest_cairo_context_guest_pointers PROPERTIES ENVIRONMENT_MODIFICATION
            "PATH=path_list_prepend:$<TARGET_FILE_DIR:libcairo>")
    endif()
    add_test_executable(guest_cairo_toy_text_tests ${LIBS_INCLUDE_DIR}/tests/GuestCairoToyText.cpp)
    target_include_directories(guest_cairo_toy_text_tests PRIVATE ${LIBS_INCLUDE_DIR})
    target_link_libraries(guest_cairo_toy_text_tests PRIVATE libcairo cairo_backend libc)
    configure_windows_unwind(guest_cairo_toy_text_tests)
    add_test(NAME guest_cairo_toy_text COMMAND guest_cairo_toy_text_tests)
    set_tests_properties(guest_cairo_toy_text PROPERTIES TIMEOUT 30)
    if(WIN32)
        set_tests_properties(guest_cairo_toy_text PROPERTIES ENVIRONMENT_MODIFICATION
            "PATH=path_list_prepend:$<TARGET_FILE_DIR:libcairo>")
    endif()
endif()

if(BUILD_TESTING)
    add_test_executable(guest_cairo_ft_font_options_tests ${LIBS_INCLUDE_DIR}/tests/GuestCairoFtFontOptions.cpp)
    target_include_directories(guest_cairo_ft_font_options_tests PRIVATE ${LIBS_INCLUDE_DIR})
    target_link_libraries(guest_cairo_ft_font_options_tests PRIVATE libcairo libfontconfig libc)
    configure_windows_unwind(guest_cairo_ft_font_options_tests)
    add_test(NAME guest_cairo_ft_font_options COMMAND guest_cairo_ft_font_options_tests)
    set_tests_properties(guest_cairo_ft_font_options PROPERTIES TIMEOUT 20)
    if(WIN32)
        set_tests_properties(guest_cairo_ft_font_options PROPERTIES ENVIRONMENT_MODIFICATION
            "PATH=path_list_prepend:$<TARGET_FILE_DIR:libcairo>;PATH=path_list_prepend:$<TARGET_FILE_DIR:libfontconfig>;PATH=path_list_prepend:$<TARGET_FILE_DIR:libc>")
    endif()

    add_test_executable(guest_cairo_ft_font_face_tests ${LIBS_INCLUDE_DIR}/tests/GuestCairoFtFontFace.cpp)
    target_include_directories(guest_cairo_ft_font_face_tests PRIVATE ${LIBS_INCLUDE_DIR})
    target_link_libraries(guest_cairo_ft_font_face_tests PRIVATE libcairo libfontconfig libc)
    configure_windows_unwind(guest_cairo_ft_font_face_tests)
    add_test(NAME guest_cairo_ft_font_face COMMAND guest_cairo_ft_font_face_tests)
    set_tests_properties(guest_cairo_ft_font_face PROPERTIES TIMEOUT 20)
    if(WIN32)
        set_tests_properties(guest_cairo_ft_font_face PROPERTIES ENVIRONMENT_MODIFICATION
            "PATH=path_list_prepend:$<TARGET_FILE_DIR:libcairo>;PATH=path_list_prepend:$<TARGET_FILE_DIR:libfontconfig>;PATH=path_list_prepend:$<TARGET_FILE_DIR:libc>")
    endif()
endif()

target_sources(libcairo PRIVATE src/FtFontOptions.cpp src/FtFontFace.cpp)
target_link_libraries(libcairo PRIVATE libfontconfig)
