1# Main variables:
2# OPENNI2_LIBRARY and OPENNI2_INCLUDES to link OpenCV modules with OpenNI2
3# HAVE_OPENNI2 for conditional compilation OpenCV with/without OpenNI2
4
5if(NOT "${OPENNI2_LIB_DIR}" STREQUAL "${OPENNI2_LIB_DIR_INTERNAL}")
6    unset(OPENNI2_LIBRARY CACHE)
7    unset(OPENNI2_LIB_DIR CACHE)
8endif()
9
10if(NOT "${OPENNI2_INCLUDE_DIR}" STREQUAL "${OPENNI2_INCLUDE_DIR_INTERNAL}")
11    unset(OPENNI2_INCLUDES CACHE)
12    unset(OPENNI2_INCLUDE_DIR CACHE)
13endif()
14
15if(WIN32)
16    if(NOT (MSVC64 OR MINGW64))
17        find_file(OPENNI2_INCLUDES "OpenNI.h" PATHS "$ENV{OPEN_NI_INSTALL_PATH}Include" DOC "OpenNI2 c++ interface header")
18        find_library(OPENNI2_LIBRARY "OpenNI2" PATHS $ENV{OPENNI2_LIB} DOC "OpenNI2 library")
19    else()
20        find_file(OPENNI2_INCLUDES "OpenNI.h" PATHS $ENV{OPENNI2_INCLUDE64} "$ENV{OPEN_NI_INSTALL_PATH64}Include" DOC "OpenNI2 c++ interface header")
21        find_library(OPENNI2_LIBRARY "OpenNI2" PATHS $ENV{OPENNI2_LIB64} DOC "OpenNI2 library")
22    endif()
23elseif(UNIX OR APPLE)
24    find_file(OPENNI2_INCLUDES "OpenNI.h" PATHS "/usr/include/ni2" "/usr/include/openni2" $ENV{OPENNI2_INCLUDE} DOC "OpenNI2 c++ interface header")
25    find_library(OPENNI2_LIBRARY "OpenNI2" PATHS "/usr/lib" $ENV{OPENNI2_REDIST} DOC "OpenNI2 library")
26endif()
27
28if(OPENNI2_LIBRARY AND OPENNI2_INCLUDES)
29    set(HAVE_OPENNI2 TRUE)
30endif() #if(OPENNI2_LIBRARY AND OPENNI2_INCLUDES)
31
32get_filename_component(OPENNI2_LIB_DIR "${OPENNI2_LIBRARY}" PATH)
33get_filename_component(OPENNI2_INCLUDE_DIR ${OPENNI2_INCLUDES} PATH)
34
35if(HAVE_OPENNI2)
36  set(OPENNI2_LIB_DIR "${OPENNI2_LIB_DIR}" CACHE PATH "Path to OpenNI2 libraries" FORCE)
37  set(OPENNI2_INCLUDE_DIR "${OPENNI2_INCLUDE_DIR}" CACHE PATH "Path to OpenNI2 headers" FORCE)
38endif()
39
40if(OPENNI2_LIBRARY)
41    set(OPENNI2_LIB_DIR_INTERNAL "${OPENNI2_LIB_DIR}" CACHE INTERNAL "This is the value of the last time OPENNI_LIB_DIR was set successfully." FORCE)
42else()
43    message( WARNING, " OpenNI2 library directory (set by OPENNI2_LIB_DIR variable) is not found or does not have OpenNI2 libraries." )
44endif()
45
46if(OPENNI2_INCLUDES)
47    set(OPENNI2_INCLUDE_DIR_INTERNAL "${OPENNI2_INCLUDE_DIR}" CACHE INTERNAL "This is the value of the last time OPENNI2_INCLUDE_DIR was set successfully." FORCE)
48else()
49    message( WARNING, " OpenNI2 include directory (set by OPENNI2_INCLUDE_DIR variable) is not found or does not have OpenNI2 include files." )
50endif()
51
52mark_as_advanced(FORCE OPENNI2_LIBRARY)
53mark_as_advanced(FORCE OPENNI2_INCLUDES)
54
55if(HAVE_OPENNI2)
56  ocv_parse_header("${OPENNI2_INCLUDE_DIR}/OniVersion.h" ONI_VERSION_LINE ONI_VERSION_MAJOR ONI_VERSION_MINOR ONI_VERSION_MAINTENANCE ONI_VERSION_BUILD)
57  if(ONI_VERSION_MAJOR)
58    set(OPENNI2_VERSION_STRING ${ONI_VERSION_MAJOR}.${ONI_VERSION_MINOR}.${ONI_VERSION_MAINTENANCE} CACHE INTERNAL "OpenNI2 version")
59    set(OPENNI2_VERSION_BUILD ${ONI_VERSION_BUILD} CACHE INTERNAL "OpenNI2 build version")
60  endif()
61endif()
62