cmake_minimum_required(VERSION 2.8)

option (BUILD_GL_3_0_RENDERER "Build a faster OpenGL 3.0 renderer backend" ON)
option (BUILD_GL_2_0_RENDERER "Build an OpenGL 2.0 renderer backend" ON)

set (RENDERERS "")
set (RENDERER_SOURCES "")
set (RENDERER_LIBRARIES "")
set (RENDERER_INCLUDE_DIRS "")

if(BUILD_GL_3_0_RENDERER)
		find_package(OpenGL)
		if (NOT OPENGL_FOUND)
				message(WARNING "OpenGL not found for GL_3_0 renderer")
		else()
			if (NOT RENDERERS)
				set(RENDERERS "GL_3_0")
			else()
				set(RENDERERS "${RENDERERS}:GL_3_0")
			endif()
			AUX_SOURCE_DIRECTORY(framework/render/gl30 RENDERER_SOURCES)
			list(APPEND RENDERER_LIBRARIES ${OPENGL_gl_LIBRARY})
			list(APPEND RENDERER_INCLUDE_DIRS ${OPENGL_INCLUDE_DIR})
		endif()
endif()

if(BUILD_GL_2_0_RENDERER)
		find_package(OpenGL)
		if (NOT OPENGL_FOUND)
				message(WARNING "OpenGL not found for GL_2_0 renderer")
		else()
			if (NOT RENDERERS)
				set(RENDERERS "GL_2_0")
			else()
				set(RENDERERS "${RENDERERS}:GL_2_0")
			endif()
			AUX_SOURCE_DIRECTORY(framework/render/gl20 RENDERER_SOURCES)
			list(APPEND RENDERER_LIBRARIES ${OPENGL_gl_LIBRARY})
			list(APPEND RENDERER_INCLUDE_DIRS ${OPENGL_INCLUDE_DIR})
		endif()
endif()

message("Building renderers: ${RENDERERS}")
add_definitions("-DRENDERERS=\"${RENDERERS}\"")
