PROJECT(PresentaBALL)

IF(NOT BALL_HAS_VIEW)
	MESSAGE(STATUS "BALL is configured to not build the VIEW components. Disabling the PresentaBALL plugin.")
	RETURN()
ENDIF()

IF(NOT BALL_HAS_QTWEBENGINE)
	MESSAGE(STATUS "QtWebEngine support has not been enabled. Disabling the PresentaBALL plugin.")
	RETURN()
ENDIF()

SET(DIRECTORY source)
### list all filenames of the directory here ###
SET(UI_SOURCES_LIST
	${DIRECTORY}/PresentaBALLSettings.ui
)

SET(SOURCES_LIST
	${DIRECTORY}/PresentaBALLPlugin.C
	${DIRECTORY}/PresentaBALLSettings.C
	${DIRECTORY}/PresentaBALLView.C
)

SET(RCC_SOURCES_LIST
	${DIRECTORY}/logo.qrc
)

SET(DIRECTORY include)
### the list of all files requiring a moc run ###
SET(MOC_SOURCES_LIST
	${DIRECTORY}/PresentaBALLPlugin.h
	${DIRECTORY}/PresentaBALLSettings.h
	${DIRECTORY}/PresentaBALLView.h
)

QT5_WRAP_CPP(MOC_OUTFILES ${MOC_SOURCES_LIST})
QT5_ADD_RESOURCES(RCC_OUTFILES ${RCC_SOURCES_LIST})
QT5_WRAP_UI(UIC_OUTFILES ${UI_SOURCES_LIST})

INCLUDE_DIRECTORIES(${PROJECT_SOURCE_DIR}/include)
INCLUDE_DIRECTORIES(${PROJECT_BINARY_DIR})

ADD_DEFINITIONS(${QT_DEFINITIONS})
ADD_DEFINITIONS(-DQT_PLUGIN)
ADD_DEFINITIONS(-DQT_NO_DEBUG)
ADD_DEFINITIONS(-DQT_SHARED)

ADD_LIBRARY(pluginPresentaBALL SHARED
	${SOURCES_LIST}
	${MOC_OUTFILES}
	${RCC_OUTFILES}
	${UIC_OUTFILES}
)

SET_TARGET_PROPERTIES(pluginPresentaBALL PROPERTIES
	PREFIX ""
)

IF(NOT APPLE)
	INSTALL(TARGETS pluginPresentaBALL
		COMPONENT "${COMPONENT_PLUGINS}"
		RUNTIME DESTINATION "${BALL_PLUGIN_INSTALL_DIRECTORY}"
		LIBRARY DESTINATION "${BALL_PLUGIN_INSTALL_DIRECTORY}"
	)

	IF(WIN32)
		IF(QT_DEPLOY_EXECUTABLE)
			INSTALL(CODE "EXECUTE_PROCESS(COMMAND ${QT_DEPLOY_EXECUTABLE} \$\{CMAKE_INSTALL_PREFIX\}/${CMAKE_INSTALL_BINDIR}/pluginPresentaBALL.dll)"
				COMPONENT "Unspecified")
		ENDIF()
	ENDIF()
ENDIF()

TARGET_LINK_LIBRARIES(pluginPresentaBALL BALL VIEW Qt5::WebEngineWidgets Qt5::WebChannel)
