
find_package( Qt5 COMPONENTS Core Gui Xml Widgets PrintSupport REQUIRED )

# add some useful macros and variables
# (QT_USE_FILE is a variable defined by FIND_PACKAGE( Qt4 ) that contains a path to CMake script)
#INCLUDE( ${QT_USE_FILE} )

# with SET() command you can change variables or define new ones
# here we define SAMPLE_SRCS variable that contains a list of all .cpp files
# note that we don't need \ at the end of line
set( QTBEADS_SRCS
	qtbeads.cpp
	main_window.cpp
	properties.cpp
	beads_results.cpp
	QCimg.cpp
	q_gel_image.cpp
	q_gel_image_scroll.cpp
	#	qtbeads_error.h
	)

# another list, this time it includes all header files that should be treated with moc
set( QTBEADS_MOC_HDRS
	main_window.h
	q_gel_image.h
	)  
# some .ui files
#SET( SAMPLE_UIS
#     ./src/ui/Dialog1.ui
#     ./src/ui/Dialog2.ui
#)

# and finally an resource file
#SET( SAMPLE_RCS
#     ./src/rc/sample.qrc
#)

# enable warnings
#ADD_DEFINITIONS( -Wall )

# by default only QtCore and QtGui modules are enabled
# other modules must be enabled like this:
#SET( QT_USE_QT3SUPPORT TRUE )   
# SET( QT_USE_QTXML TRUE )




# this command will generate rules that will run rcc on all files from SAMPLE_RCS
# in result SAMPLE_RC_SRCS variable will contain paths to files produced by rcc
qt5_add_resources( QTBEADS_SRCS ${SAMPLE_RCS} )

# this will run uic on .ui files:
#QT4_WRAP_UI( SAMPLE_UI_HDRS ${SAMPLE_UIS} )

# and finally this will run moc:
qt5_wrap_cpp( QTBEADS_MOC_SRCS ${QTBEADS_MOC_HDRS} )

# we need this to be able to include headers produced by uic in our code
# (CMAKE_BINARY_DIR holds a path to the build directory, while INCLUDE_DIRECTORIES() works just like INCLUDEPATH from qmake)
#INCLUDE_DIRECTORIES( ${CMAKE_BINARY_DIR} ${Qwt5_INCLUDE_DIR})



# here we instruct CMake to build "sample" executable from all of the source files
add_executable( qtbeads ${QTBEADS_SRCS} ${QTBEADS_MOC_SRCS} ${SAMPLE_RC_SRCS} ${SAMPLE_UI_HDRS} ${QM} )

target_include_directories(qtbeads PUBLIC ${CMAKE_BINARY_DIR}
	${OdsStream_INCLUDE_DIRS} 
	${CImg_INCLUDE_DIRS})


if(WIN32)
	set_target_properties(qtbeads
		PROPERTIES 
		LINK_FLAGS "-Wl,--subsystem,windows ${ADD_MINGW_EXE_LINKER_FLAGS}"
		CLEAN_DIRECT_OUTPUT 1
		CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${CImg_CFLAGS} ${QT_QTCORE_EXECUTABLE_COMPILE_FLAGS}"
		)
else(WIN32)
	set_target_properties(qtbeads
		PROPERTIES
		CLEAN_DIRECT_OUTPUT 1
		CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${CImg_CFLAGS}"
		)
endif(WIN32)

target_link_libraries(qtbeads cppbeads OdsStream::Core ${CImg_SYSTEM_LIBS} Qt5::Core Qt5::Gui Qt5::Xml Qt5::Widgets Qt5::PrintSupport)


