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

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

# OpenCL
FIND_PACKAGE(OpenCL)
IF(OPENCL_FOUND)

	mark_as_advanced(OPENCL_INCLUDE_DIR)
	INCLUDE_DIRECTORIES(${OPENCL_INCLUDE_DIR})
ELSE()
	MESSAGE(FATAL_ERROR "OpenCL not found, but needed.")
ENDIF(OPENCL_FOUND)

	
SET(HDRS
	RITKOpenCL.h
	OpenCLContext.h
	cl_utils.h
	OpenCLImportImageContainer.h
	OpenCLRegularMemoryImportImageContainer.h
	OpenCLImageMemoryImportImageContainer.h
)

SET(SRCS
	OpenCLContext.cxx
	cl_utils.cxx
	OpenCLImportImageContainer.txx
	OpenCLInstantiations.cxx
	OpenCLRegularMemoryImportImageContainer.txx
	OpenCLImageMemoryImportImageContainer.txx
)

# Set the include directories for RITKCuda
SET(RITKOPENCL_INCLUDE_DIRS
	${CMAKE_CURRENT_SOURCE_DIR}
	CACHE INTERNAL ""
)
		
# Set the library for 
set(RITKOPENCL_LIBRARY ritkOpenCL CACHE INTERNAL "")



SET(LIBRARY_OUTPUT_PATH "${CMAKE_BINARY_DIR}")

ADD_DEFINITIONS("/DRITKOPENCL_SHAREDLIB_EXPORT")
INCLUDE_DIRECTORIES(${RITK_OPENCL_INCLUDE_DIRS} ${CORE_INCLUDE_DIRS} ${COMMON_INCLUDE_DIRS} ${OPENCL_INCLUDE_DIR})
ADD_LIBRARY(${RITKOPENCL_LIBRARY} SHARED ${SRCS} ${HDRS} ${ITK_SRCS} ${ITK_HDRS}) 
TARGET_LINK_LIBRARIES(${RITKOPENCL_LIBRARY} ${CORE_LIBRARY} ${ITK_LIBRARIES} ${COMMON_LIBRARY} ${OPENCL_LIBRARIES})

INSTALL(FILES ${HDRS} DESTINATION dev/include/OpenCL)



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

INSTALL(TARGETS ${RITKOPENCL_LIBRARY}
	RUNTIME DESTINATION bin/debug CONFIGURATIONS Debug
	LIBRARY DESTINATION dev/lib/debug 
	ARCHIVE DESTINATION dev/lib/debug 
	CONFIGURATIONS Debug
)

INSTALL(TARGETS ${RITKOPENCL_LIBRARY}
	RUNTIME DESTINATION bin/release CONFIGURATIONS Release
	LIBRARY DESTINATION dev/lib/release 
	ARCHIVE DESTINATION dev/lib/release 
	CONFIGURATIONS Release
)