add_rules("mode.debug", "mode.release")

add_requires("libsdl 2.28.3", "zlib", "assimp", "nlohmann_json")

if is_plat("android") then 
    add_links("GLESv3")
else
    add_requires("glew")
end


-- Game files (with server)
target("Blitz")
    set_languages("c++17")
   
    if is_os("windows") then
        set_kind("static")
        add_links("ws2_32") -- link network stuff
    else
        set_kind("shared")
    end

    add_includedirs("include")
    add_files("src/blitz/**.cpp", "src/server/**.cpp")

    add_packages("zlib")





-- Server binary (headless)
target("BlitzServer")
    set_kind("binary")
    set_languages("c++17")
    set_default(false)

    add_includedirs("include")
    add_files("src/ServerMain.cpp")

    -- Libraries
    add_deps("Blitz")





-- Client binary (default)
target("BlitzClient")
    if is_plat("android") then
        set_kind("shared")
    else 
        set_kind("binary")
    end

    set_languages("c++17")
    set_default(true)

    add_includedirs("include")
    add_files("src/client/**.cpp", "src/ClientMain.cpp")

    -- Libraries
    add_deps("Blitz")
    add_packages("libsdl", "glew", "assimp", "nlohmann_json")

    add_includedirs("libs", "libs/imgui")
    add_files("libs/imgui/**.cpp")

    -- Assets
    set_rundir("$(projectdir)/assets")





-- Test Framework
target("BlitzTest")
    set_kind("static")
    set_languages("c++17")
    
    add_includedirs("include")
    add_files("test/Test.cpp")
    
    set_default(false)
    
    add_deps("Blitz")





 -- Tests
for _, file in ipairs(os.files("test/test_*.cpp")) do
    local name = path.basename(file)
    target(name)
        set_kind("binary")
        set_languages("c++17")
        add_includedirs("include")
        add_files("test/" .. name .. ".cpp")
        
        set_default(false)
        
        add_deps("BlitzTest")
        
        add_tests("compile_and_run")
end