add_library(libSceNpCppWebApi SHARED EXCLUDE_FROM_ALL Export.cpp)
target_include_directories(libSceNpCppWebApi PRIVATE ${LIBS_INCLUDE_DIR})
configure_windows_unwind(libSceNpCppWebApi)

if(BUILD_TESTING)
    add_test_executable(guest_np_cpp_web_api_product_tests ${LIBS_INCLUDE_DIR}/tests/GuestNpCppWebApiProduct.cpp)
    target_include_directories(guest_np_cpp_web_api_product_tests PRIVATE ${LIBS_INCLUDE_DIR})
    target_link_libraries(guest_np_cpp_web_api_product_tests PRIVATE libSceNpCppWebApi libc)
    configure_windows_unwind(guest_np_cpp_web_api_product_tests)
    add_test(NAME guest_np_cpp_web_api_product COMMAND guest_np_cpp_web_api_product_tests)
    if(WIN32)
        set_tests_properties(guest_np_cpp_web_api_product
            PROPERTIES ENVIRONMENT_MODIFICATION "PATH=path_list_prepend:$<TARGET_FILE_DIR:libc>")
    endif()
    add_test_executable(guest_np_cpp_web_api_matchmaking_tests ${LIBS_INCLUDE_DIR}/tests/GuestNpCppWebApiMatchmaking.cpp)
    target_include_directories(guest_np_cpp_web_api_matchmaking_tests PRIVATE ${LIBS_INCLUDE_DIR})
    target_link_libraries(guest_np_cpp_web_api_matchmaking_tests PRIVATE libSceNpCppWebApi libc)
    configure_windows_unwind(guest_np_cpp_web_api_matchmaking_tests)
    add_test(NAME guest_np_cpp_web_api_matchmaking COMMAND guest_np_cpp_web_api_matchmaking_tests)
    if(WIN32)
        set_tests_properties(guest_np_cpp_web_api_matchmaking
            PROPERTIES ENVIRONMENT_MODIFICATION "PATH=path_list_prepend:$<TARGET_FILE_DIR:libc>")
    endif()
endif()

if(MINGW)
    foreach(runtimeLinkFlag IN ITEMS -static-libgcc -static-libstdc++ -static)
        string(REPLACE "${runtimeLinkFlag}" "" CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS}")
    endforeach()
endif()

if(BUILD_TESTING)
    add_test_executable(guest_np_cpp_web_api_response_header_tests ${LIBS_INCLUDE_DIR}/tests/GuestNpCppWebApiResponseHeader.cpp)
    target_include_directories(guest_np_cpp_web_api_response_header_tests PRIVATE ${LIBS_INCLUDE_DIR})
    target_link_libraries(guest_np_cpp_web_api_response_header_tests PRIVATE libSceNpCppWebApi libc)
    configure_windows_unwind(guest_np_cpp_web_api_response_header_tests)
    add_test(NAME guest_np_cpp_web_api_response_header COMMAND guest_np_cpp_web_api_response_header_tests)
    if(WIN32)
        set_tests_properties(guest_np_cpp_web_api_response_header
            PROPERTIES ENVIRONMENT_MODIFICATION "PATH=path_list_prepend:$<TARGET_FILE_DIR:libc>")
    endif()
    add_test_executable(guest_np_cpp_web_api_string_tests ${LIBS_INCLUDE_DIR}/tests/GuestNpCppWebApiString.cpp)
    target_include_directories(guest_np_cpp_web_api_string_tests PRIVATE ${LIBS_INCLUDE_DIR})
    target_link_libraries(guest_np_cpp_web_api_string_tests PRIVATE libSceNpCppWebApi libc)
    configure_windows_unwind(guest_np_cpp_web_api_string_tests)
    add_test(NAME guest_np_cpp_web_api_string COMMAND guest_np_cpp_web_api_string_tests)
    add_test_executable(guest_np_cpp_web_api_title_cloud_storage_tests ${LIBS_INCLUDE_DIR}/tests/GuestNpCppWebApiTitleCloudStorage.cpp)
    target_include_directories(guest_np_cpp_web_api_title_cloud_storage_tests PRIVATE ${LIBS_INCLUDE_DIR})
    target_link_libraries(guest_np_cpp_web_api_title_cloud_storage_tests PRIVATE libSceNpCppWebApi libc)
    configure_windows_unwind(guest_np_cpp_web_api_title_cloud_storage_tests)
    add_test(NAME guest_np_cpp_web_api_title_cloud_storage COMMAND guest_np_cpp_web_api_title_cloud_storage_tests)
    if(WIN32)
        set_tests_properties(guest_np_cpp_web_api_title_cloud_storage
            PROPERTIES ENVIRONMENT_MODIFICATION "PATH=path_list_prepend:$<TARGET_FILE_DIR:libc>")
    endif()
    add_test(NAME guest_np_cpp_web_api_alias_append COMMAND guest_np_cpp_web_api_string_tests alias-append)
    add_test(NAME guest_np_cpp_web_api_alias_string_vector COMMAND guest_np_cpp_web_api_string_tests alias-vector)
    add_test(NAME guest_np_cpp_web_api_alias_intrusive_vector COMMAND guest_np_cpp_web_api_intrusive_ptr_tests alias-vector)
    set_tests_properties(guest_np_cpp_web_api_alias_append guest_np_cpp_web_api_alias_string_vector
        guest_np_cpp_web_api_alias_intrusive_vector PROPERTIES TIMEOUT 30)
    add_test_executable(guest_np_cpp_web_api_binary_tests ${LIBS_INCLUDE_DIR}/tests/GuestNpCppWebApiBinary.cpp)
    target_include_directories(guest_np_cpp_web_api_binary_tests PRIVATE ${LIBS_INCLUDE_DIR})
    target_link_libraries(guest_np_cpp_web_api_binary_tests PRIVATE libSceNpCppWebApi libc)
    configure_windows_unwind(guest_np_cpp_web_api_binary_tests)
    add_test(NAME guest_np_cpp_web_api_binary COMMAND guest_np_cpp_web_api_binary_tests)
    if(WIN32)
        set_tests_properties(guest_np_cpp_web_api_string guest_np_cpp_web_api_alias_append
            guest_np_cpp_web_api_alias_string_vector guest_np_cpp_web_api_alias_intrusive_vector
            guest_np_cpp_web_api_binary
            PROPERTIES ENVIRONMENT_MODIFICATION "PATH=path_list_prepend:$<TARGET_FILE_DIR:libc>")
    endif()
endif()

if(BUILD_TESTING)
    add_test_executable(guest_np_cpp_web_api_activities_tests ${LIBS_INCLUDE_DIR}/tests/GuestNpCppWebApiActivities.cpp)
    target_include_directories(guest_np_cpp_web_api_activities_tests PRIVATE ${LIBS_INCLUDE_DIR})
    target_link_libraries(guest_np_cpp_web_api_activities_tests PRIVATE libSceNpCppWebApi libc)
    configure_windows_unwind(guest_np_cpp_web_api_activities_tests)
    add_test(NAME guest_np_cpp_web_api_activities COMMAND guest_np_cpp_web_api_activities_tests)
    if(WIN32)
        set_tests_properties(guest_np_cpp_web_api_activities
            PROPERTIES ENVIRONMENT_MODIFICATION "PATH=path_list_prepend:$<TARGET_FILE_DIR:libc>")
    endif()
endif()

if(BUILD_TESTING)
    add_test_executable(guest_np_cpp_web_api_account_ids_tests ${LIBS_INCLUDE_DIR}/tests/GuestNpCppWebApiAccountIds.cpp)
    target_include_directories(guest_np_cpp_web_api_account_ids_tests PRIVATE ${LIBS_INCLUDE_DIR})
    target_link_libraries(guest_np_cpp_web_api_account_ids_tests PRIVATE libSceNpCppWebApi libc)
    configure_windows_unwind(guest_np_cpp_web_api_account_ids_tests)
    add_test(NAME guest_np_cpp_web_api_account_ids COMMAND guest_np_cpp_web_api_account_ids_tests)
    if(WIN32)
        set_tests_properties(guest_np_cpp_web_api_account_ids
            PROPERTIES ENVIRONMENT_MODIFICATION "PATH=path_list_prepend:$<TARGET_FILE_DIR:libc>")
    endif()
endif()

if(BUILD_TESTING)
    add_test_executable(guest_np_cpp_web_api_session_manager_tests ${LIBS_INCLUDE_DIR}/tests/GuestNpCppWebApiSessionManager2.cpp)
    target_include_directories(guest_np_cpp_web_api_session_manager_tests PRIVATE ${LIBS_INCLUDE_DIR})
    target_link_libraries(guest_np_cpp_web_api_session_manager_tests PRIVATE libSceNpCppWebApi libc)
    configure_windows_unwind(guest_np_cpp_web_api_session_manager_tests)
    add_test(NAME guest_np_cpp_web_api_session_manager COMMAND guest_np_cpp_web_api_session_manager_tests)
    if(WIN32)
        set_tests_properties(guest_np_cpp_web_api_session_manager
            PROPERTIES ENVIRONMENT_MODIFICATION "PATH=path_list_prepend:$<TARGET_FILE_DIR:libc>")
    endif()
endif()
