includes("Blitz.lua")

-- This should be temporary
opengl = "glbinding"
if is_plat("linux") and is_arch("arm64-v8a") then
    opengl = "glew"
    add_defines("BLITZ_GL_LOADER_GLEW")
end

add_requires("libsdl 2.28.3", {configs = {sdlmain = false}})
add_requires(opengl, "assimp 5.3.1", "nlohmann_json", "openal-soft")


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

    set_default(true)

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

    -- Libraries
    add_deps("Blitz")
    add_packages("libsdl", opengl, "assimp", "nlohmann_json", "openal-soft")

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

    if is_plat("macosx") then
        add_frameworks("OpenGL")
    elseif is_plat("windows") then
	    add_ldflags("/LTCG") -- fix compiltation of glbinding
    end

    -- Assets
    set_rundir("../assets")

    -- Valgrind test
    if is_mode("valgrind") then
        on_run(function (target)
            os.cd("assets")
            os.execv("valgrind", {"-s", "--leak-check=full", target:targetfile()})
        end)
    end
