# CMake script for PAPPSOms++ library
# Author: Olivier Langella
# Created: 22/12/2017
# Rework: April 2020 (Coronavirus confinement)

message(\n${BoldRed}"Now configuring src/widget for ${PROJECT_NAME}"${ColourReset}\n)


find_package(Qt5 COMPONENTS Core Gui PrintSupport Svg REQUIRED)


if(NOT QCustomPlot_FOUND)
	message("Still searching for QCustomPlot")
	find_package(QCustomPlot REQUIRED)
	add_definitions(-DQCUSTOMPLOT_USE_LIBRARY)
endif()


########################################################
# Files
SET(PAPPSOWIDGET_CPP_FILES
	graphicdevicewidget.cpp
	precisionwidget/precisionwidget.cpp
	massspectrumwidget/qcpspectrum.cpp
	massspectrumwidget/massspectrumwidget.cpp
	xicwidget/qcpxic.cpp
	xicwidget/xicwidget.cpp
	plotwidget/colormapplotconfig.cpp
	plotwidget/baseplotwidget.cpp
	plotwidget/basetraceplotwidget.cpp
	plotwidget/ticxicchromtraceplotwidget.cpp
	plotwidget/massspectraceplotwidget.cpp
	plotwidget/driftspectraceplotwidget.cpp
	plotwidget/basecolormapplotwidget.cpp
	plotwidget/ticxicchrommassspeccolormapplotwidget.cpp
	plotwidget/ticxicchromdriftspeccolormapplotwidget.cpp
	plotwidget/driftspecmassspeccolormapplotwidget.cpp
	)


#############################################################
# Build the static lib
add_library(pappsomspp-widget-static STATIC ${PAPPSOWIDGET_CPP_FILES})

set_target_properties(pappsomspp-widget-static
	PROPERTIES OUTPUT_NAME pappsomspp-widget
	CLEAN_DIRECT_OUTPUT 1
	)

target_link_libraries(pappsomspp-widget-static
	QCustomPlot::QCustomPlot
	Qt5::Core
	Qt5::Widgets
	Qt5::Svg
	Qt5::PrintSupport
	Boost::iostreams
	Boost::filesystem
	Boost::thread
	Boost::chrono
	PwizLite::PwizLite
	)


# FIXME: should check that this still required. It was years ago.
if(WIN32 OR _WIN32)

	target_link_libraries(pappsomspp-widget-static 
		stdc++
		)
endif()


#############################################################
# Build the shared lib
add_library(pappsomspp-widget-shared SHARED ${PAPPSOWIDGET_CPP_FILES})

set_target_properties(pappsomspp-widget-shared
	PROPERTIES OUTPUT_NAME pappsomspp-widget
	CLEAN_DIRECT_OUTPUT 1
	VERSION ${PAPPSOMSPP_VERSION}
	SOVERSION ${PAPPSOMSPP_VERSION_MAJOR}
	#COMPILE_DEFINITIONS " ${QT_DEFINITIONS}"
	#INCLUDE_DIRECTORIES "${QT_INCLUDE_DIR} ${QT_QTCORE_INCLUDE_DIR}"
	)

target_link_libraries(pappsomspp-widget-shared
	QCustomPlot::QCustomPlot
	Qt5::Core
	Qt5::Widgets
	Qt5::Svg
	Qt5::PrintSupport
	pappsomspp-shared
	Boost::iostreams
	Boost::filesystem
	Boost::thread
	Boost::chrono
	PwizLite::PwizLite
	)


# Should check that this still required. It was years ago.
if(WIN32 OR _WIN32)

	target_link_libraries(pappsomspp-widget-shared 
		stdc++
		)

endif()


# Install libs

install(TARGETS pappsomspp-widget-shared 
	LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR}
	# This one is for WIN32
	RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR}
	)

install(TARGETS pappsomspp-widget-static 
	ARCHIVE DESTINATION ${CMAKE_INSTALL_LIBDIR})


# Install headers
install(DIRECTORY pappsomspp/widget 
	DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}/pappsomspp/widget
	FILES_MATCHING PATTERN "*.h"
	PATTERN "*.hpp")
