require "ecc/ecc"
require "ninja/ninja"

workspace "2d-platformer"
	architecture "x64"
	
	configurations
	{
		"debug",
		"release"
	}

local outputdir = "%{cfg.buildcfg}-%{cfg.system}-%{cfg.architecture}"
local vs_intdir = "$(SolutionDir)intermediate-files/" .. outputdir
local intdir = "%{wks.location}/intermediate-files/" .. outputdir
local vs_bindir = "$(SolutionDir)bin/" .. outputdir 
local bindir = "%{wks.location}/bin/" .. outputdir
--local linuxlibdir = 
local vs_libreldir = "$(SolutionDir)vendor/SFML/lib/MinSizeRel"
local libreldir = "%{wks.location}/vendor/SFML/lib/MinSizeRel"
local vs_libdebugdir = "$(SolutionDir)vendor/SFML/lib/Debug"
local libdebugdir = "%{wks.location}/vendor/SFML/lib/Debug"
local vs_sfmldir = "$(SolutionDir)vendor/SFML"
local sfmldir = "%{wks.location}/vendor/SFML"
local vs_imguidir = "$(SolutionDir)vendor/imgui"
local imguidir = "%{wks.location}/vendor/imgui"
local vs_includedir = "$(SolutionDir)include"
local includedir = "%{wks.location}/include"

project "2d-platformer"
	language "C++"
	cppdialect "C++17"
	systemversion "latest"
	targetname "2d-platformer"

	files 
	{
		"src/**.cpp",
		"include/**.h",
		"include/**.hpp",
		"vendor/imgui/imgui.cpp",
		"vendor/imgui/imgui_draw.cpp",
		"vendor/imgui/imgui_tables.cpp",
		"vendor/imgui/imgui_widgets.cpp",
		"vendor/imgui/imgui-SFML.cpp"
	}


	--visual studio--
	filter {"action:vs*", "system:windows"}
		targetdir (vs_bindir)
		objdir (vs_intdir)
		includedirs 
		{
			vs_includedir, 
			vs_sfmldir .. "/include", 
			vs_imguidir
		}

	filter {"action:vs*", "system:windows", "configurations:debug"}
		libdirs {vs_libdebugdir}

	filter {"action:vs*", "system:windows", "configurations:release"}
		libdirs {vs_libreldir}


	--not visual studio on windows--
  filter {"not action:vs*", "system:windows"}
    targetdir (bindir)
    objdir (intdir)
    includedirs 
    {
      includedir, 
      imguidir 
    }
		
  filter {"not action:vs*", "system:windows", "configurations:debug"}
    libdirs {libdebugdir}

  filter {"not action:vs*", "system:windows", "configurations:release"}
    libdirs {libreldir}


	--windows specific settings--
	filter{"system:windows"}
	  defines "SFML_STATIC"
		defines "PLATFORM_WINDOWS"
		staticruntime "on"

	filter {"system:windows", "configurations:debug"}
		defines{"_DEBUG", "_CONSOLE"}
		links 
		{
			"sfml-graphics-s-d",
			"sfml-window-s-d",
			"opengl32",
			"gdi32",
			"freetyped",
			"sfml-audio-s-d",
			"flacd",
			"vorbisencd",
			"vorbisfiled",
			"vorbisd",
			"oggd",
			"sfml-network-s-d",
			"ws2_32",
			"sfml-system-s-d",
			"winmm"
		}
		
	filter {"system:windows", "configurations:release"}
		defines{"NDEBUG"}
		links 
		{
			"sfml-graphics-s",
			"sfml-window-s",
			"opengl32",
			"gdi32",
			"freetype",
			"sfml-audio-s",
			"flac",
			"vorbisenc",
			"vorbisfile",
			"vorbis",
			"ogg",
			"sfml-network-s",
			"ws2_32",
			"sfml-system-s",
			"winmm"
		}


  --linux specific settings
	filter {"system:linux"}
		targetdir (bindir)
		objdir (intdir)
		defines "PLATFORM_LINUX"
		includedirs 
		{
			includedir, 
			imguidir
		}		
		links 
		{
			"sfml-graphics",
			"sfml-window",
			"sfml-audio",
			"sfml-network",
			"sfml-system",
			"OpenGL",
		}

    
  --config settings
  filter "configurations:debug"
    defines"LOG_ENABLE"
		symbols "on"
		runtime "Debug"
		kind "ConsoleApp"

  filter "configurations:release"
		optimize "Speed"
		inlining "Auto"
		symbols "off"
		runtime "Release"
    kind "WindowedApp"
	  entrypoint "mainCRTStartup"
