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)

#-----------------------------------------------------------------------------

SET(HDRS
	PMDCamCubeRImage.h
	PMDCamCubeRImageSource.h
	PMDCamCubeRImageIO.h
	PMDCamCubeSourcePluginFactory.h
	PMDCamCubeSourcePlugin.h
	PMDCamCubeSourcePluginWidget.h
)

SET(SRCS
	PMDCamCubeRImage.txx
	PMDCamCubeRImageSource.txx
	PMDCamCubeRImageIO.txx
	PMDCamCubeSourcePluginFactory.cxx
	PMDCamCubeSourcePlugin.cxx
	PMDCamCubeSourcePluginWidget.cxx
	PMDCamCubeInstantiaions.cxx
)

#-----------------------------------------------------------------------------

# Qt
# all childs of qobject have to be put here
SET(MOC_HDRS 	
	PMDCamCubeSourcePlugin.h
	PMDCamCubeSourcePluginWidget.h
	PMDCamCubeSourcePluginFactory.h
)

SET(UIS
	PMDCamCubeSourcePluginWidget.ui
)

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

#-----------------------------------------------------------------------------

# Set the name for the library
SET(LIBRARY_NAME PMDCamCubeSourcePlugin)

# Declare as plugin library
SET(PLUGIN_LIBRARIES
	${PLUGIN_LIBRARIES}
	${LIBRARY_NAME}
	CACHE INTERNAL ""
)

# Set include directories
SET(INCLUDE_DIRS	
	${CMAKE_CURRENT_SOURCE_DIR}
	${CMAKE_CURRENT_SOURCE_DIR}/PMDSDK2
	${CMAKE_CURRENT_SOURCE_DIR}/PMDSDK2/include
	${CMAKE_CURRENT_BINARY_DIR}
)

# Declare as plugin include directories
SET(PLUGIN_INCLUDE_DIRS
	${PLUGIN_INCLUDE_DIRS}
	${INCLUDE_DIRS}
	CACHE INTERNAL ""
)

# QT plugin
ADD_DEFINITIONS(-DQT_PLUGIN)
ADD_DEFINITIONS(-DQT_SHARED)

INCLUDE_DIRECTORIES(${INCLUDE_DIRS} ${RITK_INCLUDE_DIRS})

ADD_LIBRARY(
	${LIBRARY_NAME} SHARED 
		${SRCS} 
		${HDRS} 
		${MOC_SRCS} 
		${UI_HDRS}
) 


TARGET_LINK_LIBRARIES(
	${LIBRARY_NAME} 
		debug ${RITK_COMMON_LIBRARY_DEBUG}
		debug ${RITK_CORE_LIBRARY_DEBUG}
		debug ${RITK_VISUALIZATION_LIBRARY_DEBUG}
		optimized ${RITK_COMMON_LIBRARY}
		optimized ${RITK_CORE_LIBRARY}
		optimized ${RITK_VISUALIZATION_LIBRARY}
		${CMAKE_CURRENT_SOURCE_DIR}/PMDSDK2/bin/pmdaccess2.lib
		${ITK_LIBRARIES}
		${QT_LIBRARIES}
) 

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

INSTALL(TARGETS ${LIBRARY_NAME} CONFIGURATIONS RELEASE
	RUNTIME DESTINATION ${RITK_BINARY_DIR}/release/plugins
	LIBRARY	DESTINATION ${RITK_BINARY_DIR}/release/plugins
)

INSTALL(TARGETS ${LIBRARY_NAME} CONFIGURATIONS DEBUG
	RUNTIME DESTINATION ${RITK_BINARY_DIR}/debug/plugins
	LIBRARY	DESTINATION ${RITK_BINARY_DIR}/debug/plugins
)

INSTALL(FILES
		${CMAKE_CURRENT_SOURCE_DIR}/PMDSDK2/plugins/camcube.W32.pap 
		${CMAKE_CURRENT_SOURCE_DIR}/PMDSDK2/plugins/camcubeproc.W32.ppp
		${CMAKE_CURRENT_SOURCE_DIR}/PMDSDK2/plugins/camcube.W64.pap 
		${CMAKE_CURRENT_SOURCE_DIR}/PMDSDK2/plugins/camcubeproc.W64.ppp
		${CMAKE_CURRENT_SOURCE_DIR}/PMDSDK2/bin/pmdaccess2.dll 
	DESTINATION ${RITK_BINARY_DIR}/release CONFIGURATIONS RELEASE
)

INSTALL(FILES
		${CMAKE_CURRENT_SOURCE_DIR}/PMDSDK2/plugins/camcube.W32.pap 
		${CMAKE_CURRENT_SOURCE_DIR}/PMDSDK2/plugins/camcubeproc.W32.ppp
		${CMAKE_CURRENT_SOURCE_DIR}/PMDSDK2/plugins/camcube.W64.pap 
		${CMAKE_CURRENT_SOURCE_DIR}/PMDSDK2/plugins/camcubeproc.W64.ppp
		${CMAKE_CURRENT_SOURCE_DIR}/PMDSDK2/bin/pmdaccess2.dll 
	DESTINATION ${RITK_BINARY_DIR}/debug CONFIGURATIONS DEBUG
)
