# Set modules path
set(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} ${CMAKE_CURRENT_LIST_DIR}/Modules)

#find_package(Mono)

if(OE_EDITOR_INTERNAL)
	set(OE_EDITOR 1)
endif()

# OS
if(WIN32)
    set(OE_WINDOWS 1)
    set(OE_OPENGL 1)
    set(OE_D3D 1)
    set(OE_VULKAN 1)
elseif(UNIX)
    set(OE_UNIX 1)
	set(OE_OPENGL_ES 1)
	if(ANDROID)
		set(OE_ANDROID 1)
		# API >= 24
		set(OE_VULKAN 1)
	elseif(EMSCRIPTEN)
		set(OE_EMSCRIPTEN 1)
	else() # Linux
		set(OE_LINUX 1)	
		set(OE_OPENGL 1)
    	set(OE_VULKAN 1)
	endif()
else()
    message(FATAL_ERROR "Unsupported system")
endif()

# This is experimental.
set(OE_VULKAN 0)

# Checks
if(OE_OPENGL)
    find_package(OpenGL)
    if(NOT OPENGL_FOUND)
    	message(STATUS "OpenGL not found, disabling")
    	set(OE_OPENGL 0)
    endif()
endif()
if(OE_OPENGL_ES)
	# Emscripten provides it's own libraries
	if(NOT OE_EMSCRIPTEN)
		find_package(EGL)
		find_package(GLES)
	    if(NOT EGL_FOUND OR NOT GLES_FOUND)
	    	message(STATUS "EGL or GLES not found, disabling OpenGLES")
	    	set(OE_OPENGL_ES 0)
	    endif()
	endif()
endif()
if(OE_D3D)
	find_package(DirectX)
    if(NOT DirectX_FOUND)
    	message(STATUS "Direct3D not found, disabling")
    	set(OE_D3D 0)
    endif()
endif()
if(OE_VULKAN)
	find_package(Vulkan)
    if(NOT Vulkan_FOUND)
		message(STATUS "Vulkan not found, disabling")
		set(OE_VULKAN 0)
    endif()
endif()