# Qt4
FIND_PACKAGE(Qt4 REQUIRED)
IF(QT4_FOUND)
	INCLUDE_DIRECTORIES(${QT_INCLUDE_DIR})
	INCLUDE(${QT_USE_FILE})	
ELSE()
	MESSAGE(FATAL_ERROR "QT4 not found, but needed.")
ENDIF(QT4_FOUND)

# ITK
FIND_PACKAGE(ITK REQUIRED)
IF(ITK_FOUND)
	INCLUDE_DIRECTORIES(${ITK_INCLUDE_DIRS})
	INCLUDE(${ITK_USE_FILE})
ELSE()
	MESSAGE(FATAL_ERROR "ITK not found, but needed.")
ENDIF(ITK_FOUND)


# The headers, sources and Qt related stuff in the ritkCore module
#=================================================================
SET(HDRS
	ritkCore.h
	ritkAbstractFactory.h
	ritkManager.h
	ritkQTextEditIODevice.h
	ritkDebugManager.h
	ritkThreadedEventProcessor.h
	ritkThreadedWorker.h
	ritkThreadedJob.h
	ritkEvent.h
	ritkAcquisitionPipeline.h
	ritkFrameGrabber.h
	ritkPluginBase.h
	ritkApplicationPlugin.h
	ritkFilterPlugin.h
	ritkSourcePlugin.h 
	ritkImageTypePlugin.h
	ritkPluginManager.h
	ritkPluginManagerDialog.h
	ritkPluginFactories.h
	ritkMainWindow.h
	ritkRImageFilePlayer.h
	ritkRImageFilePlayerWidget.h
	ritkLogDialog.h
	ritkAboutDialog.h
	ritkHotkeysDialog.h
	ritkPluginCreator.h
	ritkPluginCreatorDialog.h
	ThirdParty/CustomSplashScreen.h
)

SET(SRCS
	ritkManager.cxx
	ritkDebugManager.cxx
	ritkQTextEditIODevice.cxx
	ritkThreadedEventProcessor.cxx
	ritkThreadedWorker.cxx
	ritkThreadedJob.cxx
	ritkEvent.cxx
	ritkAcquisitionPipeline.cxx
	ritkFrameGrabber.cxx
	ritkPluginBase.cxx
	ritkApplicationPlugin.cxx
	ritkFilterPlugin.cxx
	ritkImageTypePlugin.cxx
	ritkSourcePlugin.cxx  
	ritkPluginManager.cxx
	ritkPluginManagerDialog.cxx
	ritkMainWindow.cxx
	ritkRImageFilePlayer.cxx
	ritkRImageFilePlayerWidget.cxx
	ritkLogDialog.cxx
	ritkAboutDialog.cxx
	ritkHotkeysDialog.cxx
	ritkPluginCreator.cxx
	ritkPluginCreatorDialog.cxx
	ThirdParty/CustomSplashScreen.cxx
)

SET(MOC_HDRS 	
	ritkManager.h
	ritkDebugManager.h
	ritkQTextEditIODevice.h
	ritkThreadedWorker.h
	ritkThreadedJob.h
	ritkAcquisitionPipeline.h
	ritkFilterPlugin.h
	ritkSourcePlugin.h	
	ritkMainWindow.h	
	ritkRImageFilePlayer.h
	ritkRImageFilePlayerWidget.h
	ritkPluginManager.h
	ritkPluginManagerDialog.h
	ritkLogDialog.h
	ritkAboutDialog.h
	ritkHotkeysDialog.h
	ritkPluginCreator.h
	ritkPluginCreatorDialog.h
)

SET(UIS		
	ritkMainWindow.ui
	ritkRImageFilePlayerWidget.ui
	ritkLogDialog.ui
	ritkAboutDialog.ui
	ritkHotkeysDialog.ui
	ritkPluginManagerDialog.ui
	ritkPluginCreatorDialog.ui
)

SET(RCS
	ritkResources.qrc
)

QT4_WRAP_UI(UI_HDRS ${UIS})	
QT4_WRAP_CPP(MOC_SRCS ${MOC_HDRS})
QT4_ADD_RESOURCES(RC_SRCS ${RCS})


# Set the library name for the ritkCommon module
# ==============================================
SET(CORE_LIBRARY ritkCore CACHE INTERNAL "")
SET(LIBRARY_OUTPUT_PATH "${CMAKE_BINARY_DIR}")
SET(CMAKE_INSTALL_RPATH_USE_LINK_PATH TRUE)


# Project settings
# ================
SET(CORE_INCLUDE_DIRS
	${COMMON_INCLUDE_DIRS}
	${TOOLS_INCLUDE_DIRS}
	${CMAKE_CURRENT_SOURCE_DIR}
	${CMAKE_CURRENT_BINARY_DIR}
	CACHE INTERNAL ""
)
INCLUDE_DIRECTORIES(${CORE_INCLUDE_DIRS})
ADD_DEFINITIONS("/DCORE_SHAREDLIB_EXPORT")
ADD_LIBRARY(${CORE_LIBRARY} SHARED ${SRCS} ${HDRS} ${MOC_SRCS} ${UI_HDRS} ${RC_SRCS})

IF(UNIX)
	TARGET_LINK_LIBRARIES(${CORE_LIBRARY} 
		${COMMON_LIBRARY}
		${QT_LIBRARIES}
		${QT_QTXML_LIBRARY} 
		${TOOLS_LIBRARY}
		GLU
		glut
	)
ENDIF(UNIX)

IF(WIN32)
	TARGET_LINK_LIBRARIES(${CORE_LIBRARY} 
		${COMMON_LIBRARY}
		${QT_LIBRARIES}
		${TOOLS_LIBRARY}
		${QT_QTXML_LIBRARY} 
		${QT_QTOPENGL_LIBRARY}
		GLU32
	)
ENDIF(WIN32)

SET_TARGET_PROPERTIES(${CORE_LIBRARY} PROPERTIES DEBUG_POSTFIX "d")


# Module installation
# ====================
INSTALL(FILES ${HDRS} DESTINATION dev/include/Core)
INSTALL(FILES ${UI_HDRS} DESTINATION dev/include/Core/ui)
INSTALL(TARGETS ${CORE_LIBRARY} CONFIGURATIONS Debug
	RUNTIME DESTINATION bin/debug
	LIBRARY DESTINATION dev/lib/debug
	ARCHIVE DESTINATION dev/lib/debug
)
INSTALL(TARGETS ${CORE_LIBRARY} CONFIGURATIONS Release
	RUNTIME DESTINATION bin/release
	LIBRARY DESTINATION dev/lib/release
	ARCHIVE DESTINATION dev/lib/release
)
