set(src "src/common.c" "src/serial.c")
set(priv_deps transport)
set(privinc "privinc")

if(PS1_BUILD)
    set(src ${src}
        "ps1/src/net.c"
    )
else()
    set(src ${src}
        "src/net.c"
        "src/enet/ipv4.c"
    )

    if(WIN9X_BUILD OR ${CMAKE_HOST_SYSTEM_NAME} STREQUAL "Windows")
        set(src ${src} "win9x/src/serial.c")
    elseif(ESP32_BUILD)
        include($ENV{IDF_PATH}/tools/cmake/idf.cmake)
        set(priv_deps ${priv_deps} idf::lwip idf::esp_phy)
    else()
        # Assume POSIX if the command below executes successfully
        execute_process(COMMAND uname -m RESULT_VARIABLE result OUTPUT_QUIET)

        if(result)
            message(FATAL_ERROR "Unknown operating system")
        else()
            set(src ${src} "posix/src/serial.c")
        endif()
    endif()

    set(priv_deps ${priv_deps} util ENET)
endif()

add_library(net ${src})
target_include_directories(net PUBLIC "inc" PRIVATE ${privinc})
target_link_libraries(net PRIVATE ${priv_deps})
