add_library(libSceLibcInternal SHARED EXCLUDE_FROM_ALL Export.cpp FileTime.cpp Getopt.cpp SignalList.cpp Spawn.cpp UserContext.cpp)
target_include_directories(libSceLibcInternal PRIVATE ${LIBS_INCLUDE_DIR})
target_sources(libSceLibcInternal PRIVATE WideCharacterTables.cpp)
if(BUILD_TESTING)
    add_test_executable(guest_libc_internal_wide_tables_tests ${LIBS_INCLUDE_DIR}/tests/GuestLibcInternalWideTables.cpp)
    target_include_directories(guest_libc_internal_wide_tables_tests PRIVATE ${LIBS_INCLUDE_DIR})
    target_link_libraries(guest_libc_internal_wide_tables_tests PRIVATE libSceLibcInternal libkernel libc)
    configure_windows_unwind(guest_libc_internal_wide_tables_tests)
    add_test(NAME guest_libc_internal_wctype_table COMMAND guest_libc_internal_wide_tables_tests classification)
    add_test(NAME guest_libc_internal_wctrans_table COMMAND guest_libc_internal_wide_tables_tests translation)
    set_tests_properties(guest_libc_internal_wctype_table guest_libc_internal_wctrans_table PROPERTIES TIMEOUT 20)
    if(WIN32)
        set_tests_properties(guest_libc_internal_wctype_table guest_libc_internal_wctrans_table PROPERTIES ENVIRONMENT_MODIFICATION
            "PATH=path_list_prepend:$<TARGET_FILE_DIR:libSceLibcInternal>")
    endif()
endif()
if(BUILD_TESTING)
    add_test_executable(guest_libc_internal_byte_extrema_tests ${LIBS_INCLUDE_DIR}/tests/GuestLibcInternalByteExtrema.cpp)
    target_include_directories(guest_libc_internal_byte_extrema_tests PRIVATE ${LIBS_INCLUDE_DIR})
    target_link_libraries(guest_libc_internal_byte_extrema_tests PRIVATE libSceLibcInternal libc libkernel)
    configure_windows_unwind(guest_libc_internal_byte_extrema_tests)
    add_test(NAME guest_libc_internal_min_byte COMMAND guest_libc_internal_byte_extrema_tests min)
    add_test(NAME guest_libc_internal_max_byte COMMAND guest_libc_internal_byte_extrema_tests max)
    set_tests_properties(guest_libc_internal_min_byte guest_libc_internal_max_byte PROPERTIES TIMEOUT 20)
    if(WIN32)
        set_tests_properties(guest_libc_internal_min_byte guest_libc_internal_max_byte PROPERTIES ENVIRONMENT_MODIFICATION
            "PATH=path_list_prepend:$<TARGET_FILE_DIR:libSceLibcInternal>")
    endif()
endif()
set_source_files_properties(UserContext.cpp PROPERTIES COMPILE_OPTIONS -fno-omit-frame-pointer)
target_sources(libSceLibcInternal PRIVATE SignalMask.cpp)
target_link_libraries(libSceLibcInternal PRIVATE ${CMAKE_DL_LIBS})
target_sources(libSceLibcInternal PRIVATE InventoryExports2.cpp Ctype.cpp CtypeCase.cpp)
if(BUILD_TESTING)
    add_test_executable(guest_libc_internal_strerror_tests ${LIBS_INCLUDE_DIR}/tests/GuestLibcInternalStrerror.cpp)
    target_include_directories(guest_libc_internal_strerror_tests PRIVATE ${LIBS_INCLUDE_DIR})
    target_link_libraries(guest_libc_internal_strerror_tests PRIVATE libSceLibcInternal libc libkernel)
    configure_windows_unwind(guest_libc_internal_strerror_tests)
    add_test(NAME guest_libc_internal_strerror COMMAND guest_libc_internal_strerror_tests)
    set_tests_properties(guest_libc_internal_strerror PROPERTIES TIMEOUT 20)
    if(WIN32)
        set_tests_properties(guest_libc_internal_strerror PROPERTIES ENVIRONMENT_MODIFICATION
            "PATH=path_list_prepend:$<TARGET_FILE_DIR:libSceLibcInternal>")
    endif()
endif()
target_sources(libSceLibcInternal PRIVATE Directory.cpp)
target_sources(libSceLibcInternal PRIVATE MemoryResource.cpp)
target_sources(libSceLibcInternal PRIVATE InventoryExports.cpp)
if(BUILD_TESTING)
    add_test_executable(guest_libc_internal_standard_stream_init_tests ${LIBS_INCLUDE_DIR}/tests/GuestLibcInternalStandardStreamInit.cpp)
    target_include_directories(guest_libc_internal_standard_stream_init_tests PRIVATE ${LIBS_INCLUDE_DIR})
    target_link_libraries(guest_libc_internal_standard_stream_init_tests PRIVATE libSceLibcInternal libkernel libc)
    configure_windows_unwind(guest_libc_internal_standard_stream_init_tests)
    add_test(NAME guest_libc_internal_standard_stream_init COMMAND guest_libc_internal_standard_stream_init_tests)
    set_tests_properties(guest_libc_internal_standard_stream_init PROPERTIES TIMEOUT 20)
    if(WIN32)
        set_tests_properties(guest_libc_internal_standard_stream_init PROPERTIES ENVIRONMENT_MODIFICATION
            "PATH=path_list_prepend:$<TARGET_FILE_DIR:libSceLibcInternal>")
    endif()
endif()
if(BUILD_TESTING)
    add_test_executable(guest_libc_internal_rng_abort_tests ${LIBS_INCLUDE_DIR}/tests/GuestLibcInternalRngAbort.cpp)
    target_include_directories(guest_libc_internal_rng_abort_tests PRIVATE ${LIBS_INCLUDE_DIR})
    target_link_libraries(guest_libc_internal_rng_abort_tests PRIVATE libSceLibcInternal libkernel libc)
    configure_windows_unwind(guest_libc_internal_rng_abort_tests)
    add_test(NAME guest_libc_internal_rng_abort COMMAND guest_libc_internal_rng_abort_tests)
    set_tests_properties(guest_libc_internal_rng_abort PROPERTIES TIMEOUT 20)
    if(WIN32)
        set_tests_properties(guest_libc_internal_rng_abort PROPERTIES ENVIRONMENT_MODIFICATION
            "PATH=path_list_prepend:$<TARGET_FILE_DIR:libSceLibcInternal>")
    endif()
endif()
target_sources(libSceLibcInternal PRIVATE Pad.cpp)
if(BUILD_TESTING)
    add_test_executable(guest_libc_internal_pad_tests ${LIBS_INCLUDE_DIR}/tests/GuestLibcInternalPad.cpp)
    target_include_directories(guest_libc_internal_pad_tests PRIVATE ${LIBS_INCLUDE_DIR})
    target_link_libraries(guest_libc_internal_pad_tests PRIVATE libSceLibcInternal libkernel libc)
    configure_windows_unwind(guest_libc_internal_pad_tests)
    add_test(NAME guest_libc_internal_pad COMMAND guest_libc_internal_pad_tests)
    set_tests_properties(guest_libc_internal_pad PROPERTIES TIMEOUT 20)
    if(WIN32)
        set_tests_properties(guest_libc_internal_pad PROPERTIES ENVIRONMENT_MODIFICATION
            "PATH=path_list_prepend:$<TARGET_FILE_DIR:libSceLibcInternal>")
    endif()
endif()
if(BUILD_TESTING)
    add_test_executable(guest_libc_internal_time_lock_tests ${LIBS_INCLUDE_DIR}/tests/GuestLibcInternalTimeLock.cpp)
    target_include_directories(guest_libc_internal_time_lock_tests PRIVATE ${LIBS_INCLUDE_DIR})
    target_link_libraries(guest_libc_internal_time_lock_tests PRIVATE libSceLibcInternal libkernel libc)
    configure_windows_unwind(guest_libc_internal_time_lock_tests)
    add_test(NAME guest_libc_internal_time_lock COMMAND guest_libc_internal_time_lock_tests)
    set_tests_properties(guest_libc_internal_time_lock PROPERTIES TIMEOUT 20)
    if(WIN32)
        set_tests_properties(guest_libc_internal_time_lock PROPERTIES ENVIRONMENT_MODIFICATION
            "PATH=path_list_prepend:$<TARGET_FILE_DIR:libSceLibcInternal>")
    endif()
endif()
if(BUILD_TESTING)
    add_test_executable(guest_libc_internal_getdst_tests ${LIBS_INCLUDE_DIR}/tests/GuestLibcInternalGetdst.cpp)
    target_include_directories(guest_libc_internal_getdst_tests PRIVATE ${LIBS_INCLUDE_DIR})
    target_link_libraries(guest_libc_internal_getdst_tests PRIVATE libSceLibcInternal libkernel libc)
    configure_windows_unwind(guest_libc_internal_getdst_tests)
    add_test(NAME guest_libc_internal_getdst COMMAND guest_libc_internal_getdst_tests)
    set_tests_properties(guest_libc_internal_getdst PROPERTIES TIMEOUT 20)
    if(WIN32)
        set_tests_properties(guest_libc_internal_getdst PROPERTIES ENVIRONMENT_MODIFICATION
            "PATH=path_list_prepend:$<TARGET_FILE_DIR:libSceLibcInternal>")
    endif()
endif()
target_sources(libSceLibcInternal PRIVATE InitOnce.cpp)
target_sources(libSceLibcInternal PRIVATE CallOnce.cpp)
target_sources(libSceLibcInternal PRIVATE WideCollate.cpp)
if(BUILD_TESTING)
    add_test_executable(guest_libc_internal_wide_collate_tests ${LIBS_INCLUDE_DIR}/tests/GuestLibcInternalWideCollate.cpp)
    target_include_directories(guest_libc_internal_wide_collate_tests PRIVATE ${LIBS_INCLUDE_DIR})
    target_link_libraries(guest_libc_internal_wide_collate_tests PRIVATE libSceLibcInternal libkernel libc)
    configure_windows_unwind(guest_libc_internal_wide_collate_tests)
    add_test(NAME guest_libc_internal_wide_collate COMMAND guest_libc_internal_wide_collate_tests)
    set_tests_properties(guest_libc_internal_wide_collate PROPERTIES TIMEOUT 20)
    if(WIN32)
        set_tests_properties(guest_libc_internal_wide_collate PROPERTIES ENVIRONMENT_MODIFICATION
            "PATH=path_list_prepend:$<TARGET_FILE_DIR:libSceLibcInternal>")
    endif()
endif()
target_sources(libSceLibcInternal PRIVATE Mutex.cpp)
target_sources(libSceLibcInternal PRIVATE NumGet.cpp)
if(BUILD_TESTING)
    add_test_executable(guest_libc_internal_num_get_tests ${LIBS_INCLUDE_DIR}/tests/GuestLibcInternalNumGet.cpp)
    target_include_directories(guest_libc_internal_num_get_tests PRIVATE ${LIBS_INCLUDE_DIR})
    target_link_libraries(guest_libc_internal_num_get_tests PRIVATE libSceLibcInternal libkernel libc ${CMAKE_DL_LIBS})
    configure_windows_unwind(guest_libc_internal_num_get_tests)
    add_test(NAME guest_libc_internal_num_get COMMAND guest_libc_internal_num_get_tests $<TARGET_FILE:libSceLibcInternal>)
    set_tests_properties(guest_libc_internal_num_get PROPERTIES TIMEOUT 20)
    if(WIN32)
        set_tests_properties(guest_libc_internal_num_get PROPERTIES ENVIRONMENT_MODIFICATION
            "PATH=path_list_prepend:$<TARGET_FILE_DIR:libSceLibcInternal>")
    endif()
    add_test_executable(guest_libc_internal_num_get_do_get_tests ${LIBS_INCLUDE_DIR}/tests/GuestLibcInternalNumGetDoGet.cpp)
    target_include_directories(guest_libc_internal_num_get_do_get_tests PRIVATE ${LIBS_INCLUDE_DIR})
    target_link_libraries(guest_libc_internal_num_get_do_get_tests PRIVATE libSceLibcInternal libkernel libc ${CMAKE_DL_LIBS})
    configure_windows_unwind(guest_libc_internal_num_get_do_get_tests)
    add_test(NAME guest_libc_internal_num_get_do_get COMMAND guest_libc_internal_num_get_do_get_tests $<TARGET_FILE:libSceLibcInternal>)
    set_tests_properties(guest_libc_internal_num_get_do_get PROPERTIES TIMEOUT 20)
    if(WIN32)
        set_tests_properties(guest_libc_internal_num_get_do_get PROPERTIES ENVIRONMENT_MODIFICATION
            "PATH=path_list_prepend:$<TARGET_FILE_DIR:libSceLibcInternal>")
    endif()
endif()
target_sources(libSceLibcInternal PRIVATE AlignedNew.cpp)
target_sources(libSceLibcInternal PRIVATE Format.cpp)
target_sources(libSceLibcInternal PRIVATE Numpunct.cpp)
if(BUILD_TESTING)
    add_test_executable(guest_libc_internal_numpunct_tests ${LIBS_INCLUDE_DIR}/tests/GuestLibcInternalNumpunct.cpp)
    target_include_directories(guest_libc_internal_numpunct_tests PRIVATE ${LIBS_INCLUDE_DIR})
    target_link_libraries(guest_libc_internal_numpunct_tests PRIVATE libSceLibcInternal libkernel libc)
    configure_windows_unwind(guest_libc_internal_numpunct_tests)
    add_test(NAME guest_libc_internal_numpunct COMMAND guest_libc_internal_numpunct_tests)
    set_tests_properties(guest_libc_internal_numpunct PROPERTIES TIMEOUT 20)
    if(WIN32)
        set_tests_properties(guest_libc_internal_numpunct PROPERTIES ENVIRONMENT_MODIFICATION
            "PATH=path_list_prepend:$<TARGET_FILE_DIR:libSceLibcInternal>")
    endif()
endif()
if(BUILD_TESTING)
    add_test_executable(guest_libc_internal_wide_numpunct_tests ${LIBS_INCLUDE_DIR}/tests/GuestLibcInternalWideNumpunct.cpp)
    target_include_directories(guest_libc_internal_wide_numpunct_tests PRIVATE ${LIBS_INCLUDE_DIR})
    target_link_libraries(guest_libc_internal_wide_numpunct_tests PRIVATE libSceLibcInternal libkernel libc)
    configure_windows_unwind(guest_libc_internal_wide_numpunct_tests)
    add_test(NAME guest_libc_internal_wide_numpunct COMMAND guest_libc_internal_wide_numpunct_tests)
    set_tests_properties(guest_libc_internal_wide_numpunct PROPERTIES TIMEOUT 20)
    if(WIN32)
        set_tests_properties(guest_libc_internal_wide_numpunct PROPERTIES ENVIRONMENT_MODIFICATION
            "PATH=path_list_prepend:$<TARGET_FILE_DIR:libSceLibcInternal>")
    endif()
endif()
target_sources(libSceLibcInternal PRIVATE Stream.cpp)
if(BUILD_TESTING)
    add_test_executable(guest_libc_internal_stream_tests ${LIBS_INCLUDE_DIR}/tests/GuestLibcInternalStream.cpp)
    target_include_directories(guest_libc_internal_stream_tests PRIVATE ${LIBS_INCLUDE_DIR})
    target_link_libraries(guest_libc_internal_stream_tests PRIVATE libSceLibcInternal libkernel libc)
    configure_windows_unwind(guest_libc_internal_stream_tests)
    add_test(NAME guest_libc_internal_stream COMMAND guest_libc_internal_stream_tests)
    set_tests_properties(guest_libc_internal_stream PROPERTIES TIMEOUT 20)
    if(WIN32)
        set_tests_properties(guest_libc_internal_stream PROPERTIES ENVIRONMENT_MODIFICATION
            "PATH=path_list_prepend:$<TARGET_FILE_DIR:libSceLibcInternal>")
    endif()
endif()
target_sources(libSceLibcInternal PRIVATE WideCtype.cpp)
if(BUILD_TESTING)
    add_test_executable(guest_libc_internal_wide_ctype_tests ${LIBS_INCLUDE_DIR}/tests/GuestLibcInternalWideCtype.cpp)
    target_include_directories(guest_libc_internal_wide_ctype_tests PRIVATE ${LIBS_INCLUDE_DIR})
    target_link_libraries(guest_libc_internal_wide_ctype_tests PRIVATE libSceLibcInternal libkernel libc)
    configure_windows_unwind(guest_libc_internal_wide_ctype_tests)
    add_test(NAME guest_libc_internal_wide_ctype COMMAND guest_libc_internal_wide_ctype_tests)
    set_tests_properties(guest_libc_internal_wide_ctype PROPERTIES TIMEOUT 20)
    if(WIN32)
        set_tests_properties(guest_libc_internal_wide_ctype PROPERTIES ENVIRONMENT_MODIFICATION
            "PATH=path_list_prepend:$<TARGET_FILE_DIR:libSceLibcInternal>")
    endif()
endif()
if(BUILD_TESTING)
    add_test_executable(guest_libc_internal_format_tests ${LIBS_INCLUDE_DIR}/tests/GuestLibcInternalFormat.cpp)
    target_include_directories(guest_libc_internal_format_tests PRIVATE ${LIBS_INCLUDE_DIR})
    target_link_libraries(guest_libc_internal_format_tests PRIVATE libSceLibcInternal libkernel libc)
    configure_windows_unwind(guest_libc_internal_format_tests)
    add_test(NAME guest_libc_internal_format COMMAND guest_libc_internal_format_tests)
    set_tests_properties(guest_libc_internal_format PROPERTIES TIMEOUT 20)
    if(WIN32)
        set_tests_properties(guest_libc_internal_format PROPERTIES ENVIRONMENT_MODIFICATION
            "PATH=path_list_prepend:$<TARGET_FILE_DIR:libSceLibcInternal>")
    endif()
endif()
if(BUILD_TESTING)
    add_test_executable(guest_libc_internal_showmanyc_tests ${LIBS_INCLUDE_DIR}/tests/GuestLibcInternalShowmanyc.cpp)
    target_include_directories(guest_libc_internal_showmanyc_tests PRIVATE ${LIBS_INCLUDE_DIR})
    target_link_libraries(guest_libc_internal_showmanyc_tests PRIVATE libSceLibcInternal)
    configure_windows_unwind(guest_libc_internal_showmanyc_tests)
    add_test(NAME guest_libc_internal_showmanyc COMMAND guest_libc_internal_showmanyc_tests)
    set_tests_properties(guest_libc_internal_showmanyc PROPERTIES TIMEOUT 20)
    if(WIN32)
        set_tests_properties(guest_libc_internal_showmanyc PROPERTIES ENVIRONMENT_MODIFICATION
            "PATH=path_list_prepend:$<TARGET_FILE_DIR:libSceLibcInternal>")
    endif()

    add_test_executable(guest_libc_internal_aligned_new_tests ${LIBS_INCLUDE_DIR}/tests/GuestLibcInternalAlignedNew.cpp)
    target_include_directories(guest_libc_internal_aligned_new_tests PRIVATE ${LIBS_INCLUDE_DIR})
    target_link_libraries(guest_libc_internal_aligned_new_tests PRIVATE libSceLibcInternal libkernel libc)
    configure_windows_unwind(guest_libc_internal_aligned_new_tests)
    add_test(NAME guest_libc_internal_aligned_new COMMAND guest_libc_internal_aligned_new_tests)
    set_tests_properties(guest_libc_internal_aligned_new PROPERTIES TIMEOUT 20)
    if(WIN32)
        set_tests_properties(guest_libc_internal_aligned_new PROPERTIES ENVIRONMENT_MODIFICATION
            "PATH=path_list_prepend:$<TARGET_FILE_DIR:libSceLibcInternal>")
    endif()
endif()
target_sources(libSceLibcInternal PRIVATE CxxRuntimeForwards.cpp)
if(BUILD_TESTING)
    add_test_executable(guest_libc_internal_cxx_forwards_tests ${LIBS_INCLUDE_DIR}/tests/GuestLibcInternalCxxForwards.cpp)
    target_include_directories(guest_libc_internal_cxx_forwards_tests PRIVATE ${LIBS_INCLUDE_DIR})
    target_link_libraries(guest_libc_internal_cxx_forwards_tests PRIVATE libSceLibcInternal libkernel libc)
    configure_windows_unwind(guest_libc_internal_cxx_forwards_tests)
    add_test(NAME guest_libc_internal_cxx_forwards COMMAND guest_libc_internal_cxx_forwards_tests)
    set_tests_properties(guest_libc_internal_cxx_forwards PROPERTIES TIMEOUT 20)
    if(WIN32)
        set_tests_properties(guest_libc_internal_cxx_forwards PROPERTIES ENVIRONMENT_MODIFICATION
            "PATH=path_list_prepend:$<TARGET_FILE_DIR:libSceLibcInternal>")
    endif()
endif()
target_sources(libSceLibcInternal PRIVATE JumpBuffer.cpp)
if(BUILD_TESTING)
    add_test_executable(guest_libc_internal_longjmp_tests ${LIBS_INCLUDE_DIR}/tests/GuestLibcInternalLongjmp.cpp)
    target_include_directories(guest_libc_internal_longjmp_tests PRIVATE ${LIBS_INCLUDE_DIR})
    target_link_libraries(guest_libc_internal_longjmp_tests PRIVATE libSceLibcInternal libkernel libc)
    configure_windows_unwind(guest_libc_internal_longjmp_tests)
    add_test(NAME guest_libc_internal_longjmp COMMAND guest_libc_internal_longjmp_tests)
    set_tests_properties(guest_libc_internal_longjmp PROPERTIES TIMEOUT 20)
    if(WIN32)
        set_tests_properties(guest_libc_internal_longjmp PROPERTIES ENVIRONMENT_MODIFICATION
            "PATH=path_list_prepend:$<TARGET_FILE_DIR:libSceLibcInternal>")
    endif()
endif()
if(BUILD_TESTING)
    add_test_executable(guest_libc_internal_mtx_tests ${LIBS_INCLUDE_DIR}/tests/GuestLibcInternalMtx.cpp)
    target_include_directories(guest_libc_internal_mtx_tests PRIVATE ${LIBS_INCLUDE_DIR})
    target_link_libraries(guest_libc_internal_mtx_tests PRIVATE libSceLibcInternal libkernel libc)
    configure_windows_unwind(guest_libc_internal_mtx_tests)
    add_test(NAME guest_libc_internal_mtx COMMAND guest_libc_internal_mtx_tests)
    set_tests_properties(guest_libc_internal_mtx PROPERTIES TIMEOUT 20)
    if(WIN32)
        set_tests_properties(guest_libc_internal_mtx PROPERTIES ENVIRONMENT_MODIFICATION
            "PATH=path_list_prepend:$<TARGET_FILE_DIR:libSceLibcInternal>")
    endif()
endif()
if(BUILD_TESTING)
    add_test_executable(guest_init_once_tests ${LIBS_INCLUDE_DIR}/tests/GuestInitOnce.cpp)
    target_include_directories(guest_init_once_tests PRIVATE ${LIBS_INCLUDE_DIR})
    target_link_libraries(guest_init_once_tests PRIVATE libSceLibcInternal libkernel libc)
    configure_windows_unwind(guest_init_once_tests)
    add_test(NAME guest_init_once COMMAND guest_init_once_tests)
    set_tests_properties(guest_init_once PROPERTIES TIMEOUT 20)
    if(WIN32)
        set_tests_properties(guest_init_once PROPERTIES ENVIRONMENT_MODIFICATION
            "PATH=path_list_prepend:$<TARGET_FILE_DIR:libSceLibcInternal>")
    endif()
endif()
if(BUILD_TESTING)
    add_test_executable(guest_call_once_ex_tests ${LIBS_INCLUDE_DIR}/tests/GuestCallOnceEx.cpp)
    target_include_directories(guest_call_once_ex_tests PRIVATE ${LIBS_INCLUDE_DIR})
    target_link_libraries(guest_call_once_ex_tests PRIVATE libSceLibcInternal libc libkernel)
    configure_windows_unwind(guest_call_once_ex_tests)
    add_test(NAME guest_call_once_ex COMMAND guest_call_once_ex_tests)
    set_tests_properties(guest_call_once_ex PROPERTIES TIMEOUT 20)
    if(WIN32)
        set_tests_properties(guest_call_once_ex PROPERTIES ENVIRONMENT_MODIFICATION
            "PATH=path_list_prepend:$<TARGET_FILE_DIR:libSceLibcInternal>")
    endif()
endif()
if(BUILD_TESTING)
    add_test_executable(guest_libc_internal_placement_delete_tests ${LIBS_INCLUDE_DIR}/tests/GuestLibcInternalPlacementDelete.cpp)
    target_include_directories(guest_libc_internal_placement_delete_tests PRIVATE ${LIBS_INCLUDE_DIR})
    target_link_libraries(guest_libc_internal_placement_delete_tests PRIVATE libSceLibcInternal libkernel libc)
    configure_windows_unwind(guest_libc_internal_placement_delete_tests)
    add_test(NAME guest_libc_internal_placement_delete COMMAND guest_libc_internal_placement_delete_tests)
    set_tests_properties(guest_libc_internal_placement_delete PROPERTIES TIMEOUT 20)
    if(WIN32)
        set_tests_properties(guest_libc_internal_placement_delete PROPERTIES ENVIRONMENT_MODIFICATION
            "PATH=path_list_prepend:$<TARGET_FILE_DIR:libSceLibcInternal>")
    endif()
endif()
target_sources(libSceLibcInternal PRIVATE Err.cpp)
target_sources(libSceLibcInternal PRIVATE RecoveredInventory.cpp)
target_sources(libSceLibcInternal PRIVATE VectorAlgorithms.cpp)

if(BUILD_TESTING)
    add_test_executable(guest_libc_internal_vector_algorithms_tests ${LIBS_INCLUDE_DIR}/tests/GuestLibcInternalVectorAlgorithms.cpp)
    target_include_directories(guest_libc_internal_vector_algorithms_tests PRIVATE ${LIBS_INCLUDE_DIR})
    target_link_libraries(guest_libc_internal_vector_algorithms_tests PRIVATE libSceLibcInternal libkernel libc)
    configure_windows_unwind(guest_libc_internal_vector_algorithms_tests)
    add_test(NAME guest_libc_internal_vector_algorithms COMMAND guest_libc_internal_vector_algorithms_tests)
    add_test(NAME guest_libc_internal_value_extrema_zero COMMAND guest_libc_internal_vector_algorithms_tests native-zero)
    add_test(NAME guest_libc_internal_value_extrema_special COMMAND guest_libc_internal_vector_algorithms_tests native-special)
    set_tests_properties(guest_libc_internal_vector_algorithms guest_libc_internal_value_extrema_zero guest_libc_internal_value_extrema_special PROPERTIES TIMEOUT 20)
    if(WIN32)
        set_tests_properties(guest_libc_internal_vector_algorithms guest_libc_internal_value_extrema_zero guest_libc_internal_value_extrema_special PROPERTIES ENVIRONMENT_MODIFICATION
            "PATH=path_list_prepend:$<TARGET_FILE_DIR:libSceLibcInternal>")
    endif()
endif()
target_sources(libSceLibcInternal PRIVATE TimeGet.cpp)
target_sources(libSceLibcInternal PRIVATE TimeGetOrder.cpp)
if(BUILD_TESTING)
    add_test_executable(guest_libc_internal_range_extrema_tests ${LIBS_INCLUDE_DIR}/tests/GuestLibcInternalRangeExtrema.cpp)
    target_include_directories(guest_libc_internal_range_extrema_tests PRIVATE ${LIBS_INCLUDE_DIR})
    target_link_libraries(guest_libc_internal_range_extrema_tests PRIVATE libSceLibcInternal libkernel libc)
    configure_windows_unwind(guest_libc_internal_range_extrema_tests)
    foreach(mode IN ITEMS pair-f pair-d min-f min-d max-f max-d elements-f elements-d guarded)
        string(REPLACE "-" "_" suffix "${mode}")
        set(test_name "guest_libc_internal_range_extrema_${suffix}")
        add_test(NAME ${test_name} COMMAND guest_libc_internal_range_extrema_tests ${mode})
        set_tests_properties(${test_name} PROPERTIES TIMEOUT 20)
        if(WIN32)
            set_tests_properties(${test_name} PROPERTIES ENVIRONMENT_MODIFICATION
                "PATH=path_list_prepend:$<TARGET_FILE_DIR:libSceLibcInternal>")
        endif()
    endforeach()
endif()
if(BUILD_TESTING)
    add_test_executable(guest_libc_internal_time_get_tests ${LIBS_INCLUDE_DIR}/tests/GuestLibcInternalTimeGet.cpp)
    target_include_directories(guest_libc_internal_time_get_tests PRIVATE ${LIBS_INCLUDE_DIR})
    target_link_libraries(guest_libc_internal_time_get_tests PRIVATE libSceLibcInternal libkernel libc ${CMAKE_DL_LIBS})
    configure_windows_unwind(guest_libc_internal_time_get_tests)
    add_test(NAME guest_libc_internal_time_get COMMAND guest_libc_internal_time_get_tests $<TARGET_FILE:libSceLibcInternal>)
    set_tests_properties(guest_libc_internal_time_get PROPERTIES TIMEOUT 20)
    add_test_executable(guest_time_get_order_tests ${LIBS_INCLUDE_DIR}/tests/GuestTimeGetOrder.cpp)
    target_include_directories(guest_time_get_order_tests PRIVATE ${LIBS_INCLUDE_DIR})
    target_link_libraries(guest_time_get_order_tests PRIVATE libSceLibcInternal libkernel libc)
    configure_windows_unwind(guest_time_get_order_tests)
    add_test(NAME guest_time_get_order COMMAND guest_time_get_order_tests)
    set_tests_properties(guest_time_get_order PROPERTIES TIMEOUT 20)
    if(WIN32)
        set_tests_properties(guest_libc_internal_time_get guest_time_get_order PROPERTIES ENVIRONMENT_MODIFICATION
            "PATH=path_list_prepend:$<TARGET_FILE_DIR:libSceLibcInternal>")
    endif()
endif()
target_sources(libSceLibcInternal PRIVATE IntegerExtrema.cpp)
if(BUILD_TESTING)
    add_test_executable(guest_libc_internal_integer_extrema_tests ${LIBS_INCLUDE_DIR}/tests/GuestLibcInternalIntegerExtrema.cpp)
    target_include_directories(guest_libc_internal_integer_extrema_tests PRIVATE ${LIBS_INCLUDE_DIR})
    target_link_libraries(guest_libc_internal_integer_extrema_tests PRIVATE libSceLibcInternal libc libkernel)
    configure_windows_unwind(guest_libc_internal_integer_extrema_tests)
    add_test(NAME guest_libc_internal_integer_extrema COMMAND guest_libc_internal_integer_extrema_tests)
    set_tests_properties(guest_libc_internal_integer_extrema PROPERTIES TIMEOUT 20)
    if(WIN32)
        set_tests_properties(guest_libc_internal_integer_extrema PROPERTIES ENVIRONMENT_MODIFICATION
            "PATH=path_list_prepend:$<TARGET_FILE_DIR:libSceLibcInternal>")
    endif()
endif()
target_sources(libSceLibcInternal PRIVATE ScaledPow.cpp)
if(BUILD_TESTING)
    add_test_executable(guest_libc_internal_scaled_pow_tests ${LIBS_INCLUDE_DIR}/tests/GuestLibcInternalScaledPow.cpp)
    target_include_directories(guest_libc_internal_scaled_pow_tests PRIVATE ${LIBS_INCLUDE_DIR})
    target_link_libraries(guest_libc_internal_scaled_pow_tests PRIVATE libSceLibcInternal libkernel libc)
    configure_windows_unwind(guest_libc_internal_scaled_pow_tests)
    add_test(NAME guest_libc_internal_scaled_pow COMMAND guest_libc_internal_scaled_pow_tests)
    set_tests_properties(guest_libc_internal_scaled_pow PROPERTIES TIMEOUT 20)
    if(WIN32)
        set_tests_properties(guest_libc_internal_scaled_pow PROPERTIES ENVIRONMENT_MODIFICATION
            "PATH=path_list_prepend:$<TARGET_FILE_DIR:libSceLibcInternal>")
    endif()
endif()
target_sources(libSceLibcInternal PRIVATE Logpoly.cpp)
if(BUILD_TESTING)
    add_test_executable(guest_libc_internal_logpoly_tests ${LIBS_INCLUDE_DIR}/tests/GuestLibcInternalLogpoly.cpp)
    target_include_directories(guest_libc_internal_logpoly_tests PRIVATE ${LIBS_INCLUDE_DIR})
    target_link_libraries(guest_libc_internal_logpoly_tests PRIVATE libSceLibcInternal libkernel libc)
    configure_windows_unwind(guest_libc_internal_logpoly_tests)
    add_test(NAME guest_libc_internal_logpoly COMMAND guest_libc_internal_logpoly_tests)
    set_tests_properties(guest_libc_internal_logpoly PROPERTIES TIMEOUT 20)
    if(WIN32)
        set_tests_properties(guest_libc_internal_logpoly PROPERTIES ENVIRONMENT_MODIFICATION
            "PATH=path_list_prepend:$<TARGET_FILE_DIR:libSceLibcInternal>")
    endif()
endif()
target_sources(libSceLibcInternal PRIVATE HalfPrecision.cpp)
if(BUILD_TESTING)
    add_test_executable(guest_libc_internal_half_precision_tests ${LIBS_INCLUDE_DIR}/tests/GuestLibcInternalHalfPrecision.cpp)
    target_include_directories(guest_libc_internal_half_precision_tests PRIVATE ${LIBS_INCLUDE_DIR})
    target_link_libraries(guest_libc_internal_half_precision_tests PRIVATE libSceLibcInternal libkernel libc)
    configure_windows_unwind(guest_libc_internal_half_precision_tests)
    add_test(NAME guest_libc_internal_half_precision COMMAND guest_libc_internal_half_precision_tests)
    set_tests_properties(guest_libc_internal_half_precision PROPERTIES TIMEOUT 20)
    if(WIN32)
        set_tests_properties(guest_libc_internal_half_precision PROPERTIES ENVIRONMENT_MODIFICATION
            "PATH=path_list_prepend:$<TARGET_FILE_DIR:libSceLibcInternal>")
    endif()
endif()
target_sources(libSceLibcInternal PRIVATE RelativeSleep.cpp)
if(BUILD_TESTING)
    add_test_executable(guest_relative_sleep_tests ${LIBS_INCLUDE_DIR}/tests/GuestRelativeSleep.cpp)
    target_include_directories(guest_relative_sleep_tests PRIVATE ${LIBS_INCLUDE_DIR})
    target_link_libraries(guest_relative_sleep_tests PRIVATE libSceLibcInternal libc)
    configure_windows_unwind(guest_relative_sleep_tests)
    set(relativeSleepTests guest_relative_sleep)
    add_test(NAME guest_relative_sleep COMMAND guest_relative_sleep_tests)
    if(Python3_Interpreter_FOUND)
        add_test(NAME guest_relative_sleep_large COMMAND ${Python3_EXECUTABLE}
            ${LIBS_INCLUDE_DIR}/tests/test_relative_sleep.py $<TARGET_FILE:guest_relative_sleep_tests>)
        list(APPEND relativeSleepTests guest_relative_sleep_large)
    endif()
    set_tests_properties(${relativeSleepTests} PROPERTIES TIMEOUT 20)
    if(WIN32)
        set_tests_properties(${relativeSleepTests} PROPERTIES ENVIRONMENT_MODIFICATION
            "PATH=path_list_prepend:$<TARGET_FILE_DIR:libSceLibcInternal>")
    endif()
endif()
target_sources(libSceLibcInternal PRIVATE ExceptionDestructors.cpp)
target_sources(libSceLibcInternal PRIVATE ConstantMembers.cpp)
if(BUILD_TESTING)
    add_test_executable(guest_libc_internal_constant_members_tests ${LIBS_INCLUDE_DIR}/tests/GuestLibcInternalConstantMembers.cpp)
    target_include_directories(guest_libc_internal_constant_members_tests PRIVATE ${LIBS_INCLUDE_DIR})
    target_link_libraries(guest_libc_internal_constant_members_tests PRIVATE libSceLibcInternal libkernel libc)
    configure_windows_unwind(guest_libc_internal_constant_members_tests)
    add_test(NAME guest_libc_internal_constant_members COMMAND guest_libc_internal_constant_members_tests)
    set_tests_properties(guest_libc_internal_constant_members PROPERTIES TIMEOUT 20)
    if(WIN32)
        set_tests_properties(guest_libc_internal_constant_members PROPERTIES ENVIRONMENT_MODIFICATION
            "PATH=path_list_prepend:$<TARGET_FILE_DIR:libSceLibcInternal>")
    endif()
endif()
target_sources(libSceLibcInternal PRIVATE TypeInfoDestructors.cpp)
if(BUILD_TESTING)
    add_test_executable(guest_libc_internal_type_info_destructors_tests ${LIBS_INCLUDE_DIR}/tests/GuestLibcInternalTypeInfoDestructors.cpp)
    target_include_directories(guest_libc_internal_type_info_destructors_tests PRIVATE ${LIBS_INCLUDE_DIR})
    target_link_libraries(guest_libc_internal_type_info_destructors_tests PRIVATE libSceLibcInternal libkernel libc)
    configure_windows_unwind(guest_libc_internal_type_info_destructors_tests)
    add_test(NAME guest_libc_internal_type_info_destructors COMMAND guest_libc_internal_type_info_destructors_tests)
    set_tests_properties(guest_libc_internal_type_info_destructors PROPERTIES TIMEOUT 20)
    if(WIN32)
        set_tests_properties(guest_libc_internal_type_info_destructors PROPERTIES ENVIRONMENT_MODIFICATION
            "PATH=path_list_prepend:$<TARGET_FILE_DIR:libSceLibcInternal>")
    endif()
endif()
target_sources(libSceLibcInternal PRIVATE ExceptionVirtuals.cpp)
if(BUILD_TESTING)
    add_test_executable(guest_libc_internal_exception_virtuals_tests ${LIBS_INCLUDE_DIR}/tests/GuestLibcInternalExceptionVirtuals.cpp)
    target_include_directories(guest_libc_internal_exception_virtuals_tests PRIVATE ${LIBS_INCLUDE_DIR})
    target_link_libraries(guest_libc_internal_exception_virtuals_tests PRIVATE libSceLibcInternal libkernel libc)
    configure_windows_unwind(guest_libc_internal_exception_virtuals_tests)
    add_test(NAME guest_libc_internal_exception_virtuals COMMAND guest_libc_internal_exception_virtuals_tests)
    set_tests_properties(guest_libc_internal_exception_virtuals PROPERTIES TIMEOUT 20)
    if(WIN32)
        set_tests_properties(guest_libc_internal_exception_virtuals PROPERTIES ENVIRONMENT_MODIFICATION
            "PATH=path_list_prepend:$<TARGET_FILE_DIR:libSceLibcInternal>")
    endif()
endif()
if(BUILD_TESTING)
    add_test_executable(guest_libc_internal_exception_destructors_tests ${LIBS_INCLUDE_DIR}/tests/GuestLibcInternalExceptionDestructors.cpp)
    target_include_directories(guest_libc_internal_exception_destructors_tests PRIVATE ${LIBS_INCLUDE_DIR})
    target_link_libraries(guest_libc_internal_exception_destructors_tests PRIVATE libSceLibcInternal libkernel libc)
    configure_windows_unwind(guest_libc_internal_exception_destructors_tests)
    add_test(NAME guest_libc_internal_exception_destructors COMMAND guest_libc_internal_exception_destructors_tests)
    set_tests_properties(guest_libc_internal_exception_destructors PROPERTIES TIMEOUT 20)
    if(WIN32)
        set_tests_properties(guest_libc_internal_exception_destructors PROPERTIES ENVIRONMENT_MODIFICATION
            "PATH=path_list_prepend:$<TARGET_FILE_DIR:libSceLibcInternal>")
    endif()
    add_test_executable(guest_libc_internal_deleting_destructors_tests ${LIBS_INCLUDE_DIR}/tests/GuestLibcInternalDeletingDestructors.cpp)
    target_include_directories(guest_libc_internal_deleting_destructors_tests PRIVATE ${LIBS_INCLUDE_DIR})
    target_link_libraries(guest_libc_internal_deleting_destructors_tests PRIVATE libSceLibcInternal libkernel libc)
    configure_windows_unwind(guest_libc_internal_deleting_destructors_tests)
    add_test(NAME guest_libc_internal_deleting_destructors COMMAND guest_libc_internal_deleting_destructors_tests)
    set_tests_properties(guest_libc_internal_deleting_destructors PROPERTIES TIMEOUT 20)
    if(WIN32)
        set_tests_properties(guest_libc_internal_deleting_destructors PROPERTIES ENVIRONMENT_MODIFICATION
            "PATH=path_list_prepend:$<TARGET_FILE_DIR:libSceLibcInternal>")
    endif()
    if(MINGW OR CMAKE_SYSTEM_NAME STREQUAL "Linux")
        enable_language(ASM)
        add_test_executable(guest_libc_internal_libc_forwards_tests
            ${LIBS_INCLUDE_DIR}/tests/GuestLibcInternalLibcForwards.cpp
            ${LIBS_INCLUDE_DIR}/tests/GuestSceV2Exceptions.S)
        target_include_directories(guest_libc_internal_libc_forwards_tests PRIVATE ${LIBS_INCLUDE_DIR})
        target_link_libraries(guest_libc_internal_libc_forwards_tests PRIVATE libSceLibcInternal libkernel libc)
        configure_windows_unwind(guest_libc_internal_libc_forwards_tests)
        add_test(NAME guest_libc_internal_libc_forwards COMMAND guest_libc_internal_libc_forwards_tests)
        set_tests_properties(guest_libc_internal_libc_forwards PROPERTIES TIMEOUT 20)
        if(WIN32)
            set_tests_properties(guest_libc_internal_libc_forwards PROPERTIES ENVIRONMENT_MODIFICATION
                "PATH=path_list_prepend:$<TARGET_FILE_DIR:libSceLibcInternal>")
        endif()
    endif()
endif()
target_sources(libSceLibcInternal PRIVATE AtomicWaitDeadline.cpp)
if(BUILD_TESTING)
    add_test_executable(guest_libc_internal_atomic_wait_deadline_tests ${LIBS_INCLUDE_DIR}/tests/GuestLibcInternalAtomicWaitDeadline.cpp)
    target_include_directories(guest_libc_internal_atomic_wait_deadline_tests PRIVATE ${LIBS_INCLUDE_DIR})
    target_link_libraries(guest_libc_internal_atomic_wait_deadline_tests PRIVATE libSceLibcInternal libc libkernel)
    configure_windows_unwind(guest_libc_internal_atomic_wait_deadline_tests)
    file(MAKE_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}/atomic-wait-deadline)
    add_test(NAME guest_libc_internal_atomic_wait_deadline COMMAND guest_libc_internal_atomic_wait_deadline_tests)
    set_tests_properties(guest_libc_internal_atomic_wait_deadline PROPERTIES TIMEOUT 20
        WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}/atomic-wait-deadline)
    if(WIN32)
        set_tests_properties(guest_libc_internal_atomic_wait_deadline PROPERTIES ENVIRONMENT_MODIFICATION
            "PATH=path_list_prepend:$<TARGET_FILE_DIR:libSceLibcInternal>")
    endif()
endif()
target_sources(libSceLibcInternal PRIVATE UnversionedFilesystemCalls.cpp)
if(BUILD_TESTING)
    add_test_executable(guest_libc_internal_unversioned_filesystem_tests ${LIBS_INCLUDE_DIR}/tests/GuestLibcInternalUnversionedFilesystem.cpp)
    target_include_directories(guest_libc_internal_unversioned_filesystem_tests PRIVATE ${LIBS_INCLUDE_DIR})
    target_link_libraries(guest_libc_internal_unversioned_filesystem_tests PRIVATE libSceLibcInternal libkernel libc)
    configure_windows_unwind(guest_libc_internal_unversioned_filesystem_tests)
    add_test(NAME guest_libc_internal_unversioned_filesystem COMMAND guest_libc_internal_unversioned_filesystem_tests)
    set_tests_properties(guest_libc_internal_unversioned_filesystem PROPERTIES TIMEOUT 20)
    if(WIN32)
        set_tests_properties(guest_libc_internal_unversioned_filesystem PROPERTIES ENVIRONMENT_MODIFICATION
            "PATH=path_list_prepend:$<TARGET_FILE_DIR:libSceLibcInternal>")
    endif()
endif()
target_sources(libSceLibcInternal PRIVATE Significand.cpp)
if(BUILD_TESTING)
    add_test_executable(guest_libc_internal_significand_tests ${LIBS_INCLUDE_DIR}/tests/GuestLibcInternalSignificand.cpp)
    target_include_directories(guest_libc_internal_significand_tests PRIVATE ${LIBS_INCLUDE_DIR})
    target_link_libraries(guest_libc_internal_significand_tests PRIVATE libSceLibcInternal libc libkernel)
    configure_windows_unwind(guest_libc_internal_significand_tests)
    add_test(NAME guest_libc_internal_significand COMMAND guest_libc_internal_significand_tests)
    set_tests_properties(guest_libc_internal_significand PROPERTIES TIMEOUT 20)
    if(WIN32)
        set_tests_properties(guest_libc_internal_significand PROPERTIES ENVIRONMENT_MODIFICATION
            "PATH=path_list_prepend:$<TARGET_FILE_DIR:libSceLibcInternal>")
    endif()
endif()
target_sources(libSceLibcInternal PRIVATE ScaledHypot.cpp)
if(BUILD_TESTING)
    add_test_executable(guest_libc_internal_scaled_hypot_tests ${LIBS_INCLUDE_DIR}/tests/GuestLibcInternalScaledHypot.cpp)
    target_include_directories(guest_libc_internal_scaled_hypot_tests PRIVATE ${LIBS_INCLUDE_DIR})
    target_link_libraries(guest_libc_internal_scaled_hypot_tests PRIVATE libSceLibcInternal libkernel libc)
    configure_windows_unwind(guest_libc_internal_scaled_hypot_tests)
    add_test(NAME guest_libc_internal_scaled_hypot COMMAND guest_libc_internal_scaled_hypot_tests)
    set_tests_properties(guest_libc_internal_scaled_hypot PROPERTIES TIMEOUT 20)
    if(WIN32)
        set_tests_properties(guest_libc_internal_scaled_hypot PROPERTIES ENVIRONMENT_MODIFICATION
            "PATH=path_list_prepend:$<TARGET_FILE_DIR:libSceLibcInternal>")
    endif()
endif()
target_sources(libSceLibcInternal PRIVATE ExtendedPrecision.cpp)
if(BUILD_TESTING)
    add_test_executable(guest_libc_internal_extended_precision_tests ${LIBS_INCLUDE_DIR}/tests/GuestLibcInternalExtendedPrecision.cpp)
    target_include_directories(guest_libc_internal_extended_precision_tests PRIVATE ${LIBS_INCLUDE_DIR})
    target_link_libraries(guest_libc_internal_extended_precision_tests PRIVATE libSceLibcInternal libc libkernel)
    configure_windows_unwind(guest_libc_internal_extended_precision_tests)
    add_test(NAME guest_libc_internal_extended_precision COMMAND guest_libc_internal_extended_precision_tests)
    set_tests_properties(guest_libc_internal_extended_precision PROPERTIES TIMEOUT 20)
    if(WIN32)
        set_tests_properties(guest_libc_internal_extended_precision PROPERTIES ENVIRONMENT_MODIFICATION
            "PATH=path_list_prepend:$<TARGET_FILE_DIR:libSceLibcInternal>")
    endif()
endif()
configure_windows_unwind(libSceLibcInternal)
target_sources(libSceLibcInternal PRIVATE FilesystemStatistics.cpp PathStatistics.cpp)
target_sources(libSceLibcInternal PRIVATE LocaleObjects.cpp)
if(BUILD_TESTING)
    add_test_executable(guest_libc_internal_locale_objects_tests ${LIBS_INCLUDE_DIR}/tests/GuestLibcInternalLocaleObjects.cpp)
    target_include_directories(guest_libc_internal_locale_objects_tests PRIVATE ${LIBS_INCLUDE_DIR})
    target_link_libraries(guest_libc_internal_locale_objects_tests PRIVATE libSceLibcInternal libkernel libc)
    configure_windows_unwind(guest_libc_internal_locale_objects_tests)
    add_test(NAME guest_libc_internal_locale_objects COMMAND guest_libc_internal_locale_objects_tests)
    set_tests_properties(guest_libc_internal_locale_objects PROPERTIES TIMEOUT 20)
    if(WIN32)
        set_tests_properties(guest_libc_internal_locale_objects PROPERTIES ENVIRONMENT_MODIFICATION
            "PATH=path_list_prepend:$<TARGET_FILE_DIR:libSceLibcInternal>")
    endif()
    add_test_executable(guest_libc_internal_locale_state_tests ${LIBS_INCLUDE_DIR}/tests/GuestLibcInternalLocaleState.cpp)
    target_include_directories(guest_libc_internal_locale_state_tests PRIVATE ${LIBS_INCLUDE_DIR})
    target_link_libraries(guest_libc_internal_locale_state_tests PRIVATE libSceLibcInternal libkernel libc)
    configure_windows_unwind(guest_libc_internal_locale_state_tests)
    add_test(NAME guest_libc_internal_locale_state COMMAND guest_libc_internal_locale_state_tests)
    set_tests_properties(guest_libc_internal_locale_state PROPERTIES TIMEOUT 20)
    if(WIN32)
        set_tests_properties(guest_libc_internal_locale_state PROPERTIES ENVIRONMENT_MODIFICATION
            "PATH=path_list_prepend:$<TARGET_FILE_DIR:libSceLibcInternal>")
    endif()
endif()
target_sources(libSceLibcInternal PRIVATE Inet.cpp)
target_sources(libSceLibcInternal PRIVATE InventoryExports6.cpp)
target_sources(libSceLibcInternal PRIVATE MoneyGetPut.cpp)
if(BUILD_TESTING)
    add_test_executable(guest_libc_internal_money_get_put_tests ${LIBS_INCLUDE_DIR}/tests/GuestLibcInternalMoneyGetPut.cpp)
    target_include_directories(guest_libc_internal_money_get_put_tests PRIVATE ${LIBS_INCLUDE_DIR})
    target_link_libraries(guest_libc_internal_money_get_put_tests PRIVATE libSceLibcInternal libkernel libc ${CMAKE_DL_LIBS})
    configure_windows_unwind(guest_libc_internal_money_get_put_tests)
    add_test(NAME guest_libc_internal_money_get_put COMMAND guest_libc_internal_money_get_put_tests $<TARGET_FILE:libSceLibcInternal>)
    set_tests_properties(guest_libc_internal_money_get_put PROPERTIES TIMEOUT 20)
    if(WIN32)
        set_tests_properties(guest_libc_internal_money_get_put PROPERTIES ENVIRONMENT_MODIFICATION
            "PATH=path_list_prepend:$<TARGET_FILE_DIR:libSceLibcInternal>")
    endif()
endif()

target_sources(libSceLibcInternal PRIVATE IosBase.cpp)
if(BUILD_TESTING)
    add_test_executable(guest_libc_internal_ios_base_tests ${LIBS_INCLUDE_DIR}/tests/GuestLibcInternalIosBase.cpp)
    target_include_directories(guest_libc_internal_ios_base_tests PRIVATE ${LIBS_INCLUDE_DIR})
    target_link_libraries(guest_libc_internal_ios_base_tests PRIVATE libSceLibcInternal libkernel libc)
    configure_windows_unwind(guest_libc_internal_ios_base_tests)
    add_test(NAME guest_libc_internal_ios_base COMMAND guest_libc_internal_ios_base_tests)
    set_tests_properties(guest_libc_internal_ios_base PROPERTIES TIMEOUT 20)
    if(WIN32)
        set_tests_properties(guest_libc_internal_ios_base PROPERTIES ENVIRONMENT_MODIFICATION
            "PATH=path_list_prepend:$<TARGET_FILE_DIR:libSceLibcInternal>")
    endif()
endif()
target_sources(libSceLibcInternal PRIVATE StreamDestructors.cpp)
if(BUILD_TESTING)
    add_test_executable(guest_libc_internal_stream_destructors_tests ${LIBS_INCLUDE_DIR}/tests/GuestLibcInternalStreamDestructors.cpp)
    target_include_directories(guest_libc_internal_stream_destructors_tests PRIVATE ${LIBS_INCLUDE_DIR})
    target_link_libraries(guest_libc_internal_stream_destructors_tests PRIVATE libSceLibcInternal libkernel libc)
    configure_windows_unwind(guest_libc_internal_stream_destructors_tests)
    add_test(NAME guest_libc_internal_stream_destructors COMMAND guest_libc_internal_stream_destructors_tests)
    set_tests_properties(guest_libc_internal_stream_destructors PROPERTIES TIMEOUT 20)
    if(WIN32)
        set_tests_properties(guest_libc_internal_stream_destructors PROPERTIES ENVIRONMENT_MODIFICATION
            "PATH=path_list_prepend:$<TARGET_FILE_DIR:libSceLibcInternal>")
    endif()
endif()
target_sources(libSceLibcInternal PRIVATE BitsetToString.cpp)
if(BUILD_TESTING)
    add_test_executable(guest_libc_internal_bitset_to_string_tests ${LIBS_INCLUDE_DIR}/tests/GuestLibcInternalBitsetToString.cpp)
    target_include_directories(guest_libc_internal_bitset_to_string_tests PRIVATE ${LIBS_INCLUDE_DIR})
    target_link_libraries(guest_libc_internal_bitset_to_string_tests PRIVATE libSceLibcInternal libc libkernel)
    configure_windows_unwind(guest_libc_internal_bitset_to_string_tests)
    add_test(NAME guest_libc_internal_bitset_to_string COMMAND guest_libc_internal_bitset_to_string_tests)
    set_tests_properties(guest_libc_internal_bitset_to_string PROPERTIES TIMEOUT 20)
    if(WIN32)
        set_tests_properties(guest_libc_internal_bitset_to_string PROPERTIES ENVIRONMENT_MODIFICATION
            "PATH=path_list_prepend:$<TARGET_FILE_DIR:libSceLibcInternal>")
    endif()
endif()
target_sources(libSceLibcInternal PRIVATE Filesystem.cpp)
target_sources(libSceLibcInternal PRIVATE FacetPut.cpp)
if(BUILD_TESTING)
    add_test_executable(guest_libc_internal_facet_put_tests ${LIBS_INCLUDE_DIR}/tests/GuestLibcInternalFacetPut.cpp)
    target_include_directories(guest_libc_internal_facet_put_tests PRIVATE ${LIBS_INCLUDE_DIR})
    target_link_libraries(guest_libc_internal_facet_put_tests PRIVATE libSceLibcInternal libkernel libc ${CMAKE_DL_LIBS})
    configure_windows_unwind(guest_libc_internal_facet_put_tests)
    add_test(NAME guest_libc_internal_facet_put COMMAND guest_libc_internal_facet_put_tests $<TARGET_FILE:libSceLibcInternal>)
    set_tests_properties(guest_libc_internal_facet_put PROPERTIES TIMEOUT 20)
    if(WIN32)
        set_tests_properties(guest_libc_internal_facet_put PROPERTIES ENVIRONMENT_MODIFICATION
            "PATH=path_list_prepend:$<TARGET_FILE_DIR:libSceLibcInternal>")
    endif()
endif()
target_sources(libSceLibcInternal PRIVATE Collate.cpp)
target_sources(libSceLibcInternal PRIVATE Messages.cpp)
if(BUILD_TESTING)
    add_test_executable(guest_libc_internal_collate_tests ${LIBS_INCLUDE_DIR}/tests/GuestLibcInternalCollate.cpp)
    target_include_directories(guest_libc_internal_collate_tests PRIVATE ${LIBS_INCLUDE_DIR})
    target_link_libraries(guest_libc_internal_collate_tests PRIVATE libSceLibcInternal libkernel libc ${CMAKE_DL_LIBS})
    configure_windows_unwind(guest_libc_internal_collate_tests)
    add_test(NAME guest_libc_internal_collate COMMAND guest_libc_internal_collate_tests $<TARGET_FILE:libSceLibcInternal>)
    set_tests_properties(guest_libc_internal_collate PROPERTIES TIMEOUT 20)
    if(WIN32)
        set_tests_properties(guest_libc_internal_collate PROPERTIES ENVIRONMENT_MODIFICATION
            "PATH=path_list_prepend:$<TARGET_FILE_DIR:libSceLibcInternal>")
    endif()
endif()
target_sources(libSceLibcInternal PRIVATE BasicString.cpp)
if(BUILD_TESTING AND (MINGW OR CMAKE_SYSTEM_NAME STREQUAL "Linux"))
    enable_language(ASM)
    add_test_executable(guest_libc_internal_basic_string_tests
        ${LIBS_INCLUDE_DIR}/tests/GuestLibcInternalBasicString.cpp
        ${LIBS_INCLUDE_DIR}/tests/GuestSceV2Exceptions.S)
    target_include_directories(guest_libc_internal_basic_string_tests PRIVATE ${LIBS_INCLUDE_DIR})
    target_link_libraries(guest_libc_internal_basic_string_tests PRIVATE libSceLibcInternal libkernel libc)
    configure_windows_unwind(guest_libc_internal_basic_string_tests)
    add_test(NAME guest_libc_internal_basic_string COMMAND guest_libc_internal_basic_string_tests)
    set_tests_properties(guest_libc_internal_basic_string PROPERTIES TIMEOUT 20)
    if(WIN32)
        set_tests_properties(guest_libc_internal_basic_string PROPERTIES ENVIRONMENT_MODIFICATION
            "PATH=path_list_prepend:$<TARGET_FILE_DIR:libSceLibcInternal>")
    endif()
endif()
target_sources(libSceLibcInternal PRIVATE PlacementDelete.cpp)
target_sources(libSceLibcInternal PRIVATE RemPio2.cpp)
set_source_files_properties(RemPio2.cpp PROPERTIES COMPILE_OPTIONS $<$<CXX_COMPILER_ID:GNU,Clang,AppleClang>:-ffp-contract=off>)

if(BUILD_TESTING)
    add_test_executable(guest_statvfs_tests ${LIBS_INCLUDE_DIR}/tests/GuestStatvfs.cpp)
    target_include_directories(guest_statvfs_tests PRIVATE ${LIBS_INCLUDE_DIR})
    target_link_libraries(guest_statvfs_tests PRIVATE libSceLibcInternal libc)
    configure_windows_unwind(guest_statvfs_tests)
    add_test(NAME guest_statvfs COMMAND guest_statvfs_tests)
    set_tests_properties(guest_statvfs PROPERTIES TIMEOUT 20)
    if(WIN32)
        set_tests_properties(guest_statvfs PROPERTIES ENVIRONMENT_MODIFICATION
            "PATH=path_list_prepend:$<TARGET_FILE_DIR:libSceLibcInternal>")
    endif()
    add_test_executable(guest_fstatvfs_conversion_tests ${LIBS_INCLUDE_DIR}/tests/GuestFstatvfsConversion.cpp FilesystemStatistics.cpp)
    target_include_directories(guest_fstatvfs_conversion_tests PRIVATE ${LIBS_INCLUDE_DIR})
    configure_windows_unwind(guest_fstatvfs_conversion_tests)
    add_test(NAME guest_fstatvfs_conversion COMMAND guest_fstatvfs_conversion_tests)
    set_tests_properties(guest_fstatvfs_conversion PROPERTIES TIMEOUT 20)
    add_test_executable(guest_kernel_rem_pio2_tests ${LIBS_INCLUDE_DIR}/tests/GuestKernelRemPio2.cpp)
    target_include_directories(guest_kernel_rem_pio2_tests PRIVATE ${LIBS_INCLUDE_DIR})
    target_link_libraries(guest_kernel_rem_pio2_tests PRIVATE libSceLibcInternal libkernel libc)
    configure_windows_unwind(guest_kernel_rem_pio2_tests)
    add_test(NAME guest_kernel_rem_pio2 COMMAND guest_kernel_rem_pio2_tests)
    set_tests_properties(guest_kernel_rem_pio2 PROPERTIES TIMEOUT 20)
    if(WIN32)
        set_tests_properties(guest_kernel_rem_pio2 PROPERTIES ENVIRONMENT_MODIFICATION
            "PATH=path_list_prepend:$<TARGET_FILE_DIR:libSceLibcInternal>")
    endif()
    add_test_executable(guest_fstatvfs_tests ${LIBS_INCLUDE_DIR}/tests/GuestFstatvfs.cpp)
    target_include_directories(guest_fstatvfs_tests PRIVATE ${LIBS_INCLUDE_DIR})
    target_link_libraries(guest_fstatvfs_tests PRIVATE libSceLibcInternal libkernel libc)
    configure_windows_unwind(guest_fstatvfs_tests)
    add_test(NAME guest_fstatvfs COMMAND guest_fstatvfs_tests)
    set_tests_properties(guest_fstatvfs PROPERTIES TIMEOUT 20)
    if(WIN32)
        set_tests_properties(guest_fstatvfs PROPERTIES ENVIRONMENT_MODIFICATION
            "PATH=path_list_prepend:$<TARGET_FILE_DIR:libSceLibcInternal>")
    endif()
    add_test_executable(guest_fdopendir_tests ${LIBS_INCLUDE_DIR}/tests/GuestFdopendir.cpp)
    target_include_directories(guest_fdopendir_tests PRIVATE ${LIBS_INCLUDE_DIR})
    target_link_libraries(guest_fdopendir_tests PRIVATE libSceLibcInternal libkernel libc)
    configure_windows_unwind(guest_fdopendir_tests)
    add_test(NAME guest_fdopendir COMMAND guest_fdopendir_tests)
    if(WIN32)
        set_tests_properties(guest_fdopendir PROPERTIES ENVIRONMENT_MODIFICATION
            "PATH=path_list_prepend:$<TARGET_FILE_DIR:libSceLibcInternal>")
    endif()
    add_test_executable(guest_opendir2_tests ${LIBS_INCLUDE_DIR}/tests/GuestOpendir2.cpp)
    target_include_directories(guest_opendir2_tests PRIVATE ${LIBS_INCLUDE_DIR})
    target_link_libraries(guest_opendir2_tests PRIVATE libSceLibcInternal libkernel libc)
    configure_windows_unwind(guest_opendir2_tests)
    add_test(NAME guest_opendir2 COMMAND guest_opendir2_tests)
    if(WIN32)
        set_tests_properties(guest_opendir2 PROPERTIES ENVIRONMENT_MODIFICATION
            "PATH=path_list_prepend:$<TARGET_FILE_DIR:libSceLibcInternal>")
    endif()
    add_test_executable(guest_utime_forwarding_tests ${LIBS_INCLUDE_DIR}/tests/GuestUtimeForwarding.cpp FileTime.cpp)
    target_include_directories(guest_utime_forwarding_tests PRIVATE ${LIBS_INCLUDE_DIR})
    configure_windows_unwind(guest_utime_forwarding_tests)
    add_test(NAME guest_utime_forwarding COMMAND guest_utime_forwarding_tests)
    set_tests_properties(guest_utime_forwarding PROPERTIES TIMEOUT 20)
    add_test_executable(guest_utime_tests ${LIBS_INCLUDE_DIR}/tests/GuestUtime.cpp)
    target_include_directories(guest_utime_tests PRIVATE ${LIBS_INCLUDE_DIR})
    target_link_libraries(guest_utime_tests PRIVATE libSceLibcInternal libc)
    configure_windows_unwind(guest_utime_tests)
    add_test(NAME guest_utime COMMAND guest_utime_tests)
    set_tests_properties(guest_utime PROPERTIES TIMEOUT 20)
    if(WIN32)
        set_tests_properties(guest_utime PROPERTIES ENVIRONMENT_MODIFICATION
            "PATH=path_list_prepend:$<TARGET_FILE_DIR:libSceLibcInternal>")
    endif()
    if(NOT WIN32)
        add_test_executable(guest_posix_spawn_errors_tests ${LIBS_INCLUDE_DIR}/tests/GuestPosixSpawnErrors.cpp)
        target_include_directories(guest_posix_spawn_errors_tests PRIVATE ${LIBS_INCLUDE_DIR})
        target_link_libraries(guest_posix_spawn_errors_tests PRIVATE libSceLibcInternal libc libkernel)
        file(MAKE_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}/spawn-errors)
        add_test(NAME guest_posix_spawn_errors COMMAND guest_posix_spawn_errors_tests)
        set_tests_properties(guest_posix_spawn_errors PROPERTIES TIMEOUT 20
            WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}/spawn-errors)
    endif()
    add_test_executable(guest_posix_spawn_tests ${LIBS_INCLUDE_DIR}/tests/GuestPosixSpawn.cpp)
    target_include_directories(guest_posix_spawn_tests PRIVATE ${LIBS_INCLUDE_DIR})
    target_link_libraries(guest_posix_spawn_tests PRIVATE libSceLibcInternal libc libkernel)
    configure_windows_unwind(guest_posix_spawn_tests)
    add_test(NAME guest_posix_spawn COMMAND guest_posix_spawn_tests)
    set_tests_properties(guest_posix_spawn PROPERTIES TIMEOUT 20)
    add_asan_test_options(guest_posix_spawn handle_sigbus=0)
    if(WIN32)
        set_tests_properties(guest_posix_spawn PROPERTIES ENVIRONMENT_MODIFICATION
            "PATH=path_list_prepend:$<TARGET_FILE_DIR:libSceLibcInternal>")
    endif()
    add_test_executable(guest_posix_spawn_optional_pid_tests ${LIBS_INCLUDE_DIR}/tests/GuestPosixSpawnOptionalPid.cpp)
    target_include_directories(guest_posix_spawn_optional_pid_tests PRIVATE ${LIBS_INCLUDE_DIR})
    target_link_libraries(guest_posix_spawn_optional_pid_tests PRIVATE libSceLibcInternal libc libkernel)
    configure_windows_unwind(guest_posix_spawn_optional_pid_tests)
    file(MAKE_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}/spawn-optional-pid)
    add_test(NAME guest_posix_spawn_optional_pid COMMAND guest_posix_spawn_optional_pid_tests)
    set_tests_properties(guest_posix_spawn_optional_pid PROPERTIES TIMEOUT 20
        WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}/spawn-optional-pid)
    add_asan_test_options(guest_posix_spawn_optional_pid handle_sigbus=0)
    if(WIN32)
        set_tests_properties(guest_posix_spawn_optional_pid PROPERTIES ENVIRONMENT_MODIFICATION
            "PATH=path_list_prepend:$<TARGET_FILE_DIR:libSceLibcInternal>")
    endif()
    add_test_executable(guest_program_name_tests ${LIBS_INCLUDE_DIR}/tests/GuestProgramName.cpp)
    target_include_directories(guest_program_name_tests PRIVATE ${LIBS_INCLUDE_DIR})
    target_link_libraries(guest_program_name_tests PRIVATE libSceLibcInternal libkernel libc)
    configure_windows_unwind(guest_program_name_tests)
    add_test(NAME guest_program_name COMMAND guest_program_name_tests)
    set_tests_properties(guest_program_name PROPERTIES TIMEOUT 20)
    if(CMAKE_SYSTEM_NAME STREQUAL "Linux")
        add_test_executable(guest_posix_spawn_flags_tests ${LIBS_INCLUDE_DIR}/tests/GuestPosixSpawnFlags.cpp)
        target_include_directories(guest_posix_spawn_flags_tests PRIVATE ${LIBS_INCLUDE_DIR})
        target_link_libraries(guest_posix_spawn_flags_tests PRIVATE libSceLibcInternal libc libkernel ${CMAKE_DL_LIBS})
        file(MAKE_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}/spawn-flags)
        add_test(NAME guest_posix_spawn_flags COMMAND guest_posix_spawn_flags_tests)
        set_tests_properties(guest_posix_spawn_flags PROPERTIES TIMEOUT 20
            WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}/spawn-flags)
    endif()
    if(WIN32)
        set_tests_properties(guest_program_name PROPERTIES ENVIRONMENT_MODIFICATION
            "PATH=path_list_prepend:$<TARGET_FILE_DIR:libSceLibcInternal>")
    endif()
    add_test_executable(guest_thread_atexit_tests ${LIBS_INCLUDE_DIR}/tests/GuestThreadAtexit.cpp)
    target_include_directories(guest_thread_atexit_tests PRIVATE ${LIBS_INCLUDE_DIR})
    target_link_libraries(guest_thread_atexit_tests PRIVATE libSceLibcInternal libkernel libc)
    configure_windows_unwind(guest_thread_atexit_tests)
    add_test(NAME guest_thread_atexit COMMAND guest_thread_atexit_tests)
    set_tests_properties(guest_thread_atexit PROPERTIES TIMEOUT 20)
    if(WIN32)
        set_tests_properties(guest_thread_atexit PROPERTIES ENVIRONMENT_MODIFICATION
            "PATH=path_list_prepend:$<TARGET_FILE_DIR:libSceLibcInternal>")
    endif()
    add_test_executable(guest_err_tests ${LIBS_INCLUDE_DIR}/tests/GuestErr.cpp)
    target_include_directories(guest_err_tests PRIVATE ${LIBS_INCLUDE_DIR})
    target_link_libraries(guest_err_tests PRIVATE libSceLibcInternal libkernel libc)
    configure_windows_unwind(guest_err_tests)
    add_test(NAME guest_err COMMAND guest_err_tests)
    set_tests_properties(guest_err PROPERTIES TIMEOUT 20)
    if(WIN32)
        set_tests_properties(guest_err PROPERTIES ENVIRONMENT_MODIFICATION
            "PATH=path_list_prepend:$<TARGET_FILE_DIR:libSceLibcInternal>")
    endif()
    add_test_executable(guest_libc_internal_memory_resource_tests ${LIBS_INCLUDE_DIR}/tests/GuestLibcInternalMemoryResource.cpp)
    target_include_directories(guest_libc_internal_memory_resource_tests PRIVATE ${LIBS_INCLUDE_DIR})
    target_link_libraries(guest_libc_internal_memory_resource_tests PRIVATE libSceLibcInternal libkernel libc)
    configure_windows_unwind(guest_libc_internal_memory_resource_tests)
    add_test(NAME guest_libc_internal_memory_resource COMMAND guest_libc_internal_memory_resource_tests)
    set_tests_properties(guest_libc_internal_memory_resource PROPERTIES TIMEOUT 20)
    if(WIN32)
        set_tests_properties(guest_libc_internal_memory_resource PROPERTIES ENVIRONMENT_MODIFICATION
            "PATH=path_list_prepend:$<TARGET_FILE_DIR:libSceLibcInternal>")
    endif()
    add_test_executable(guest_libc_internal_runtime_hooks_tests ${LIBS_INCLUDE_DIR}/tests/GuestLibcInternalRuntimeHooks.cpp)
    target_include_directories(guest_libc_internal_runtime_hooks_tests PRIVATE ${LIBS_INCLUDE_DIR})
    target_link_libraries(guest_libc_internal_runtime_hooks_tests PRIVATE libSceLibcInternal libkernel libc)
    configure_windows_unwind(guest_libc_internal_runtime_hooks_tests)
    add_test(NAME guest_libc_internal_runtime_hooks COMMAND guest_libc_internal_runtime_hooks_tests)
    set_tests_properties(guest_libc_internal_runtime_hooks PROPERTIES TIMEOUT 20)
    if(WIN32)
        set_tests_properties(guest_libc_internal_runtime_hooks PROPERTIES ENVIRONMENT_MODIFICATION
            "PATH=path_list_prepend:$<TARGET_FILE_DIR:libSceLibcInternal>")
    endif()
    add_test_executable(guest_libc_internal_empty_facet_members_tests ${LIBS_INCLUDE_DIR}/tests/GuestLibcInternalEmptyFacetMembers.cpp)
    target_include_directories(guest_libc_internal_empty_facet_members_tests PRIVATE ${LIBS_INCLUDE_DIR})
    target_link_libraries(guest_libc_internal_empty_facet_members_tests PRIVATE libSceLibcInternal libkernel libc)
    configure_windows_unwind(guest_libc_internal_empty_facet_members_tests)
    add_test(NAME guest_libc_internal_empty_facet_members COMMAND guest_libc_internal_empty_facet_members_tests)
    set_tests_properties(guest_libc_internal_empty_facet_members PROPERTIES TIMEOUT 20)
    if(WIN32)
        set_tests_properties(guest_libc_internal_empty_facet_members PROPERTIES ENVIRONMENT_MODIFICATION
            "PATH=path_list_prepend:$<TARGET_FILE_DIR:libSceLibcInternal>")
    endif()
    add_test_executable(guest_libc_internal_facet_queries_tests ${LIBS_INCLUDE_DIR}/tests/GuestLibcInternalFacetQueries.cpp)
    target_include_directories(guest_libc_internal_facet_queries_tests PRIVATE ${LIBS_INCLUDE_DIR})
    target_link_libraries(guest_libc_internal_facet_queries_tests PRIVATE libSceLibcInternal libkernel libc)
    configure_windows_unwind(guest_libc_internal_facet_queries_tests)
    add_test(NAME guest_libc_internal_facet_queries COMMAND guest_libc_internal_facet_queries_tests)
    set_tests_properties(guest_libc_internal_facet_queries PROPERTIES TIMEOUT 20)
    if(WIN32)
        set_tests_properties(guest_libc_internal_facet_queries PROPERTIES ENVIRONMENT_MODIFICATION
            "PATH=path_list_prepend:$<TARGET_FILE_DIR:libSceLibcInternal>")
    endif()
    add_test_executable(guest_libc_internal_messages_tests ${LIBS_INCLUDE_DIR}/tests/GuestLibcInternalMessages.cpp)
    target_include_directories(guest_libc_internal_messages_tests PRIVATE ${LIBS_INCLUDE_DIR})
    target_link_libraries(guest_libc_internal_messages_tests PRIVATE libSceLibcInternal libkernel libc)
    configure_windows_unwind(guest_libc_internal_messages_tests)
    add_test(NAME guest_libc_internal_messages COMMAND guest_libc_internal_messages_tests)
    set_tests_properties(guest_libc_internal_messages PROPERTIES TIMEOUT 20)
    if(WIN32)
        set_tests_properties(guest_libc_internal_messages PROPERTIES ENVIRONMENT_MODIFICATION
            "PATH=path_list_prepend:$<TARGET_FILE_DIR:libSceLibcInternal>")
    endif()
    add_test_executable(guest_getopt_tests ${LIBS_INCLUDE_DIR}/tests/GuestGetopt.cpp)
    target_include_directories(guest_getopt_tests PRIVATE ${LIBS_INCLUDE_DIR})
    target_link_libraries(guest_getopt_tests PRIVATE libSceLibcInternal libkernel libc)
    configure_windows_unwind(guest_getopt_tests)
    add_test(NAME guest_getopt COMMAND guest_getopt_tests)
    set_tests_properties(guest_getopt PROPERTIES TIMEOUT 20)
    if(WIN32)
        set_tests_properties(guest_getopt PROPERTIES ENVIRONMENT_MODIFICATION
            "PATH=path_list_prepend:$<TARGET_FILE_DIR:libSceLibcInternal>")
    endif()
    add_test_executable(guest_inet_address_tests ${LIBS_INCLUDE_DIR}/tests/GuestInetAddress.cpp)
    target_include_directories(guest_inet_address_tests PRIVATE ${LIBS_INCLUDE_DIR})
    target_link_libraries(guest_inet_address_tests PRIVATE libSceLibcInternal libkernel libc)
    configure_windows_unwind(guest_inet_address_tests)
    add_test(NAME guest_inet_address COMMAND guest_inet_address_tests)
    set_tests_properties(guest_inet_address PROPERTIES TIMEOUT 20)
    if(WIN32)
        set_tests_properties(guest_inet_address PROPERTIES ENVIRONMENT_MODIFICATION
            "PATH=path_list_prepend:$<TARGET_FILE_DIR:libSceLibcInternal>")
    endif()
    add_test_executable(guest_force_tls_destructor_tests ${LIBS_INCLUDE_DIR}/tests/GuestForceTlsDestructor.cpp)
    target_include_directories(guest_force_tls_destructor_tests PRIVATE ${LIBS_INCLUDE_DIR})
    target_link_libraries(guest_force_tls_destructor_tests PRIVATE libSceLibcInternal libkernel libc ${CMAKE_DL_LIBS})
    configure_windows_unwind(guest_force_tls_destructor_tests)
    add_test(NAME guest_force_tls_destructor COMMAND guest_force_tls_destructor_tests)
    set_tests_properties(guest_force_tls_destructor PROPERTIES TIMEOUT 20)
    if(WIN32)
        set_tests_properties(guest_force_tls_destructor PROPERTIES ENVIRONMENT_MODIFICATION
            "PATH=path_list_prepend:$<TARGET_FILE_DIR:libSceLibcInternal>")
    endif()
    add_test_executable(guest_fminf_tests ${LIBS_INCLUDE_DIR}/tests/GuestFminf.cpp)
    target_include_directories(guest_fminf_tests PRIVATE ${LIBS_INCLUDE_DIR})
    target_link_libraries(guest_fminf_tests PRIVATE libSceLibcInternal libc)
    configure_windows_unwind(guest_fminf_tests)
    add_test(NAME guest_fminf COMMAND guest_fminf_tests)
    set_tests_properties(guest_fminf PROPERTIES TIMEOUT 20)
    if(WIN32)
        set_tests_properties(guest_fminf PROPERTIES ENVIRONMENT_MODIFICATION
            "PATH=path_list_prepend:$<TARGET_FILE_DIR:libSceLibcInternal>")
    endif()
    add_test_executable(guest_signal_list_tests ${LIBS_INCLUDE_DIR}/tests/GuestSignalList.cpp)
    target_include_directories(guest_signal_list_tests PRIVATE ${LIBS_INCLUDE_DIR})
    target_link_libraries(guest_signal_list_tests PRIVATE libSceLibcInternal)
    configure_windows_unwind(guest_signal_list_tests)
    add_test(NAME guest_signal_list COMMAND guest_signal_list_tests)
    set_tests_properties(guest_signal_list PROPERTIES TIMEOUT 20)
    if(WIN32)
        set_tests_properties(guest_signal_list PROPERTIES ENVIRONMENT_MODIFICATION
            "PATH=path_list_prepend:$<TARGET_FILE_DIR:libSceLibcInternal>")
    endif()

    add_test_executable(guest_legacy_signal_mask_tests ${LIBS_INCLUDE_DIR}/tests/GuestLegacySignalMask.cpp)
    target_include_directories(guest_legacy_signal_mask_tests PRIVATE ${LIBS_INCLUDE_DIR})
    target_link_libraries(guest_legacy_signal_mask_tests PRIVATE libSceLibcInternal libkernel libc)
    configure_windows_unwind(guest_legacy_signal_mask_tests)
    add_test(NAME guest_legacy_signal_mask COMMAND guest_legacy_signal_mask_tests)
    set_tests_properties(guest_legacy_signal_mask PROPERTIES TIMEOUT 10)
    if(WIN32)
        set_tests_properties(guest_legacy_signal_mask PROPERTIES ENVIRONMENT_MODIFICATION
            "PATH=path_list_prepend:$<TARGET_FILE_DIR:libSceLibcInternal>")
    endif()
    add_test_executable(guest_legacy_signal_mask_forwarding_tests
        ${LIBS_INCLUDE_DIR}/tests/GuestLegacySignalMaskForwarding.cpp SignalMask.cpp)
    target_include_directories(guest_legacy_signal_mask_forwarding_tests PRIVATE ${LIBS_INCLUDE_DIR})
    configure_windows_unwind(guest_legacy_signal_mask_forwarding_tests)
    add_test(NAME guest_legacy_signal_mask_forwarding COMMAND guest_legacy_signal_mask_forwarding_tests)
    set_tests_properties(guest_legacy_signal_mask_forwarding PROPERTIES TIMEOUT 10)
endif()

if(BUILD_TESTING)
    add_test_executable(guest_libc_filesystem_tests ${LIBS_INCLUDE_DIR}/tests/GuestLibcFilesystem.cpp)
    target_include_directories(guest_libc_filesystem_tests PRIVATE ${LIBS_INCLUDE_DIR})
    target_link_libraries(guest_libc_filesystem_tests PRIVATE libSceLibcInternal libkernel libc)
    configure_windows_unwind(guest_libc_filesystem_tests)
    add_test(NAME guest_libc_filesystem COMMAND guest_libc_filesystem_tests)
    if(WIN32)
        set_tests_properties(guest_libc_filesystem PROPERTIES ENVIRONMENT_MODIFICATION
            "PATH=path_list_prepend:$<TARGET_FILE_DIR:libSceLibcInternal>")
    endif()
endif()

target_sources(libSceLibcInternal PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}/Sigvec.cpp)

if(BUILD_TESTING AND (WIN32 OR CMAKE_SYSTEM_NAME STREQUAL "Linux"))
    add_test_executable(guest_sigvec_modules_tests
        ${LIBS_INCLUDE_DIR}/tests/GuestSigvecModules.cpp
        ${LIBS_INCLUDE_DIR}/nid/src/NidCompute.cpp
        ${LIBS_INCLUDE_DIR}/nid/src/Sha1.cpp)
    target_include_directories(guest_sigvec_modules_tests PRIVATE ${LIBS_INCLUDE_DIR} ${LIBS_INCLUDE_DIR}/nid/include)
    target_link_libraries(guest_sigvec_modules_tests PRIVATE ${CMAKE_DL_LIBS})
    set_source_files_properties(${LIBS_INCLUDE_DIR}/tests/GuestSigvecModules.cpp PROPERTIES COMPILE_OPTIONS "-fno-exceptions;-fno-asynchronous-unwind-tables")
    if(MINGW)
        target_compile_options(guest_sigvec_modules_tests PRIVATE -fasynchronous-unwind-tables)
        target_link_options(guest_sigvec_modules_tests PRIVATE -static -static-libgcc -static-libstdc++)
    endif()
    add_library(sigvec_modules_exceptions SHARED ${LIBS_INCLUDE_DIR}/tests/SigvecModulesExceptions.cpp)
    target_include_directories(sigvec_modules_exceptions PRIVATE ${LIBS_INCLUDE_DIR})
    target_link_libraries(sigvec_modules_exceptions PRIVATE libc)
    set_target_properties(sigvec_modules_exceptions PROPERTIES WINDOWS_EXPORT_ALL_SYMBOLS ON)
    configure_windows_unwind(sigvec_modules_exceptions)
    add_dependencies(guest_sigvec_modules_tests libc libkernel libSceLibcInternal nid_patcher sigvec_modules_exceptions)
    set(sigvecAllocatorArgument)
    if(TARGET mimalloc)
        set(sigvecAllocatorArgument -DALLOCATOR_DIRECTORY=$<TARGET_FILE_DIR:mimalloc>)
    endif()
    add_test(NAME guest_sigvec_modules COMMAND ${CMAKE_COMMAND}
        -DEXCEPTION_PROBE=$<TARGET_FILE:sigvec_modules_exceptions>
        -DPATCHER=$<TARGET_FILE:nid_patcher>
        -DLIBC=$<TARGET_FILE:libc>
        -DKERNEL=$<TARGET_FILE:libkernel>
        -DINTERNAL=$<TARGET_FILE:libSceLibcInternal>
        ${sigvecAllocatorArgument}
        -DWORK_DIR=${CMAKE_CURRENT_BINARY_DIR}/sigvec-modules
        -P ${LIBS_INCLUDE_DIR}/tests/SigvecModules.cmake
        -- "$<TARGET_FILE:guest_sigvec_modules_tests>")
    set_tests_properties(guest_sigvec_modules PROPERTIES TIMEOUT 20)
endif()

target_sources(libSceLibcInternal PRIVATE QuadrantTrig.cpp)
if(BUILD_TESTING)
    add_test_executable(guest_libc_internal_quadrant_trig_tests ${LIBS_INCLUDE_DIR}/tests/GuestLibcInternalQuadrantTrig.cpp)
    target_include_directories(guest_libc_internal_quadrant_trig_tests PRIVATE ${LIBS_INCLUDE_DIR})
    target_link_libraries(guest_libc_internal_quadrant_trig_tests PRIVATE libSceLibcInternal libkernel libc)
    configure_windows_unwind(guest_libc_internal_quadrant_trig_tests)
    add_test(NAME guest_libc_internal_quadrant_trig COMMAND guest_libc_internal_quadrant_trig_tests)
    set_tests_properties(guest_libc_internal_quadrant_trig PROPERTIES TIMEOUT 20)
    if(WIN32)
        set_tests_properties(guest_libc_internal_quadrant_trig PROPERTIES ENVIRONMENT_MODIFICATION
            "PATH=path_list_prepend:$<TARGET_FILE_DIR:libSceLibcInternal>")
    endif()
endif()

target_sources(libSceLibcInternal PRIVATE ExtendedPrecisionDouble.cpp)
if(BUILD_TESTING)
    add_test_executable(guest_libc_internal_extended_precision_double_tests ${LIBS_INCLUDE_DIR}/tests/GuestLibcInternalExtendedPrecisionDouble.cpp)
    target_include_directories(guest_libc_internal_extended_precision_double_tests PRIVATE ${LIBS_INCLUDE_DIR})
    target_link_libraries(guest_libc_internal_extended_precision_double_tests PRIVATE libSceLibcInternal libkernel libc)
    configure_windows_unwind(guest_libc_internal_extended_precision_double_tests)
    add_test(NAME guest_libc_internal_extended_precision_double COMMAND guest_libc_internal_extended_precision_double_tests)
    set_tests_properties(guest_libc_internal_extended_precision_double PROPERTIES TIMEOUT 20)
    if(WIN32)
        set_tests_properties(guest_libc_internal_extended_precision_double PROPERTIES ENVIRONMENT_MODIFICATION
            "PATH=path_list_prepend:$<TARGET_FILE_DIR:libSceLibcInternal>")
    endif()
endif()

target_sources(libSceLibcInternal PRIVATE MultiPrecision.cpp)
if(BUILD_TESTING)
    add_test_executable(guest_libc_internal_multi_precision_tests ${LIBS_INCLUDE_DIR}/tests/GuestLibcInternalMultiPrecision.cpp)
    target_include_directories(guest_libc_internal_multi_precision_tests PRIVATE ${LIBS_INCLUDE_DIR})
    target_link_libraries(guest_libc_internal_multi_precision_tests PRIVATE libSceLibcInternal libkernel libc)
    configure_windows_unwind(guest_libc_internal_multi_precision_tests)
    add_test(NAME guest_libc_internal_multi_precision COMMAND guest_libc_internal_multi_precision_tests)
    set_tests_properties(guest_libc_internal_multi_precision PROPERTIES TIMEOUT 20)
    if(WIN32)
        set_tests_properties(guest_libc_internal_multi_precision PROPERTIES ENVIRONMENT_MODIFICATION
            "PATH=path_list_prepend:$<TARGET_FILE_DIR:libSceLibcInternal>")
    endif()
endif()

if(BUILD_TESTING)
    add_test_executable(guest_libc_internal_firmware_answers_tests ${LIBS_INCLUDE_DIR}/tests/GuestLibcInternalFirmwareAnswers.cpp)
    target_include_directories(guest_libc_internal_firmware_answers_tests PRIVATE ${LIBS_INCLUDE_DIR})
    target_link_libraries(guest_libc_internal_firmware_answers_tests PRIVATE libSceLibcInternal libkernel libc)
    configure_windows_unwind(guest_libc_internal_firmware_answers_tests)
    add_test(NAME guest_libc_internal_firmware_answers COMMAND guest_libc_internal_firmware_answers_tests)
    set_tests_properties(guest_libc_internal_firmware_answers PROPERTIES TIMEOUT 20)
    if(WIN32)
        set_tests_properties(guest_libc_internal_firmware_answers PROPERTIES ENVIRONMENT_MODIFICATION
            "PATH=path_list_prepend:$<TARGET_FILE_DIR:libSceLibcInternal>")
    endif()
endif()

target_sources(libSceLibcInternal PRIVATE FacetReferences.cpp)
if(BUILD_TESTING)
    add_test_executable(guest_libc_internal_facet_references_tests ${LIBS_INCLUDE_DIR}/tests/GuestLibcInternalFacetReferences.cpp)
    target_include_directories(guest_libc_internal_facet_references_tests PRIVATE ${LIBS_INCLUDE_DIR})
    target_link_libraries(guest_libc_internal_facet_references_tests PRIVATE libSceLibcInternal libkernel libc)
    configure_windows_unwind(guest_libc_internal_facet_references_tests)
    add_test(NAME guest_libc_internal_facet_references COMMAND guest_libc_internal_facet_references_tests)
    set_tests_properties(guest_libc_internal_facet_references PROPERTIES TIMEOUT 20)
    if(WIN32)
        set_tests_properties(guest_libc_internal_facet_references PROPERTIES ENVIRONMENT_MODIFICATION
            "PATH=path_list_prepend:$<TARGET_FILE_DIR:libSceLibcInternal>")
    endif()
endif()

target_sources(libSceLibcInternal PRIVATE FloatWords.cpp)
if(BUILD_TESTING)
    add_test_executable(guest_float_words_tests ${LIBS_INCLUDE_DIR}/tests/GuestFloatWords.cpp)
    target_include_directories(guest_float_words_tests PRIVATE ${LIBS_INCLUDE_DIR})
    target_link_libraries(guest_float_words_tests PRIVATE libSceLibcInternal libc)
    configure_windows_unwind(guest_float_words_tests)
    add_test(NAME guest_float_words COMMAND guest_float_words_tests)
    set_tests_properties(guest_float_words PROPERTIES TIMEOUT 20)
    if(WIN32)
        set_tests_properties(guest_float_words PROPERTIES ENVIRONMENT_MODIFICATION
            "PATH=path_list_prepend:$<TARGET_FILE_DIR:libc>")
    endif()
endif()

target_sources(libSceLibcInternal PRIVATE Unexpected.cpp)
if(BUILD_TESTING)
    add_test_executable(guest_libc_internal_unexpected_tests ${LIBS_INCLUDE_DIR}/tests/GuestLibcInternalUnexpected.cpp)
    target_include_directories(guest_libc_internal_unexpected_tests PRIVATE ${LIBS_INCLUDE_DIR})
    target_link_libraries(guest_libc_internal_unexpected_tests PRIVATE libSceLibcInternal libkernel libc)
    configure_windows_unwind(guest_libc_internal_unexpected_tests)
    add_test(NAME guest_libc_internal_unexpected COMMAND guest_libc_internal_unexpected_tests)
    set_tests_properties(guest_libc_internal_unexpected PROPERTIES TIMEOUT 20)
    if(WIN32)
        set_tests_properties(guest_libc_internal_unexpected PROPERTIES ENVIRONMENT_MODIFICATION
            "PATH=path_list_prepend:$<TARGET_FILE_DIR:libSceLibcInternal>")
    endif()
endif()

target_sources(libSceLibcInternal PRIVATE NestedException.cpp)
if(BUILD_TESTING)
    add_test_executable(guest_libc_internal_nested_exception_tests ${LIBS_INCLUDE_DIR}/tests/GuestLibcInternalNestedException.cpp)
    target_include_directories(guest_libc_internal_nested_exception_tests PRIVATE ${LIBS_INCLUDE_DIR})
    target_link_libraries(guest_libc_internal_nested_exception_tests PRIVATE libSceLibcInternal libkernel libc)
    configure_windows_unwind(guest_libc_internal_nested_exception_tests)
    add_test(NAME guest_libc_internal_nested_exception COMMAND guest_libc_internal_nested_exception_tests)
    set_tests_properties(guest_libc_internal_nested_exception PROPERTIES TIMEOUT 20)
    if(WIN32)
        set_tests_properties(guest_libc_internal_nested_exception PROPERTIES ENVIRONMENT_MODIFICATION
            "PATH=path_list_prepend:$<TARGET_FILE_DIR:libSceLibcInternal>")
    endif()
endif()
target_sources(libSceLibcInternal PRIVATE FloatDigits.cpp)
if(BUILD_TESTING)
    add_test_executable(guest_libc_internal_float_digits_tests ${LIBS_INCLUDE_DIR}/tests/GuestLibcInternalFloatDigits.cpp)
    target_include_directories(guest_libc_internal_float_digits_tests PRIVATE ${LIBS_INCLUDE_DIR})
    target_link_libraries(guest_libc_internal_float_digits_tests PRIVATE libSceLibcInternal libkernel libc)
    configure_windows_unwind(guest_libc_internal_float_digits_tests)
    add_test(NAME guest_libc_internal_float_digits COMMAND guest_libc_internal_float_digits_tests)
    set_tests_properties(guest_libc_internal_float_digits PROPERTIES TIMEOUT 20)
    if(WIN32)
        set_tests_properties(guest_libc_internal_float_digits PROPERTIES ENVIRONMENT_MODIFICATION
            "PATH=path_list_prepend:$<TARGET_FILE_DIR:libSceLibcInternal>")
    endif()
endif()

target_sources(libSceLibcInternal PRIVATE CodecvtChar.cpp)
target_sources(libSceLibcInternal PRIVATE CodecvtUtfMetadata.cpp)
if(BUILD_TESTING)
    add_test_executable(guest_codecvt_utf_metadata_tests ${LIBS_INCLUDE_DIR}/tests/GuestCodecvtUtfMetadata.cpp)
    target_include_directories(guest_codecvt_utf_metadata_tests PRIVATE ${LIBS_INCLUDE_DIR})
    target_link_libraries(guest_codecvt_utf_metadata_tests PRIVATE libSceLibcInternal libkernel libc)
    configure_windows_unwind(guest_codecvt_utf_metadata_tests)
    add_test(NAME guest_codecvt_utf_metadata COMMAND guest_codecvt_utf_metadata_tests)
    set_tests_properties(guest_codecvt_utf_metadata PROPERTIES TIMEOUT 20)
    if(WIN32)
        set_tests_properties(guest_codecvt_utf_metadata PROPERTIES ENVIRONMENT_MODIFICATION
            "PATH=path_list_prepend:$<TARGET_FILE_DIR:libSceLibcInternal>")
    endif()
endif()
if(BUILD_TESTING)
    add_test_executable(guest_libc_internal_codecvt_char_tests ${LIBS_INCLUDE_DIR}/tests/GuestLibcInternalCodecvtChar.cpp)
    target_include_directories(guest_libc_internal_codecvt_char_tests PRIVATE ${LIBS_INCLUDE_DIR})
    target_link_libraries(guest_libc_internal_codecvt_char_tests PRIVATE libSceLibcInternal libkernel libc ${CMAKE_DL_LIBS})
    configure_windows_unwind(guest_libc_internal_codecvt_char_tests)
    add_test(NAME guest_libc_internal_codecvt_char COMMAND guest_libc_internal_codecvt_char_tests $<TARGET_FILE:libSceLibcInternal>)
    set_tests_properties(guest_libc_internal_codecvt_char PROPERTIES TIMEOUT 20)
    if(WIN32)
        set_tests_properties(guest_libc_internal_codecvt_char PROPERTIES ENVIRONMENT_MODIFICATION
            "PATH=path_list_prepend:$<TARGET_FILE_DIR:libSceLibcInternal>")
    endif()
endif()

if(BUILD_TESTING)
    add_test_executable(guest_libc_internal_ctype_tests ${LIBS_INCLUDE_DIR}/tests/GuestLibcInternalCtype.cpp)
    target_include_directories(guest_libc_internal_ctype_tests PRIVATE ${LIBS_INCLUDE_DIR})
    target_link_libraries(guest_libc_internal_ctype_tests PRIVATE libSceLibcInternal libkernel libc)
    configure_windows_unwind(guest_libc_internal_ctype_tests)
    add_test(NAME guest_libc_internal_ctype COMMAND guest_libc_internal_ctype_tests)
    set_tests_properties(guest_libc_internal_ctype PROPERTIES TIMEOUT 20)
    if(WIN32)
        set_tests_properties(guest_libc_internal_ctype PROPERTIES ENVIRONMENT_MODIFICATION
            "PATH=path_list_prepend:$<TARGET_FILE_DIR:libSceLibcInternal>")
    endif()

    add_test_executable(guest_ctype_case_tests ${LIBS_INCLUDE_DIR}/tests/GuestCtypeCase.cpp)
    target_include_directories(guest_ctype_case_tests PRIVATE ${LIBS_INCLUDE_DIR})
    target_link_libraries(guest_ctype_case_tests PRIVATE libSceLibcInternal libc libkernel)
    configure_windows_unwind(guest_ctype_case_tests)
    add_test(NAME guest_ctype_case COMMAND guest_ctype_case_tests)
    set_tests_properties(guest_ctype_case PROPERTIES TIMEOUT 20)
    if(WIN32)
        set_tests_properties(guest_ctype_case PROPERTIES ENVIRONMENT_MODIFICATION
            "PATH=path_list_prepend:$<TARGET_FILE_DIR:libSceLibcInternal>")
    endif()
endif()

target_sources(libSceLibcInternal PRIVATE LogGamma.cpp)
if(BUILD_TESTING)
    add_test_executable(guest_libc_internal_log_gamma_tests ${LIBS_INCLUDE_DIR}/tests/GuestLibcInternalLogGamma.cpp)
    target_include_directories(guest_libc_internal_log_gamma_tests PRIVATE ${LIBS_INCLUDE_DIR})
    target_link_libraries(guest_libc_internal_log_gamma_tests PRIVATE libSceLibcInternal libc)
    configure_windows_unwind(guest_libc_internal_log_gamma_tests)
    add_test(NAME guest_libc_internal_log_gamma COMMAND guest_libc_internal_log_gamma_tests)
    if(WIN32)
        set_tests_properties(guest_libc_internal_log_gamma PROPERTIES ENVIRONMENT_MODIFICATION
            "PATH=path_list_prepend:$<TARGET_FILE_DIR:libSceLibcInternal>")
    endif()
endif()

target_sources(libSceLibcInternal PRIVATE CollationWorkers.cpp)
if(BUILD_TESTING)
    add_test_executable(guest_libc_internal_collation_workers_tests ${LIBS_INCLUDE_DIR}/tests/GuestLibcInternalCollationWorkers.cpp)
    target_include_directories(guest_libc_internal_collation_workers_tests PRIVATE ${LIBS_INCLUDE_DIR})
    target_link_libraries(guest_libc_internal_collation_workers_tests PRIVATE libSceLibcInternal libkernel libc)
    configure_windows_unwind(guest_libc_internal_collation_workers_tests)
    add_test(NAME guest_libc_internal_collation_workers COMMAND guest_libc_internal_collation_workers_tests)
    set_tests_properties(guest_libc_internal_collation_workers PROPERTIES TIMEOUT 20)
    if(WIN32)
        set_tests_properties(guest_libc_internal_collation_workers PROPERTIES ENVIRONMENT_MODIFICATION
            "PATH=path_list_prepend:$<TARGET_FILE_DIR:libSceLibcInternal>")
    endif()
endif()

target_sources(libSceLibcInternal PRIVATE CollationState.cpp)
if(BUILD_TESTING)
    add_test_executable(guest_libc_internal_collation_state_tests ${LIBS_INCLUDE_DIR}/tests/GuestLibcInternalCollationState.cpp)
    target_include_directories(guest_libc_internal_collation_state_tests PRIVATE ${LIBS_INCLUDE_DIR})
    target_link_libraries(guest_libc_internal_collation_state_tests PRIVATE libSceLibcInternal libkernel libc)
    configure_windows_unwind(guest_libc_internal_collation_state_tests)
    add_test(NAME guest_libc_internal_collation_state COMMAND guest_libc_internal_collation_state_tests)
    set_tests_properties(guest_libc_internal_collation_state PROPERTIES TIMEOUT 20)
    if(WIN32)
        set_tests_properties(guest_libc_internal_collation_state PROPERTIES ENVIRONMENT_MODIFICATION
            "PATH=path_list_prepend:$<TARGET_FILE_DIR:libSceLibcInternal>")
    endif()
endif()
if(BUILD_TESTING)
    add_test_executable(guest_libc_internal_strxfrm_tests ${LIBS_INCLUDE_DIR}/tests/GuestLibcInternalStrxfrm.cpp)
    target_include_directories(guest_libc_internal_strxfrm_tests PRIVATE ${LIBS_INCLUDE_DIR})
    target_link_libraries(guest_libc_internal_strxfrm_tests PRIVATE libSceLibcInternal libc libkernel)
    configure_windows_unwind(guest_libc_internal_strxfrm_tests)
    add_test(NAME guest_libc_internal_strxfrm COMMAND guest_libc_internal_strxfrm_tests)
    set_tests_properties(guest_libc_internal_strxfrm PROPERTIES TIMEOUT 20)
    if(WIN32)
        set_tests_properties(guest_libc_internal_strxfrm PROPERTIES ENVIRONMENT_MODIFICATION
            "PATH=path_list_prepend:$<TARGET_FILE_DIR:libSceLibcInternal>")
    endif()
endif()

target_sources(libSceLibcInternal PRIVATE Filebuf.cpp StreambufTransfer.cpp)
if(BUILD_TESTING)
    add_test_executable(guest_libc_internal_filebuf_unlock_tests ${LIBS_INCLUDE_DIR}/tests/GuestLibcInternalFilebufUnlock.cpp)
    target_include_directories(guest_libc_internal_filebuf_unlock_tests PRIVATE ${LIBS_INCLUDE_DIR})
    target_link_libraries(guest_libc_internal_filebuf_unlock_tests PRIVATE libSceLibcInternal libkernel libc)
    configure_windows_unwind(guest_libc_internal_filebuf_unlock_tests)
    add_test(NAME guest_libc_internal_filebuf_unlock COMMAND guest_libc_internal_filebuf_unlock_tests)
    set_tests_properties(guest_libc_internal_filebuf_unlock PROPERTIES TIMEOUT 20)
    if(WIN32)
        set_tests_properties(guest_libc_internal_filebuf_unlock PROPERTIES ENVIRONMENT_MODIFICATION
            "PATH=path_list_prepend:$<TARGET_FILE_DIR:libSceLibcInternal>")
    endif()
endif()

if(BUILD_TESTING)
    add_test_executable(guest_libc_internal_filebuf_io_tests ${LIBS_INCLUDE_DIR}/tests/GuestLibcInternalFilebufIo.cpp)
    target_include_directories(guest_libc_internal_filebuf_io_tests PRIVATE ${LIBS_INCLUDE_DIR})
    target_link_libraries(guest_libc_internal_filebuf_io_tests PRIVATE libSceLibcInternal libkernel libc)
    configure_windows_unwind(guest_libc_internal_filebuf_io_tests)
    add_test(NAME guest_libc_internal_filebuf_io COMMAND guest_libc_internal_filebuf_io_tests)
    set_tests_properties(guest_libc_internal_filebuf_io PROPERTIES TIMEOUT 20)
    if(WIN32)
        set_tests_properties(guest_libc_internal_filebuf_io PROPERTIES ENVIRONMENT_MODIFICATION
            "PATH=path_list_prepend:$<TARGET_FILE_DIR:libSceLibcInternal>")
    endif()
endif()

if(BUILD_TESTING)
    add_test_executable(guest_libc_internal_streambuf_transfer_tests ${LIBS_INCLUDE_DIR}/tests/GuestLibcInternalStreambufTransfer.cpp)
    target_include_directories(guest_libc_internal_streambuf_transfer_tests PRIVATE ${LIBS_INCLUDE_DIR})
    target_link_libraries(guest_libc_internal_streambuf_transfer_tests PRIVATE libSceLibcInternal libkernel libc)
    configure_windows_unwind(guest_libc_internal_streambuf_transfer_tests)
    add_test(NAME guest_libc_internal_streambuf_transfer COMMAND guest_libc_internal_streambuf_transfer_tests)
    set_tests_properties(guest_libc_internal_streambuf_transfer PROPERTIES TIMEOUT 20)
    if(WIN32)
        set_tests_properties(guest_libc_internal_streambuf_transfer PROPERTIES ENVIRONMENT_MODIFICATION
            "PATH=path_list_prepend:$<TARGET_FILE_DIR:libSceLibcInternal>")
    endif()
endif()

target_sources(libSceLibcInternal PRIVATE TimeGetFields.cpp)
if(BUILD_TESTING)
    add_test_executable(guest_libc_internal_time_get_fields_tests ${LIBS_INCLUDE_DIR}/tests/GuestLibcInternalTimeGetFields.cpp)
    target_include_directories(guest_libc_internal_time_get_fields_tests PRIVATE ${LIBS_INCLUDE_DIR})
    target_link_libraries(guest_libc_internal_time_get_fields_tests PRIVATE libSceLibcInternal libkernel libc ${CMAKE_DL_LIBS})
    configure_windows_unwind(guest_libc_internal_time_get_fields_tests)
    add_test(NAME guest_libc_internal_time_get_fields COMMAND guest_libc_internal_time_get_fields_tests $<TARGET_FILE:libSceLibcInternal>)
    set_tests_properties(guest_libc_internal_time_get_fields PROPERTIES TIMEOUT 20)
    if(WIN32)
        set_tests_properties(guest_libc_internal_time_get_fields PROPERTIES ENVIRONMENT_MODIFICATION
            "PATH=path_list_prepend:$<TARGET_FILE_DIR:libSceLibcInternal>")
    endif()
endif()

if(BUILD_TESTING)
    add_test_executable(guest_libc_internal_time_put_c2_tests ${LIBS_INCLUDE_DIR}/tests/GuestLibcInternalTimePutC2.cpp)
    target_include_directories(guest_libc_internal_time_put_c2_tests PRIVATE ${LIBS_INCLUDE_DIR})
    target_link_libraries(guest_libc_internal_time_put_c2_tests PRIVATE libSceLibcInternal libkernel libc)
    configure_windows_unwind(guest_libc_internal_time_put_c2_tests)
    add_test(NAME guest_libc_internal_time_put_c2 COMMAND guest_libc_internal_time_put_c2_tests)
    set_tests_properties(guest_libc_internal_time_put_c2 PROPERTIES TIMEOUT 20)
endif()

if(BUILD_TESTING)
    add_test_executable(guest_libc_internal_filebuf_lock_tests ${LIBS_INCLUDE_DIR}/tests/GuestLibcInternalFilebufLock.cpp)
    target_include_directories(guest_libc_internal_filebuf_lock_tests PRIVATE ${LIBS_INCLUDE_DIR})
    target_link_libraries(guest_libc_internal_filebuf_lock_tests PRIVATE libSceLibcInternal libkernel libc)
    configure_windows_unwind(guest_libc_internal_filebuf_lock_tests)
    add_test(NAME guest_libc_internal_filebuf_lock COMMAND guest_libc_internal_filebuf_lock_tests)
    set_tests_properties(guest_libc_internal_filebuf_lock PROPERTIES TIMEOUT 20)
    if(WIN32)
        set_tests_properties(guest_libc_internal_filebuf_lock PROPERTIES ENVIRONMENT_MODIFICATION
            "PATH=path_list_prepend:$<TARGET_FILE_DIR:libSceLibcInternal>")
    endif()
endif()

target_sources(libSceLibcInternal PRIVATE Fiopen.cpp)
if(BUILD_TESTING)
    add_test_executable(guest_libc_internal_wide_fiopen_tests ${LIBS_INCLUDE_DIR}/tests/GuestLibcInternalWideFiopen.cpp)
    target_include_directories(guest_libc_internal_wide_fiopen_tests PRIVATE ${LIBS_INCLUDE_DIR})
    target_link_libraries(guest_libc_internal_wide_fiopen_tests PRIVATE libSceLibcInternal libkernel libc)
    configure_windows_unwind(guest_libc_internal_wide_fiopen_tests)
    add_test(NAME guest_libc_internal_wide_fiopen COMMAND guest_libc_internal_wide_fiopen_tests)
    set_tests_properties(guest_libc_internal_wide_fiopen PROPERTIES TIMEOUT 20)
    if(WIN32)
        set_tests_properties(guest_libc_internal_wide_fiopen PROPERTIES ENVIRONMENT_MODIFICATION
            "PATH=path_list_prepend:$<TARGET_FILE_DIR:libSceLibcInternal>")
    endif()
endif()

target_sources(libSceLibcInternal PRIVATE DinkumThreadErrors.cpp)
if(BUILD_TESTING)
    add_test_executable(guest_dinkum_thread_errors_tests ${LIBS_INCLUDE_DIR}/tests/GuestDinkumThreadErrors.cpp)
    target_include_directories(guest_dinkum_thread_errors_tests PRIVATE ${LIBS_INCLUDE_DIR})
    target_link_libraries(guest_dinkum_thread_errors_tests PRIVATE libSceLibcInternal libkernel libc)
    configure_windows_unwind(guest_dinkum_thread_errors_tests)
    foreach(test destructors throws allocation_failure)
        add_test(NAME guest_dinkum_thread_errors_${test} COMMAND guest_dinkum_thread_errors_tests ${test})
        set_tests_properties(guest_dinkum_thread_errors_${test} PROPERTIES TIMEOUT 20)
        if(WIN32)
            set_tests_properties(guest_dinkum_thread_errors_${test} PROPERTIES ENVIRONMENT_MODIFICATION
                "PATH=path_list_prepend:$<TARGET_FILE_DIR:libSceLibcInternal>")
        endif()
    endforeach()
endif()

if(BUILD_TESTING)
    add_test_executable(guest_libc_internal_exception_report_tests ${LIBS_INCLUDE_DIR}/tests/GuestLibcInternalExceptionReport.cpp)
    target_include_directories(guest_libc_internal_exception_report_tests PRIVATE ${LIBS_INCLUDE_DIR})
    target_link_libraries(guest_libc_internal_exception_report_tests PRIVATE libSceLibcInternal libkernel libc ${CMAKE_DL_LIBS})
    configure_windows_unwind(guest_libc_internal_exception_report_tests)
    add_test(NAME guest_libc_internal_exception_report COMMAND guest_libc_internal_exception_report_tests $<TARGET_FILE:libSceLibcInternal>)
    set_tests_properties(guest_libc_internal_exception_report PROPERTIES TIMEOUT 20)
    if(WIN32)
        set_tests_properties(guest_libc_internal_exception_report PROPERTIES ENVIRONMENT_MODIFICATION
            "PATH=path_list_prepend:$<TARGET_FILE_DIR:libSceLibcInternal>")
    endif()
endif()
target_sources(libSceLibcInternal PRIVATE NumPutFormat.cpp)
if(BUILD_TESTING)
    add_test_executable(guest_libc_internal_num_put_format_tests ${LIBS_INCLUDE_DIR}/tests/GuestLibcInternalNumPutFormat.cpp)
    target_include_directories(guest_libc_internal_num_put_format_tests PRIVATE ${LIBS_INCLUDE_DIR})
    target_link_libraries(guest_libc_internal_num_put_format_tests PRIVATE libSceLibcInternal libkernel libc)
    configure_windows_unwind(guest_libc_internal_num_put_format_tests)
    add_test(NAME guest_libc_internal_num_put_format COMMAND guest_libc_internal_num_put_format_tests)
    set_tests_properties(guest_libc_internal_num_put_format PROPERTIES TIMEOUT 20)
    if(WIN32)
        set_tests_properties(guest_libc_internal_num_put_format PROPERTIES ENVIRONMENT_MODIFICATION
            "PATH=path_list_prepend:$<TARGET_FILE_DIR:libSceLibcInternal>")
    endif()
endif()
target_sources(libSceLibcInternal PRIVATE NumPutField.cpp)
if(BUILD_TESTING)
    add_test_executable(guest_libc_internal_num_put_field_tests ${CMAKE_CURRENT_SOURCE_DIR}/tests/NumPutField.cpp)
    target_include_directories(guest_libc_internal_num_put_field_tests PRIVATE ${LIBS_INCLUDE_DIR})
    target_link_libraries(guest_libc_internal_num_put_field_tests PRIVATE libSceLibcInternal libkernel libc)
    configure_windows_unwind(guest_libc_internal_num_put_field_tests)
    add_test(NAME guest_libc_internal_num_put_field COMMAND guest_libc_internal_num_put_field_tests)
    set_tests_properties(guest_libc_internal_num_put_field PROPERTIES TIMEOUT 20)
    if(WIN32)
        set_tests_properties(guest_libc_internal_num_put_field PROPERTIES ENVIRONMENT_MODIFICATION
            "PATH=path_list_prepend:$<TARGET_FILE_DIR:libSceLibcInternal>")
    endif()
endif()
target_sources(libSceLibcInternal PRIVATE Rint.cpp)
if(BUILD_TESTING)
    add_test_executable(guest_libc_internal_rint_tests ${LIBS_INCLUDE_DIR}/tests/GuestLibcInternalRint.cpp)
    target_include_directories(guest_libc_internal_rint_tests PRIVATE ${LIBS_INCLUDE_DIR})
    target_link_libraries(guest_libc_internal_rint_tests PRIVATE libSceLibcInternal libkernel libc)
    configure_windows_unwind(guest_libc_internal_rint_tests)
    add_test(NAME guest_libc_internal_rint COMMAND guest_libc_internal_rint_tests)
    set_tests_properties(guest_libc_internal_rint PROPERTIES TIMEOUT 20)
    if(WIN32)
        set_tests_properties(guest_libc_internal_rint PROPERTIES ENVIRONMENT_MODIFICATION
            "PATH=path_list_prepend:$<TARGET_FILE_DIR:libSceLibcInternal>")
    endif()
endif()
target_sources(libSceLibcInternal PRIVATE Multibyte.cpp)
if(BUILD_TESTING)
    add_test_executable(guest_libc_internal_multibyte_tests ${LIBS_INCLUDE_DIR}/tests/GuestLibcInternalMultibyte.cpp)
    target_include_directories(guest_libc_internal_multibyte_tests PRIVATE ${LIBS_INCLUDE_DIR})
    target_link_libraries(guest_libc_internal_multibyte_tests PRIVATE libSceLibcInternal libkernel libc)
    configure_windows_unwind(guest_libc_internal_multibyte_tests)
    add_test(NAME guest_libc_internal_multibyte COMMAND guest_libc_internal_multibyte_tests)
    set_tests_properties(guest_libc_internal_multibyte PROPERTIES TIMEOUT 20)
    if(WIN32)
        set_tests_properties(guest_libc_internal_multibyte PROPERTIES ENVIRONMENT_MODIFICATION
            "PATH=path_list_prepend:$<TARGET_FILE_DIR:libSceLibcInternal>")
    endif()
endif()
target_sources(libSceLibcInternal PRIVATE Tgamma.cpp)
if(BUILD_TESTING)
    add_test_executable(guest_libc_internal_tgamma_tests ${LIBS_INCLUDE_DIR}/tests/GuestLibcInternalTgamma.cpp)
    target_include_directories(guest_libc_internal_tgamma_tests PRIVATE ${LIBS_INCLUDE_DIR})
    target_link_libraries(guest_libc_internal_tgamma_tests PRIVATE libSceLibcInternal libkernel libc)
    configure_windows_unwind(guest_libc_internal_tgamma_tests)
    add_test(NAME guest_libc_internal_tgamma COMMAND guest_libc_internal_tgamma_tests)
    set_tests_properties(guest_libc_internal_tgamma PROPERTIES TIMEOUT 20)
    if(WIN32)
        set_tests_properties(guest_libc_internal_tgamma PROPERTIES ENVIRONMENT_MODIFICATION
            "PATH=path_list_prepend:$<TARGET_FILE_DIR:libSceLibcInternal>")
    endif()
endif()
if(BUILD_TESTING)
    add_test_executable(guest_libc_internal_at_exit_tests ${LIBS_INCLUDE_DIR}/tests/GuestLibcInternalAtExit.cpp)
    target_include_directories(guest_libc_internal_at_exit_tests PRIVATE ${LIBS_INCLUDE_DIR})
    target_link_libraries(guest_libc_internal_at_exit_tests PRIVATE libSceLibcInternal libkernel libc)
    configure_windows_unwind(guest_libc_internal_at_exit_tests)
    add_test(NAME guest_libc_internal_at_thread_exit COMMAND guest_libc_internal_at_exit_tests)
    add_test(NAME guest_libc_internal_at_quick_exit COMMAND guest_libc_internal_at_exit_tests --quick-exit)
    set_tests_properties(guest_libc_internal_at_thread_exit guest_libc_internal_at_quick_exit PROPERTIES TIMEOUT 20)
    set_tests_properties(guest_libc_internal_at_quick_exit PROPERTIES
        PASS_REGULAR_EXPRESSION "Guest quick_exit handlers completed")
    if(WIN32)
        set_tests_properties(guest_libc_internal_at_thread_exit guest_libc_internal_at_quick_exit PROPERTIES ENVIRONMENT_MODIFICATION
            "PATH=path_list_prepend:$<TARGET_FILE_DIR:libSceLibcInternal>")
    endif()
endif()
