# 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)

# OpenGL
#FIND_PACKAGE(OpenGL REQUIRED)
#if (OpenGL_FOUND)
#	INCLUDE_DIRECTORIES(${OPENGL_INCLUDE_DIR})
#	INCLUDE(${OpenGL_USE_FILE})
#else()
#	MESSAGE("OpenGL not found but needed.")
#endif(OpenGL_FOUND)


# The headers, sources and Qt related stuff in the ritkVisualization module
#==========================================================================
SET(HDRS  
	ritkVisualization.h
	ritkOpenGLExtensions.h
	ritkLUTs.h
	ritkShaders.h
	ritkOpenGLEntity.h
	ritkOpenGLCamera.h
	ritkOpenGLRImageEntity.h
	ritkOpenGLVolumeRayCastEntity.h
	ritkOpenGLFloatVolumeRayCastControlUnit.h
	ritkOpenGLPointPickerEntity.h
	ritkOpenGLPointPickerPolygonEntity.h
	ritkOpenGLPointPickerLinearEntity.h
	ritkOpenGLVisualizationWidget.h
	ritkOpenGLRImageControlUnit.h
	ritkOpenGLCameraControlUnit.h
	ritkOpenGLPointPickerLinearControlUnit.h
	ritkImagePayloadVisualizationConfig.h
	ritkVisualizationUnit.h
	ritkRayCasterBase.h
	ritkGraphicsInteropImportImageContainer.h
	ThirdParty/GLee.h
	ThirdParty/inpoly.h
)

SET(TMPS
	ritkRayCasterBase.txx
	ritkGraphicsInteropImportImageContainer.txx
)

SET(SRCS 
	${TMPS}
	ritkLUTs.cxx
	ritkOpenGLEntity.cxx
	ritkOpenGLCamera.cxx
	ritkOpenGLRImageEntity.cxx
	ritkOpenGLVolumeRayCastEntity.txx
	ritkOpenGLFloatVolumeRayCastControlUnit.cxx
	ritkOpenGLVolumeRayCastEntityInstantiations.cxx
	ritkOpenGLPointPickerEntity.cxx
	ritkOpenGLPointPickerPolygonEntity.cxx
	ritkOpenGLPointPickerLinearEntity.cxx
	ritkOpenGLVisualizationWidget.cxx
	ritkOpenGLRImageControlUnit.cxx
	ritkOpenGLCameraControlUnit.cxx
	ritkOpenGLPointPickerLinearControlUnit.cxx
	ritkImagePayloadVisualizationConfig.cxx
	ritkVisualizationUnit.cxx	
	ritkGraphicsInteropImportImageContainerInstantiations.cxx
	ThirdParty/GLee.c
	ThirdParty/inpoly.cxx
)

SET(MOC_HDRS 
	ritkOpenGLEntity.h
	ritkOpenGLVisualizationWidget.h
	ritkOpenGLRImageControlUnit.h
	ritkOpenGLRImageEntity.h
	ritkOpenGLFloatVolumeRayCastControlUnit.h
	ritkOpenGLPointPickerEntity.h
	ritkOpenGLPointPickerLinearEntity.h
	ritkOpenGLPointPickerPolygonEntity.h
	ritkOpenGLCamera.h
	ritkOpenGLCameraControlUnit.h
	ritkOpenGLPointPickerLinearControlUnit.h
	ritkVisualizationUnit.h
)

SET(UIS	
	ritkOpenGLRImageControlUnit.ui
	ritkOpenGLCameraControlUnit.ui
	ritkOpenGLPointPickerLinearControlUnit.ui
	ritkOpenGLFloatVolumeRayCastControlUnit.ui
)

QT4_WRAP_UI(UI_HDRS ${UIS})	
QT4_WRAP_CPP(MOC_SRCS ${MOC_HDRS})


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


# Project settings
# ================
SET(VISUALIZATION_INCLUDE_DIRS
	${COMMON_INCLUDE_DIRS}
	${CORE_INCLUDE_DIRS}
	${CMAKE_CURRENT_SOURCE_DIR}
	${CMAKE_CURRENT_BINARY_DIR}	
	${QT_QTOPENGL_INCLUDE_DIR}
	${TOOLS_INCLUDE_DIRS}
	CACHE INTERNAL ""
)

INCLUDE_DIRECTORIES(${VISUALIZATION_INCLUDE_DIRS})
ADD_DEFINITIONS("/DVISUALIZATION_SHAREDLIB_EXPORT")
ADD_LIBRARY(${VISUALIZATION_LIBRARY} SHARED ${SRCS} ${HDRS} ${MOC_SRCS} ${UI_HDRS})

IF(UNIX)
	TARGET_LINK_LIBRARIES(${VISUALIZATION_LIBRARY} 
		${COMMON_LIBRARY} 
		${CORE_LIBRARY} 
		${QT_QTOPENGL_LIBRARY} 
		${OPENGL_gl_LIBRARY} 
		${OPENGL_glu_LIBRARY}
		${TOOLS_LIBRARY}
		GLU
		glut
	)
ENDIF(UNIX)

IF(WIN32)
	TARGET_LINK_LIBRARIES(${VISUALIZATION_LIBRARY} 
		${COMMON_LIBRARY} 
		${CORE_LIBRARY} 
		${QT_QTOPENGL_LIBRARY} 
		${OPENGL_gl_LIBRARY} 
		${OPENGL_glu_LIBRARY}
		GLU32
	)
ENDIF(WIN32)

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


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