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

# VTK
FIND_PACKAGE(VTK REQUIRED)
IF(VTK_FOUND)
	INCLUDE(${VTK_USE_FILE})
	INCLUDE_DIRECTORIES(${VTK_INCLUDE_DIRS})
ELSE()
	MESSAGE(FATAL_ERROR "VTK not found, but needed.")
ENDIF(VTK_FOUND)

# VTK libraries for convenience
SET(VTK_LIBRARIES
	vtkCommon
	vtkWidgets
	QVTK
)


# The headers, sources and Qt related stuff in the ritkVTK module
#================================================================
SET(HDRS
	ritkVTK.h
	ritkRImageVTKData.h
	ritkLUTData.h
	ritkActorPipeline.h
	ritkVTKImageActorPipeline.h	
	ritkRImageActorPipeline.h
	ritkRImage2DActorPipeline.h
	ritkSynchronizedQVTKWidget.h
	ritkVisualizationWidget2D.h
	ritkVisualizationWidget3D.h
)

SET(SRCS
	ritkRImageVTKData.cxx
	ritkActorPipeline.cxx
	ritkVTKImageActorPipeline.cxx
	ritkRImageActorPipeline.cxx
	ritkRImage2DActorPipeline.cxx
	ritkSynchronizedQVTKWidget.cxx
	ritkVisualizationWidget2D.cxx
	ritkVisualizationWidget3D.cxx
)

SET(MOC_HDRS 
	ritkSynchronizedQVTKWidget.h
	ritkVisualizationWidget2D.h	
	ritkVisualizationWidget3D.h
)

SET(UIS	
	ritkVisualizationWidget2D.ui
	ritkVisualizationWidget3D.ui
)

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

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


# Project settings
# ================
SET(RITKVTK_INCLUDE_DIRS
	${CMAKE_CURRENT_SOURCE_DIR}
	${CMAKE_CURRENT_BINARY_DIR}
	${TOOLS_INCLUDE_DIRS}
	${COMMON_INCLUDE_DIRS}
	${CORE_INCLUDE_DIRS}
	${CMAKE_CURRENT_SOURCE_DIR}/ThirdParty
	CACHE INTERNAL ""
)
SET(THIRDPARTY_HDRS
	ThirdParty/itkImageToVTKImageFilter.h
	ThirdParty/itkVTKImageToImageFilter.h
	ThirdParty/itkImageToVTKImageFilter.txx
	ThirdParty/itkVTKImageToImageFilter.txx
)
INCLUDE_DIRECTORIES(${RITKVTK_INCLUDE_DIRS})
ADD_DEFINITIONS("/DRITKVTK_SHAREDLIB_EXPORT")
ADD_LIBRARY(${RITKVTK_LIBRARY} SHARED ${SRCS} ${HDRS} ${ITK_SRCS} ${ITK_HDRS} ${MOC_SRCS} ${UI_HDRS}) 
TARGET_LINK_LIBRARIES(${RITKVTK_LIBRARY} ${TOOLS_LIBRARY} ${CORE_LIBRARY} ${ITK_LIBRARIES} ${VTK_LIBRARIES})
SET_TARGET_PROPERTIES(${RITKVTK_LIBRARY} PROPERTIES DEBUG_POSTFIX "d")


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