SET(Kinect2SDK_ROOT_DIR $ENV{KINECTSDK20_DIR})
SET(Kinect2SDK_LIB_DIR "${Kinect2SDK_ROOT_DIR}Lib/x86")
SET(Kinect2SDK_INCLUDE_DIR "${Kinect2SDK_ROOT_DIR}inc")
SET(Kinect2SDK_DLLS $ENV{SystemRoot}System32/Kinect20.Face.dll)
SET(Kinect2SDK_LIBRARIES "${Kinect2SDK_LIB_DIR}/Kinect20.lib" "${Kinect2SDK_LIB_DIR}/Kinect20.Face.lib")
SET(Kinect2SDK_INCLUDES 
	"${Kinect2SDK_INCLUDE_DIR}/Kinect.h"
	"${Kinect2SDK_INCLUDE_DIR}/Kinect.Face.h"
	"${Kinect2SDK_INCLUDE_DIR}/Kinect.INPC.h"
	#"${Kinect2SDK_INCLUDE_DIR}/NuiSkeleton.h"
	#"${Kinect2SDK_INCLUDE_DIR}/KinectAudio.h"
	#"${Kinect2SDK_INCLUDE_DIR}/NuiImageBuffer.h"
)

#SET(KinectTOOLKIT_DIR $ENV{KINECT_TOOLKIT_DIR})
#SET(KinectTOOLKIT_LIB_DIR "${KinectTOOLKIT_DIR}lib/x86")
#SET(KinectTOOLKIT_INCLUDE_DIR "${KinectTOOLKIT_DIR}inc")
#SET(KinectTOOLKIT_DLL_DIR "${KinectTOOLKIT_DIR}bin")
#SET(KinectTOOLKIT_LIBRARIES "${KinectTOOLKIT_LIB_DIR}/FaceTrackLib.lib")
#SET(KinectTOOLKIT_DLLS 
#	"${KinectTOOLKIT_DLL_DIR}/FaceTrackData.dll"
#	"${KinectTOOLKIT_DLL_DIR}/FaceTrackLib.dll"
#)
#SET(KinectTOOLKIT_INCLUDES 
#	"${KinectTOOLKIT_INCLUDE_DIR}/FaceTrackLib.h"
#	"${KinectTOOLKIT_INCLUDE_DIR}/KinectInteraction.h"
#	"${KinectTOOLKIT_INCLUDE_DIR}/KinectBackgroundRemoval.h"
#)


####################   Macro   #######################
MACRO(CHECK_FILES _FILES _DIR)
	SET(_MISSING_FILES)
	FOREACH(_FILE ${${_FILES}})
		IF(NOT EXISTS "${_FILE}")
			SET(Kinect2SDK_FOUND NO)
			get_filename_component(_FILE ${_FILE} NAME)
			SET(_MISSING_FILES "${_MISSING_FILES}${_FILE}, ")
		ENDIF()
	ENDFOREACH()
	IF(_MISSING_FILES)
		MESSAGE(STATUS "In folder \"${${_DIR}}\" not found files: ${_MISSING_FILES}")
		SET(KinectSDK_FOUND NO)
	ENDIF()
ENDMACRO(CHECK_FILES)

MACRO(CHECK_DIR _DIR)
	IF(NOT EXISTS "${${_DIR}}")
		MESSAGE(STATUS "Folder \"${${_DIR}}\" not found.")
		SET(KinectSDK_FOUND NO)
	ENDIF()
ENDMACRO(CHECK_DIR)

##################### Checking #######################
MESSAGE(STATUS "Searching KinectSDK.")
SET(KinectSDK_FOUND YES)

CHECK_DIR(KinectSDK_ROOT_DIR)
IF(KinectSDK_FOUND)
	CHECK_DIR(KinectSDK_LIB_DIR)
	CHECK_DIR(KinectSDK_INCLUDE_DIR)
	
	IF(KinectSDK_FOUND)
		#CHECK_FILES(KinectSDK_DLLS KinectSDK_ROOT_DIR)
		CHECK_FILES(KinectSDK_LIBRARIES KinectSDK_LIB_DIR)
		CHECK_FILES(KinectSDK_INCLUDES KinectSDK_INCLUDE_DIR)
	ENDIF()
ENDIF()

MESSAGE(STATUS "KinectSDK_FOUND - ${KinectSDK_FOUND}.")


#MESSAGE(STATUS "Searching KinectTOOLKIT.")
#SET(KinectTOOLKIT_FOUND YES)

#CHECK_DIR(KinectTOOLKIT_DIR)
#IF(KinectTOOLKIT_FOUND)
#	CHECK_DIR(KinectTOOLKIT_LIB_DIR)
#	CHECK_DIR(KinectTOOLKIT_INCLUDE_DIR)
	
#	IF(KinectTOOLKIT_FOUND)
#		CHECK_FILES(KinectTOOLKIT_LIBRARIES KinectTOOLKIT_LIB_DIR)
#		CHECK_FILES(KinectTOOLKIT_INCLUDES KinectTOOLKIT_INCLUDE_DIR)
#	ENDIF()
#ENDIF()

#MESSAGE(STATUS "KinectTOOLKIT_FOUND - ${KinectTOOLKIT_FOUND}.")
