find_package( Qt6 COMPONENTS Core Gui Xml REQUIRED )
find_package(QuaZip-Qt6 REQUIRED)

list( APPEND CMAKE_MODULE_PATH
	${PROJECT_SOURCE_DIR}/cmake_modules
	)

set(CImg_INCLUDE_DIR "${CMAKE_SOURCE_DIR}/src/cimg")

if(DEBIAN_PACKAGE)
	#  CImg_FOUND - system has CImg lib
	set(CImg_FOUND 1)
	#  CImg_INCLUDE_DIRS - the CImg include directory
	set(CImg_INCLUDE_DIR "/usr/include")
	#  CImg_SYSTEM_LIBS - external libraries that CImg uses
	set(CImg_SYSTEM_LIBS "/usr/lib${LIB_SUFFIX}/libz.so"
		"/usr/lib${LIB_SUFFIX}/libpng16.so"
		"/usr/lib${LIB_SUFFIX}/libjpeg.so"
		"/usr/lib${LIB_SUFFIX}/libtiff.so")
	#  CImg_SYSTEM_LIBS_DIR - external library directories
	set(CImg_SYSTEM_LIBS_DIR "")
	#  CImg_CFLAGS - compilation flags
	set(CImg_CFLAGS "pthread" "-Dcimg_use_png" "-Dcimg_use_jpeg" "-Dcimg_use_tiff" "-Dcimg_use_zlib")

else(DEBIAN_PACKAGE)
	find_package( CImg REQUIRED )
endif(DEBIAN_PACKAGE)

# Add CIMG Flags to Compilation Flags
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${CIMG_CFLAGS}")

#include_directories(${OdsStream_INCLUDE_DIRS})

if(MINGW32)
	include_directories( ${QUAZIP_INCLUDE_DIR} )
else(MINGW32)
	find_package( OdsStream REQUIRED )
endif(MINGW32)



set( BEADS_FOR_QT_CPP
	ConfigFile/ConfigFile.cpp
	parameters.cpp
	encode/base64.cpp
	images/imageIntensity.cpp
	images/imageDirect.cpp
	images/imageCode.h
	images/imageCoule.cpp
	images/imagePaths.cpp
	images/imageConfluent.cpp
	images/imageProb.cpp
	images/parameterProb.cpp
	parameterDetection.cpp
	images/parameterConfluent.cpp
	detection.cpp
	images/imageDetection.cpp
	images/imageNumber.cpp
	images/parameterNumber.cpp
	images/imageContours.cpp
	spotPROTICdbDocument.cpp
	spot.cpp
	spotDocument.cpp
	spotSvgDocument.cpp
	images/imageDeNovo.cpp
	)

if(WIN32)
else(WIN32)
	#FIND_PACKAGE(X11 REQUIRED)

	#INCLUDE_DIRECTORIES(X11_INCLUDE_DIR)
	# X11_FOUND is true if X11 is available.
	#    * X11_INCLUDE_DIR contains the include directories to use X11.
	#    * X11_LIBRARIES points to the libraries to link against to use X11.
	# Make sure the compiler can find include files from our Hello library.
	#include_directories(${X11_INCLUDE_DIR})

	#ADD_DEFINITIONS(${PTHREADS_DEFINITIONS})
	# -m -pthread FindThreads

	# Make sure the linker can find the Hello library once it is built.
	#link_directories(${X11_INCLUDE_DIR})
endif(WIN32)


add_executable(beads beads.cpp )
target_include_directories(beads PUBLIC $${CImg_INCLUDE_DIRS} ${CImg_SYSTEM_LIBS_DIR})
set_target_properties(beads
	PROPERTIES OUTPUT_NAME beads
	CLEAN_DIRECT_OUTPUT 1
	CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${CImg_CFLAGS}"
	)

target_link_libraries(beads cppbeads
	${CImg_SYSTEM_LIBS}
	${CImg_CFLAGS}
	Qt6::Core
	Qt6::Gui
	Qt6::Xml
	OdsStream::Core
	)


add_library(cppbeads STATIC
	${BEADS_FOR_QT_CPP}
	)

target_include_directories(cppbeads PUBLIC ${OdsStream_INCLUDE_DIRS}
	${CImg_INCLUDE_DIRS} ${CImg_SYSTEM_LIBS_DIR})
set_target_properties(cppbeads
	PROPERTIES OUTPUT_NAME cppbeads-qt6
	CLEAN_DIRECT_OUTPUT 1
	CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${CImg_CFLAGS}"
	)

target_link_libraries(cppbeads
	${CImg_SYSTEM_LIBS}
	${CImg_CFLAGS}
	Qt6::Core
	Qt6::Gui
	Qt6::Xml
	OdsStream::Core
	)


subdirs(qtbeads)
