cmake_minimum_required(VERSION 2.6)

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

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

# RITK
FIND_PACKAGE(RITK REQUIRED)
IF(RITK_FOUND)
	INCLUDE_DIRECTORIES(${RITK_INCLUDE_DIR})
	INCLUDE(${RITK_USE_FILE})	
ELSE()
	MESSAGE("RITK not found, but needed.")
ENDIF(RITK_FOUND)

# CUDA
FIND_PACKAGE(CUDA)
IF(CUDA_FOUND)
	SET(CUDA_NVCC_FLAGS ${CUDA_NVCC_FLAGS} "--ptxas-options=-v")
ELSE()
	MESSAGE(FATAL_ERROR "CUDA not found, but needed.")
ENDIF(CUDA_FOUND)


# The headers, sources and Qt related stuff in this plugin
# ========================================================
SET(CUDANormalizedConvolutionRImage_HDRS
	CUDASeparableNormalizedConvolutionImageFilter.h
	CUDANormalizedConvolutionRImageFilter.h
	CUDANormalizedConvolutionRImageFilterPlugin.h
	CUDANormalizedConvolutionRImageFilterWidget.h
	CUDANormalizedConvolutionRImageFilterPluginFactory.h
)

SET(CUDANormalizedConvolutionRImage_SRCS
	CUDASeparableNormalizedConvolutionImageFilter.txx
	CUDANormalizedConvolutionRImageFilter.txx
	CUDANormalizedConvolutionRImageFilterPlugin.cxx
	CUDANormalizedConvolutionRImageFilterWidget.cxx
	CUDANormalizedConvolutionRImageFilterPluginFactory.cxx
	Instantiations.cxx
)

SET(CUDA_HDRS
	CUDASeparableNormalizedConvolutionImageFilterInterfaces.h
	CUDASeparableNormalizedConvolutionImageFilterKernel.h
)

SET(CUDA_SRCS
	CUDASeparableNormalizedConvolutionImageFilter.cu
)

SET(CUDANormalizedConvolutionRImage_MOC_HDRS 	
	CUDANormalizedConvolutionRImageFilterWidget.h
	CUDANormalizedConvolutionRImageFilterPlugin.h
	CUDANormalizedConvolutionRImageFilterPluginFactory.h
)

SET(CUDANormalizedConvolutionRImage_UIS
	CUDANormalizedConvolutionRImageFilterWidget.ui
)

QT4_WRAP_UI(UI_HDRS ${CUDANormalizedConvolutionRImage_UIS})	
QT4_WRAP_CPP(MOC_SRCS ${CUDANormalizedConvolutionRImage_MOC_HDRS})


# Set the library name for this plugin
# ====================================
SET(CUDANormalizedConvolutionRImage_LIBRARY CUDANormalizedConvolutionRImage CACHE INTERNAL "")
SET(LIBRARY_OUTPUT_PATH "${CMAKE_BINARY_DIR}")
SET(CMAKE_INSTALL_RPATH_USE_LINK_PATH TRUE)


# Project settings
# ================
SET(CUDANormalizedConvolutionRImage_INCLUDE_DIRS ${CMAKE_CURRENT_SOURCE_DIR} ${CMAKE_CURRENT_BINARY_DIR} CACHE INTERNAL "")
INCLUDE_DIRECTORIES(${CUDANormalizedConvolutionRImage_INCLUDE_DIRS} ${RITK_INCLUDE_DIRS})
ADD_DEFINITIONS(-DQT_PLUGIN)
ADD_DEFINITIONS(-DQT_SHARED)
CUDA_ADD_LIBRARY(${CUDANormalizedConvolutionRImage_LIBRARY} SHARED ${CUDANormalizedConvolutionRImage_SRCS} ${CUDANormalizedConvolutionRImage_HDRS} ${MOC_SRCS} ${UI_HDRS} ${CUDA_HDRS} ${CUDA_SRCS})
TARGET_LINK_LIBRARIES(${CUDANormalizedConvolutionRImage_LIBRARY}
	debug ${RITK_COMMON_LIBRARY_DEBUG}
	optimized ${RITK_COMMON_LIBRARY}
	debug ${RITK_CORE_LIBRARY_DEBUG}
	optimized ${RITK_CORE_LIBRARY}
	debug ${RITK_CUDA_LIBRARY_DEBUG}
	optimized ${RITK_CUDA_LIBRARY}
	${ITK_LIBRARIES}
	${QT_LIBRARIES}
	${CUDA_CUDA_LIBRARY} 
	${CUDA_CUDART_LIBRARY} 

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


# Module installation
# ===================
INSTALL(TARGETS ${CUDANormalizedConvolutionRImage_LIBRARY} CONFIGURATIONS RELEASE
	RUNTIME DESTINATION ${RITK_BINARY_DIR}/release/plugins 
	LIBRARY DESTINATION ${RITK_BINARY_DIR}/release/plugins 
)
INSTALL(TARGETS ${CUDANormalizedConvolutionRImage_LIBRARY} CONFIGURATIONS DEBUG
	RUNTIME DESTINATION ${RITK_BINARY_DIR}/debug/plugins 
	LIBRARY DESTINATION ${RITK_BINARY_DIR}/debug/plugins 
)
