Added version detection for OpenNI
authorAndrey Kamaev <no@email>
Wed, 11 Apr 2012 13:20:25 +0000 (13:20 +0000)
committerAndrey Kamaev <no@email>
Wed, 11 Apr 2012 13:20:25 +0000 (13:20 +0000)
CMakeLists.txt
cmake/OpenCVFindOpenNI.cmake

index a073364..2784920 100644 (file)
@@ -790,10 +790,10 @@ else()
   status("    JPEG 2000:"  "NO")
 endif()
 
-status("    OpenEXR:"   WITH_OPENEXR AND OPENEXR_FOUND     THEN "${OPENEXR_LIBRARIES} (ver ${OPENEXR_VERSION})" ELSE NO)
-status("    OpenNI:"    HAVE_OPENNI                        THEN YES             ELSE NO)
+status("    OpenEXR:"   WITH_OPENEXR AND OPENEXR_FOUND     THEN "${OPENEXR_LIBRARIES} (ver ${OPENEXR_VERSION})"                     ELSE NO)
+status("    OpenNI:"    HAVE_OPENNI                        THEN "YES (ver ${OPENNI_VERSION_STRING}, build ${OPENNI_VERSION_BUILD})" ELSE NO)
 status("    OpenNI PrimeSensor Modules:"
-                        HAVE_OPENNI_PRIME_SENSOR_MODULE    THEN YES             ELSE NO)
+                        HAVE_OPENNI_PRIME_SENSOR_MODULE    THEN "YES (${OPENNI_PRIME_SENSOR_MODULE})"                               ELSE NO)
 if(WIN32)
   status("    XIMEA:"     HAVE_XIMEA  THEN YES ELSE NO)
 endif()
index bf9d614..2897a99 100644 (file)
@@ -48,9 +48,15 @@ if(OPENNI_LIBRARY AND OPENNI_INCLUDES)
     endif()
 endif() #if(OPENNI_LIBRARY AND OPENNI_INCLUDES)
 
-get_filename_component(OPENNI_LIB_DIR "${OPENNI_LIBRARY}" PATH CACHE)
-get_filename_component(OPENNI_INCLUDE_DIR ${OPENNI_INCLUDES} PATH CACHE)
-get_filename_component(OPENNI_PRIME_SENSOR_MODULE_BIN_DIR "${OPENNI_PRIME_SENSOR_MODULE}" PATH CACHE)
+get_filename_component(OPENNI_LIB_DIR "${OPENNI_LIBRARY}" PATH)
+get_filename_component(OPENNI_INCLUDE_DIR ${OPENNI_INCLUDES} PATH)
+get_filename_component(OPENNI_PRIME_SENSOR_MODULE_BIN_DIR "${OPENNI_PRIME_SENSOR_MODULE}" PATH)
+
+if(HAVE_OPENNI)
+  set(OPENNI_LIB_DIR "${OPENNI_LIB_DIR}" CACHE PATH "Path to OpenNI libraries" FORCE)
+  set(OPENNI_INCLUDE_DIR "${OPENNI_INCLUDE_DIR}" CACHE PATH "Path to OpenNI headers" FORCE)
+  set(OPENNI_PRIME_SENSOR_MODULE_BIN_DIR "${OPENNI_PRIME_SENSOR_MODULE_BIN_DIR}" CACHE PATH "Path to OpenNI PrimeSensor Module binaries" FORCE)
+endif()
 
 if(OPENNI_LIBRARY)
     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)
@@ -73,3 +79,11 @@ endif()
 mark_as_advanced(FORCE OPENNI_PRIME_SENSOR_MODULE)
 mark_as_advanced(FORCE OPENNI_LIBRARY)
 mark_as_advanced(FORCE OPENNI_INCLUDES)
+
+if(HAVE_OPENNI)
+  ocv_parse_header("${OPENNI_INCLUDE_DIR}/XnVersion.h" OPENNI_VERSION_LINES XN_MAJOR_VERSION XN_MINOR_VERSION XN_MAINTENANCE_VERSION XN_BUILD_VERSION)
+  if(XN_MAJOR_VERSION)
+    set(OPENNI_VERSION_STRING ${XN_MAJOR_VERSION}.${XN_MINOR_VERSION}.${XN_MAINTENANCE_VERSION} CACHE INTERNAL "OpenNI version")
+    set(OPENNI_VERSION_BUILD ${XN_BUILD_VERSION} CACHE INTERNAL "OpenNI build version")
+  endif()
+endif()