Home | History | Annotate | Download | only in cmake
      1 # Main variables:
      2 # OPENNI_LIBRARY and OPENNI_INCLUDES to link OpenCV modules with OpenNI
      3 # HAVE_OPENNI for conditional compilation OpenCV with/without OpenNI
      4 
      5 if(NOT "${OPENNI_LIB_DIR}" STREQUAL "${OPENNI_LIB_DIR_INTERNAL}")
      6     unset(OPENNI_LIBRARY CACHE)
      7     unset(OPENNI_LIB_DIR CACHE)
      8 endif()
      9 
     10 if(NOT "${OPENNI_INCLUDE_DIR}" STREQUAL "${OPENNI_INCLUDE_DIR_INTERNAL}")
     11     unset(OPENNI_INCLUDES CACHE)
     12     unset(OPENNI_INCLUDE_DIR CACHE)
     13 endif()
     14 
     15 if(NOT "${OPENNI_PRIME_SENSOR_MODULE_BIN_DIR}" STREQUAL "${OPENNI_PRIME_SENSOR_MODULE_BIN_DIR_INTERNAL}")
     16     unset(OPENNI_PRIME_SENSOR_MODULE CACHE)
     17     unset(OPENNI_PRIME_SENSOR_MODULE_BIN_DIR CACHE)
     18 endif()
     19 
     20 if(WIN32)
     21     if(NOT (MSVC64 OR MINGW64))
     22         find_file(OPENNI_INCLUDES "XnCppWrapper.h" PATHS "$ENV{OPEN_NI_INSTALL_PATH}Include" DOC "OpenNI c++ interface header")
     23         find_library(OPENNI_LIBRARY "OpenNI" PATHS $ENV{OPEN_NI_LIB} DOC "OpenNI library")
     24     else()
     25         find_file(OPENNI_INCLUDES "XnCppWrapper.h" PATHS "$ENV{OPEN_NI_INSTALL_PATH64}Include" DOC "OpenNI c++ interface header")
     26         find_library(OPENNI_LIBRARY "OpenNI64" PATHS $ENV{OPEN_NI_LIB64} DOC "OpenNI library")
     27     endif()
     28 elseif(UNIX OR APPLE)
     29     find_file(OPENNI_INCLUDES "XnCppWrapper.h" PATHS "/usr/include/ni" "/usr/include/openni" DOC "OpenNI c++ interface header")
     30     find_library(OPENNI_LIBRARY "OpenNI" PATHS "/usr/lib" DOC "OpenNI library")
     31 endif()
     32 
     33 if(OPENNI_LIBRARY AND OPENNI_INCLUDES)
     34     set(HAVE_OPENNI TRUE)
     35     # the check: are PrimeSensor Modules for OpenNI installed
     36     if(WIN32)
     37     if(NOT (MSVC64 OR MINGW64))
     38             find_file(OPENNI_PRIME_SENSOR_MODULE "XnCore.dll" PATHS "$ENV{OPEN_NI_INSTALL_PATH}../PrimeSense/Sensor/Bin" "$ENV{OPEN_NI_INSTALL_PATH}../PrimeSense/SensorKinect/Bin" DOC "Core library of PrimeSensor Modules for OpenNI")
     39         else()
     40             find_file(OPENNI_PRIME_SENSOR_MODULE "XnCore64.dll" PATHS "$ENV{OPEN_NI_INSTALL_PATH64}../PrimeSense/Sensor/Bin64" "$ENV{OPEN_NI_INSTALL_PATH64}../PrimeSense/SensorKinect/Bin64" DOC "Core library of PrimeSensor Modules for OpenNI")
     41         endif()
     42     elseif(UNIX OR APPLE)
     43         find_library(OPENNI_PRIME_SENSOR_MODULE "XnCore" PATHS "/usr/lib" DOC "Core library of PrimeSensor Modules for OpenNI")
     44     endif()
     45 
     46     if(OPENNI_PRIME_SENSOR_MODULE)
     47         set(HAVE_OPENNI_PRIME_SENSOR_MODULE TRUE)
     48     endif()
     49 endif() #if(OPENNI_LIBRARY AND OPENNI_INCLUDES)
     50 
     51 get_filename_component(OPENNI_LIB_DIR "${OPENNI_LIBRARY}" PATH)
     52 get_filename_component(OPENNI_INCLUDE_DIR ${OPENNI_INCLUDES} PATH)
     53 get_filename_component(OPENNI_PRIME_SENSOR_MODULE_BIN_DIR "${OPENNI_PRIME_SENSOR_MODULE}" PATH)
     54 
     55 if(HAVE_OPENNI)
     56   set(OPENNI_LIB_DIR "${OPENNI_LIB_DIR}" CACHE PATH "Path to OpenNI libraries" FORCE)
     57   set(OPENNI_INCLUDE_DIR "${OPENNI_INCLUDE_DIR}" CACHE PATH "Path to OpenNI headers" FORCE)
     58   set(OPENNI_PRIME_SENSOR_MODULE_BIN_DIR "${OPENNI_PRIME_SENSOR_MODULE_BIN_DIR}" CACHE PATH "Path to OpenNI PrimeSensor Module binaries" FORCE)
     59 endif()
     60 
     61 if(OPENNI_LIBRARY)
     62     set(OPENNI_LIB_DIR_INTERNAL "${OPENNI_LIB_DIR}" CACHE INTERNAL "This is the value of the last time OPENNI_LIB_DIR was set successfully." FORCE)
     63 else()
     64     message( WARNING, " OpenNI library directory (set by OPENNI_LIB_DIR variable) is not found or does not have OpenNI libraries." )
     65 endif()
     66 
     67 if(OPENNI_INCLUDES)
     68     set(OPENNI_INCLUDE_DIR_INTERNAL "${OPENNI_INCLUDE_DIR}" CACHE INTERNAL "This is the value of the last time OPENNI_INCLUDE_DIR was set successfully." FORCE)
     69 else()
     70     message( WARNING, " OpenNI include directory (set by OPENNI_INCLUDE_DIR variable) is not found or does not have OpenNI include files." )
     71 endif()
     72 
     73 if(OPENNI_PRIME_SENSOR_MODULE)
     74     set(OPENNI_PRIME_SENSOR_MODULE_BIN_DIR_INTERNAL "${OPENNI_PRIME_SENSOR_MODULE_BIN_DIR}" CACHE INTERNAL "This is the value of the last time OPENNI_PRIME_SENSOR_MODULE_BIN_DIR was set successfully." FORCE)
     75 else()
     76     message( WARNING, " PrimeSensor Module binaries directory (set by OPENNI_PRIME_SENSOR_MODULE_BIN_DIR variable) is not found or does not have PrimeSensor Module binaries." )
     77 endif()
     78 
     79 mark_as_advanced(FORCE OPENNI_PRIME_SENSOR_MODULE)
     80 mark_as_advanced(FORCE OPENNI_LIBRARY)
     81 mark_as_advanced(FORCE OPENNI_INCLUDES)
     82 
     83 if(HAVE_OPENNI)
     84   ocv_parse_header("${OPENNI_INCLUDE_DIR}/XnVersion.h" OPENNI_VERSION_LINES XN_MAJOR_VERSION XN_MINOR_VERSION XN_MAINTENANCE_VERSION XN_BUILD_VERSION)
     85   if(XN_MAJOR_VERSION)
     86     set(OPENNI_VERSION_STRING ${XN_MAJOR_VERSION}.${XN_MINOR_VERSION}.${XN_MAINTENANCE_VERSION} CACHE INTERNAL "OpenNI version")
     87     set(OPENNI_VERSION_BUILD ${XN_BUILD_VERSION} CACHE INTERNAL "OpenNI build version")
     88   endif()
     89 endif()
     90