cmake_minimum_required(VERSION 3.13)
cmake_policy(SET CMP0011 NEW) # don`t affect includer policies
cmake_policy(SET CMP0017 NEW) # need include() with .cmake
cmake_policy(SET CMP0020 NEW) # Automatically link Qt executables to qtmain target on Windows
if (POLICY CMP0053)
	cmake_policy(SET CMP0053 NEW) # simpler variable expansion and escape sequence evaluation rules
endif()
if (POLICY CMP0177)
	cmake_policy(SET CMP0177 OLD)
endif()
project(shstk)
set(CMAKE_MODULE_PATH
	"${CMAKE_CURRENT_SOURCE_DIR}"
	"${CMAKE_CURRENT_SOURCE_DIR}/cmake"
	"${CMAKE_CURRENT_SOURCE_DIR}/pip/cmake"
	"${CMAKE_CURRENT_SOURCE_DIR}/qad/cmake"
	"${CMAKE_CURRENT_SOURCE_DIR}/qglengine/cmake"
	"${CMAKE_CURRENT_SOURCE_DIR}/cd_utils/cmake"
	)
set(ROOT_DIR "${CMAKE_CURRENT_SOURCE_DIR}")
set(SHSTKPROJECT 1)

include(QtWraps)
include(SHSTKMacros)

shstk_begin_project("" "")

option(CROSSTOOLS "Crosstools minimal build" OFF)
option(QGLVIEW "Build QGLView library and utils" ON)
option(QGLENGINE "Build QGLEngine library and utils" ON)
option(UTILS "Build various utils" ${_plugins_default_})
option(DESIGNER_PLUGINS "Build Qt designer plugins" ${_plugins_default_})
if (CROSSTOOLS)
	set(LOCAL 0)
	set(QGLVIEW 0)
	set(QGLENGINE 0)
	set(UTILS 0)
	set(DESIGNER_PLUGINS 0)
endif()
set(CMAKE_CXX_STANDARD 11)

add_subdirectory(cmake)

add_subdirectory(pip)
find_package(PIP REQUIRED)

if (NOT CROSSTOOLS)

	qad_find_qt(Core QUIET)
	if (SOME_QT_FOUND)

		add_subdirectory(qad)
		find_package(QAD REQUIRED)
		
		if (QGLENGINE)
			add_subdirectory(qglengine)
		endif()

	endif()
	
	add_subdirectory(cd)

endif()

if(WIN32 AND SOME_QT_FOUND)
	foreach(_l ${PIP_MODULES} ${CD_MODULES})
		qad_install(TARGETS ${_l} RUNTIME DESTINATION QtBin)
	endforeach()
endif()
