cmake_minimum_required(VERSION 3.0)
cmake_policy(SET CMP0072 NEW) #  FindOpenGL prefers GLVND by default
if (POLICY CMP0057)
	cmake_policy(SET CMP0057 NEW)
endif()
if (POLICY CMP0054)
	cmake_policy(SET CMP0054 NEW)
endif()
project(QGLEngine)
if (NOT DEFINED SHSTKPROJECT)
	include(SHSTKQtMacros)
endif()
find_package(PIP REQUIRED)
find_package(QAD REQUIRED)
shstk_qt_founded(QtVersions)
set(_qgl_ok 0)
if ("Qt5" IN_LIST QtVersions)
	set(_qgl_ok 1)
endif()
if ("Qt6" IN_LIST QtVersions)
	set(_qgl_ok 1)
endif()
if (NOT _qgl_ok)
	message(WARNING "Building ${PROJECT_NAME} available only on Qt5/6!")
else()
	include(SHSTKQtMacros)
	
	set(QGLEngine_MAJOR    1)
	set(QGLEngine_MINOR    0)
	set(QGLEngine_REVISION 0)
	set(QGLEngine_SUFFIX   "rc")
	set(QGLEngine_COMPANY  SHS)
	set(QGLEngine_DOMAIN   org.SHS)

	if ("x${CMAKE_MODULE_PATH}" STREQUAL "x")
		set(CMAKE_MODULE_PATH "${CMAKE_CURRENT_SOURCE_DIR}/cmake")
	endif()

	shstk_begin_project(QGLEngine)
	set(_qglengine_root_build "${CMAKE_CURRENT_BINARY_DIR}")

	add_subdirectory(src)
	shstk_copy_to_parent()

        shstk_install(qglengine FALSE "" "${QGLEngine_VERSION_FILE}")
	file(GLOB CMAKES "cmake/*.cmake" "cmake/*.in")
	install(FILES ${CMAKES} DESTINATION ${CMAKE_ROOT}/Modules)
	
endif()
