project(qcd_utils)
cmake_minimum_required(VERSION 2.6)
cmake_policy(SET CMP0017 OLD)
if (NOT LIBPROJECT)
	find_package(PIP REQUIRED)
	option(LIB "System install" 0)
	option(DEBUG "Build with -g3" 0)
	set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -O3 -Wall")
	if (DEBUG)
		set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -g3")
	endif()
endif()
find_package(QAD REQUIRED)
list(APPEND QT_MULTILIB_LIST ${PROJECT_NAME})
set(QT_MULTILIB_LIST ${QT_MULTILIB_LIST} PARENT_SCOPE)
include_directories(${PIP_INCLUDES} ${QAD_INCLUDES})
file(GLOB SRC "*.h" "*.cpp" "*.ui" "*.qrc" "lang/*.ts")
find_qt(${QtVersions} Core Gui)
qt_wrap(${SRC} HDRS out_HDR CPPS out_CPP QMS out_QM)
qt_add_library(${PROJECT_NAME} SHARED out_CPP)
qt_target_link_libraries(${PROJECT_NAME} pip qad_utils qad_widgets cd_utils piqt)
message(STATUS "Building ${PROJECT_NAME}")
if(LIBPROJECT)
	sdk_install("" "${PROJECT_NAME}" "${out_HDR}")
else()
	if(LIB)
		if(WIN32)
			set(CMAKE_INSTALL_PREFIX ${MINGW_DIR})
			install(FILES ${out_HDR} DESTINATION ${MINGW_INCLUDE})
			qt_install(TARGETS ${PROJECT_NAME} DESTINATION ${MINGW_LIB})
			qt_install(TARGETS ${PROJECT_NAME} DESTINATION ${MINGW_BIN})
			qt_install(TARGETS ${PROJECT_NAME} DESTINATION QtBin)
		else()
			if(APPLE)
				set(CMAKE_INSTALL_PREFIX /usr/local)
			else()
				set(CMAKE_INSTALL_PREFIX /usr)
			endif()
			install(FILES ${out_HDR} DESTINATION ${CMAKE_INSTALL_PREFIX}/include)
			qt_install(TARGETS ${PROJECT_NAME} DESTINATION ${CMAKE_INSTALL_PREFIX}/lib)
		endif()
		message(STATUS "Install ${PROJECT_NAME} to system \"${CMAKE_INSTALL_PREFIX}\"")
	else()
		qt_install(TARGETS ${PROJECT_NAME} DESTINATION bin)
		message(STATUS "Install ${PROJECT_NAME} to local \"bin\"")
	endif()
endif()

add_subdirectory(pult)

