Permalink
Browse files

openni/nite finiding macros, WIN32 work

  • Loading branch information...
1 parent e29e807 commit 9d8a2fc196284d74baa7603be2fbaa797d172f9f @royshil royshil committed Mar 2, 2012
@@ -10,6 +10,8 @@ set (CMAKE_BACKWARDS_COMPATIBILITY 2.6)
Project(${PLUGIN_NAME})
+set(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} "${CMAKE_CURRENT_SOURCE_DIR}/cmake/Modules/")
+
file (GLOB GENERAL RELATIVE ${CMAKE_CURRENT_SOURCE_DIR}
[^.]*.cpp
[^.]*.h
@@ -35,6 +37,24 @@ SET( SOURCES
${GENERATED}
)
+find_package(OpenNI)
+if(NOT OPENNI_FOUND)
+ message(STATUS "Can't find OpenNI!")
+else()
+ message(STATUS "OpenNI found in ${OpenNI_INCLUDE_DIRS}")
+endif()
+include_directories(${OpenNI_INCLUDE_DIRS})
+
+
+find_package(NITE)
+if(NOT NITE_FOUND)
+ message(STATUS "Can't find NITE!")
+else()
+ message(STATUS "NITE found in ${NITE_INCLUDE_DIRS}")
+endif()
+include_directories(${NITE_INCLUDE_DIRS})
+
+
# This will include Win/projectDef.cmake, X11/projectDef.cmake, Mac/projectDef
# depending on the platform
include_platform()
@@ -25,6 +25,8 @@ set (SOURCES
${PLATFORM}
)
+
+
add_windows_plugin(${PROJECT_NAME} SOURCES)
# This is an example of how to add a build step to sign the plugin DLL before
@@ -47,6 +49,7 @@ add_windows_plugin(${PROJECT_NAME} SOURCES)
# add library dependencies here; leave ${PLUGIN_INTERNAL_DEPS} there unless you know what you're doing!
target_link_libraries(${PROJECT_NAME}
${PLUGIN_INTERNAL_DEPS}
+ ${OpenNI_LIBRARIES}
)
set(WIX_HEAT_FLAGS
@@ -0,0 +1,83 @@
+# - Try to find NITE
+# Once done, this will define
+#
+# NITE_FOUND - system has NITE
+# NITE_INCLUDE_DIRS - the NITE include directories
+# NITE_LIBRARIES - link these to use NITE
+
+#include(LibFindMacros)
+
+# Dependencies
+
+# Use pkg-config to get hints about paths
+find_package(PkgConfig)
+pkg_check_modules(NITE_PKGCONF NITE)
+
+SET(NITE_INCLUDE_SEARCH_PATHS ${NITE_PKGCONF_INCLUDE_DIRS})
+SET(NITE_LIB_SEARCH_PATHS ${NITE_PKGCONF_LIBRARY_DIRS})
+
+IF(WIN32)
+ # this is where NITE msi installers usually put the files
+ SET(NITE_INCLUDE_SEARCH_PATHS "C:/Program Files/NITE/Include/" "D:/Program Files/NITE/Include/")
+ SET(NITE_LIB_SEARCH_PATHS "C:/Program Files/NITE/Lib/" "D:/Program Files/NITE/Lib/")
+ENDIF(WIN32)
+
+MESSAGE(STATUS "Try to look here: ${NITE_INCLUDE_SEARCH_PATHS}")
+
+# Include dir
+find_path(NITE_INCLUDE_DIR
+ NAMES XnVNite.h
+ HINTS ${NITE_INCLUDE_SEARCH_PATHS}
+ PATH_SUFFIXES "ni"
+)
+
+if(NITE_INCLUDE_DIR STREQUAL "NITE_INCLUDE_DIR-NOTFOUND")
+ message(STATUS "Looking for NITE in default dirs")
+ find_path(NITE_INCLUDE_DIR NAMES XnVNite.h
+ PATH_SUFFIXES "ni"
+ )
+endif()
+
+# Finally the library itself
+find_library(NITE_LIBRARY
+ NAMES XnVNITE
+ PATHS ${NITE_LIB_SEARCH_PATHS}
+)
+
+if(NITE_LIBRARY STREQUAL "NITE_LIBRARY-NOTFOUND")
+ message(STATUS "can't find NITE library, looking more aggressively")
+ foreach(NITE_LOOKUP_PATH ${NITE_LIB_SEARCH_PATHS})
+ file(GLOB NITE_LIBRARY "${NITE_LOOKUP_PATH}/XnVNITE*lib")
+ message(STATUS "looking in ${NITE_LOOKUP_PATH} resulted in ${NITE_LIBRARY}")
+ if(NOT ${NITE_LIBRARY} STREQUAL "")
+ #found NITE library
+ #but there may be many files found..
+ foreach(NITE_LIBRARY_FOUND ${NITE_LIBRARY})
+ string(REGEX MATCH "jni" FOUND_JNI_IN_FILE ${NITE_LIBRARY_FOUND})
+ if(NOT FOUND_JNI_IN_FILE)
+ set(NITE_LIBRARY ${NITE_LIBRARY_FOUND})
+ break()
+ endif()
+ endforeach()
+ break()
+ endif()
+ endforeach()
+endif()
+
+# Set the include dir variables and the libraries and let libfind_process do the rest.
+# NOTE: Singular variables for this library, plural for libraries this this lib depends on.
+#set(NITE_PROCESS_INCLUDES NITE_INCLUDE_DIR NITE_INCLUDE_DIRS)
+#set(NITE_PROCESS_LIBS NITE_LIBRARY NITE_LIBRARIES)
+#libfind_process(NITE)
+
+set(NITE_LIBRARIES ${NITE_LIBRARY} )
+set(NITE_LIBS ${NITE_LIBRARY} )
+set(NITE_INCLUDE_DIRS ${NITE_INCLUDE_DIR} )
+
+include(FindPackageHandleStandardArgs)
+# handle the QUIETLY and REQUIRED arguments and set ???_FOUND to TRUE
+# if all listed variables are TRUE
+find_package_handle_standard_args(NITE DEFAULT_MSG
+ NITE_LIBRARY NITE_INCLUDE_DIR)
+
+mark_as_advanced(NITE_INCLUDE_DIR NITE_LIBRARY )
@@ -0,0 +1,62 @@
+# - Try to find OpenNI
+# Once done, this will define
+#
+# OpenNI_FOUND - system has OpenNI
+# OpenNI_INCLUDE_DIRS - the OpenNI include directories
+# OpenNI_LIBRARIES - link these to use OpenNI
+
+#include(LibFindMacros)
+
+# Dependencies
+
+# Use pkg-config to get hints about paths
+find_package(PkgConfig)
+pkg_check_modules(OpenNI_PKGCONF OpenNI)
+
+SET(OPENNI_INCLUDE_SEARCH_PATHS ${OpenNI_PKGCONF_INCLUDE_DIRS})
+SET(OPENNI_LIB_SEARCH_PATHS ${OpenNI_PKGCONF_LIBRARY_DIRS})
+
+IF(WIN32)
+ SET(OPENNI_INCLUDE_SEARCH_PATHS "C:/Program Files/OpenNI/Include/" "D:/Program Files/OpenNI/Include/")
+ SET(OPENNI_LIB_SEARCH_PATHS "C:/Program Files/OpenNI/Lib/" "D:/Program Files/OpenNI/Lib/")
+ENDIF(WIN32)
+
+MESSAGE(STATUS "Try to look here: ${OPENNI_INCLUDE_SEARCH_PATHS}")
+
+# Include dir
+find_path(OpenNI_INCLUDE_DIR
+ NAMES XnOpenNI.h
+ HINTS ${OPENNI_INCLUDE_SEARCH_PATHS}
+ PATH_SUFFIXES "ni"
+)
+
+if(OpenNI_INCLUDE_DIR STREQUAL "OpenNI_INCLUDE_DIR-NOTFOUND")
+ message(STATUS "Looking for OpenNI in default dirs")
+ find_path(OpenNI_INCLUDE_DIR NAMES XnOpenNI.h
+ PATH_SUFFIXES "ni"
+ )
+endif()
+
+# Finally the library itself
+find_library(OpenNI_LIBRARY
+ NAMES OpenNI
+ PATHS ${OPENNI_LIB_SEARCH_PATHS}
+)
+
+# Set the include dir variables and the libraries and let libfind_process do the rest.
+# NOTE: Singular variables for this library, plural for libraries this this lib depends on.
+#set(OpenNI_PROCESS_INCLUDES OpenNI_INCLUDE_DIR OpenNI_INCLUDE_DIRS)
+#set(OpenNI_PROCESS_LIBS OpenNI_LIBRARY OpenNI_LIBRARIES)
+#libfind_process(OpenNI)
+
+set(OpenNI_LIBRARIES ${OpenNI_LIBRARY} )
+set(OpenNI_LIBS ${OpenNI_LIBRARY} )
+set(OpenNI_INCLUDE_DIRS ${OpenNI_INCLUDE_DIR} )
+
+include(FindPackageHandleStandardArgs)
+# handle the QUIETLY and REQUIRED arguments and set LIBXML2_FOUND to TRUE
+# if all listed variables are TRUE
+find_package_handle_standard_args(OpenNI DEFAULT_MSG
+ OpenNI_LIBRARY OpenNI_INCLUDE_DIR)
+
+mark_as_advanced(OpenNI_INCLUDE_DIR OpenNI_LIBRARY )
@@ -0,0 +1,99 @@
+# Works the same as find_package, but forwards the "REQUIRED" and "QUIET" arguments
+# used for the current package. For this to work, the first parameter must be the
+# prefix of the current package, then the prefix of the new package etc, which are
+# passed to find_package.
+macro (libfind_package PREFIX)
+ set (LIBFIND_PACKAGE_ARGS ${ARGN})
+ if (${PREFIX}_FIND_QUIETLY)
+ set (LIBFIND_PACKAGE_ARGS ${LIBFIND_PACKAGE_ARGS} QUIET)
+ endif (${PREFIX}_FIND_QUIETLY)
+ if (${PREFIX}_FIND_REQUIRED)
+ set (LIBFIND_PACKAGE_ARGS ${LIBFIND_PACKAGE_ARGS} REQUIRED)
+ endif (${PREFIX}_FIND_REQUIRED)
+ find_package(${LIBFIND_PACKAGE_ARGS})
+endmacro (libfind_package)
+
+# CMake developers made the UsePkgConfig system deprecated in the same release (2.6)
+# where they added pkg_check_modules. Consequently I need to support both in my scripts
+# to avoid those deprecated warnings. Here's a helper that does just that.
+# Works identically to pkg_check_modules, except that no checks are needed prior to use.
+macro (libfind_pkg_check_modules PREFIX PKGNAME)
+ if (${CMAKE_MAJOR_VERSION} EQUAL 2 AND ${CMAKE_MINOR_VERSION} EQUAL 4)
+ include(UsePkgConfig)
+ pkgconfig(${PKGNAME} ${PREFIX}_INCLUDE_DIRS ${PREFIX}_LIBRARY_DIRS ${PREFIX}_LDFLAGS ${PREFIX}_CFLAGS)
+ else (${CMAKE_MAJOR_VERSION} EQUAL 2 AND ${CMAKE_MINOR_VERSION} EQUAL 4)
+ find_package(PkgConfig)
+ if (PKG_CONFIG_FOUND)
+ pkg_check_modules(${PREFIX} ${PKGNAME})
+ endif (PKG_CONFIG_FOUND)
+ endif (${CMAKE_MAJOR_VERSION} EQUAL 2 AND ${CMAKE_MINOR_VERSION} EQUAL 4)
+endmacro (libfind_pkg_check_modules)
+
+# Do the final processing once the paths have been detected.
+# If include dirs are needed, ${PREFIX}_PROCESS_INCLUDES should be set to contain
+# all the variables, each of which contain one include directory.
+# Ditto for ${PREFIX}_PROCESS_LIBS and library files.
+# Will set ${PREFIX}_FOUND, ${PREFIX}_INCLUDE_DIRS and ${PREFIX}_LIBRARIES.
+# Also handles errors in case library detection was required, etc.
+macro (libfind_process PREFIX)
+ # Skip processing if already processed during this run
+ if (NOT ${PREFIX}_FOUND)
+ # Start with the assumption that the library was found
+ set (${PREFIX}_FOUND TRUE)
+
+ # Process all includes and set _FOUND to false if any are missing
+ foreach (i ${${PREFIX}_PROCESS_INCLUDES})
+ if (${i})
+ set (${PREFIX}_INCLUDE_DIRS ${${PREFIX}_INCLUDE_DIRS} ${${i}})
+ mark_as_advanced(${i})
+ else (${i})
+ set (${PREFIX}_FOUND FALSE)
+ endif (${i})
+ endforeach (i)
+
+ # Process all libraries and set _FOUND to false if any are missing
+ foreach (i ${${PREFIX}_PROCESS_LIBS})
+ if (${i})
+ set (${PREFIX}_LIBRARIES ${${PREFIX}_LIBRARIES} ${${i}})
+ mark_as_advanced(${i})
+ else (${i})
+ set (${PREFIX}_FOUND FALSE)
+ endif (${i})
+ endforeach (i)
+
+ # Print message and/or exit on fatal error
+ if (${PREFIX}_FOUND)
+ if (NOT ${PREFIX}_FIND_QUIETLY)
+ message (STATUS "Found ${PREFIX} ${${PREFIX}_VERSION}")
+ endif (NOT ${PREFIX}_FIND_QUIETLY)
+ else (${PREFIX}_FOUND)
+ if (${PREFIX}_FIND_REQUIRED)
+ foreach (i ${${PREFIX}_PROCESS_INCLUDES} ${${PREFIX}_PROCESS_LIBS})
+ message("${i}=${${i}}")
+ endforeach (i)
+ message (FATAL_ERROR "Required library ${PREFIX} NOT FOUND.\nInstall the library (dev version) and try again. If the library is already installed, use ccmake to set the missing variables manually.")
+ endif (${PREFIX}_FIND_REQUIRED)
+ endif (${PREFIX}_FOUND)
+ endif (NOT ${PREFIX}_FOUND)
+endmacro (libfind_process)
+
+macro(libfind_library PREFIX basename)
+ set(TMP "")
+ if(MSVC80)
+ set(TMP -vc80)
+ endif(MSVC80)
+ if(MSVC90)
+ set(TMP -vc90)
+ endif(MSVC90)
+ set(${PREFIX}_LIBNAMES ${basename}${TMP})
+ if(${ARGC} GREATER 2)
+ set(${PREFIX}_LIBNAMES ${basename}${TMP}-${ARGV2})
+ string(REGEX REPLACE "\\." "_" TMP ${${PREFIX}_LIBNAMES})
+ set(${PREFIX}_LIBNAMES ${${PREFIX}_LIBNAMES} ${TMP})
+ endif(${ARGC} GREATER 2)
+ find_library(${PREFIX}_LIBRARY
+ NAMES ${${PREFIX}_LIBNAMES}
+ PATHS ${${PREFIX}_PKGCONF_LIBRARY_DIRS}
+ )
+endmacro(libfind_library)
+

0 comments on commit 9d8a2fc

Please sign in to comment.