Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

OpenNI2 pkg_config replaced with find script from PCL. #39

Open
wants to merge 3 commits into
base: ros1
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
30 changes: 15 additions & 15 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,16 +1,14 @@
cmake_minimum_required(VERSION 2.8.3)
project(openni2_camera)

set(CMAKE_MODULE_PATH ${CMAKE_CURRENT_SOURCE_DIR}/cmake)

find_package(catkin REQUIRED camera_info_manager dynamic_reconfigure image_transport nodelet sensor_msgs roscpp message_generation)

find_package(Boost REQUIRED COMPONENTS system thread)

find_package(PkgConfig)
find_package(OpenNI2 REQUIRED)

pkg_check_modules(PC_OPENNI2 libopenni2)
if (NOT PC_OPENNI2_FOUND)
pkg_check_modules(PC_OPENNI2 REQUIRED openni2)
endif()

generate_dynamic_reconfigure_options(cfg/OpenNI2.cfg)
add_service_files(FILES
Expand All @@ -26,12 +24,10 @@ catkin_package(

include_directories(include
${catkin_INCLUDE_DIRS}
${Boost_INCLUDE_DIRS}
${PC_OPENNI2_INCLUDE_DIRS}
${Boost_ICLUDE_DIRS}
${OPENNI2_INCLUDE_DIRS}
)

link_directories(${PC_OPENNI2_LIBRARY_DIRS})

add_library(openni2_wrapper
src/openni2_convert.cpp
src/openni2_device.cpp
Expand All @@ -42,33 +38,37 @@ add_library(openni2_wrapper
src/openni2_exception.cpp
src/openni2_video_mode.cpp
)
target_link_libraries(openni2_wrapper ${catkin_LIBRARIES} ${PC_OPENNI2_LIBRARIES} ${Boost_LIBRARIES} )
target_link_libraries(openni2_wrapper
${catkin_LIBRARIES}
${OPENNI2_LIBRARIES}
${Boost_LIBRARIES}
)

add_executable(test_wrapper test/test_wrapper.cpp )
target_link_libraries(test_wrapper openni2_wrapper ${Boost_LIBRARIES})
target_link_libraries(test_wrapper openni2_wrapper ${Boost_LIBRARIES} ${OPENNI2_LIBRARIES})

add_library(openni2_driver_lib
src/openni2_driver.cpp
)
target_link_libraries(openni2_driver_lib openni2_wrapper ${catkin_LIBRARIES} ${Boost_LIBRARIES} )
target_link_libraries(openni2_driver_lib openni2_wrapper ${catkin_LIBRARIES} ${Boost_LIBRARIES} ${OPENNI2_LIBRARIES})
add_dependencies(openni2_driver_lib ${PROJECT_NAME}_gencfg ${PROJECT_NAME}_generate_messages_cpp)

add_library(openni2_camera_nodelet
ros/openni2_camera_nodelet.cpp
)
target_link_libraries(openni2_camera_nodelet openni2_driver_lib ${catkin_LIBRARIES} ${Boost_LIBRARIES} )
target_link_libraries(openni2_camera_nodelet openni2_driver_lib ${catkin_LIBRARIES} ${Boost_LIBRARIES} ${OPENNI2_LIBRARIES})
add_dependencies(openni2_camera_nodelet ${PROJECT_NAME}_gencfg)

add_executable(openni2_camera_node
ros/openni2_camera_node.cpp
)
target_link_libraries(openni2_camera_node openni2_driver_lib ${catkin_LIBRARIES} ${Boost_LIBRARIES} )
target_link_libraries(openni2_camera_node openni2_driver_lib ${catkin_LIBRARIES} ${Boost_LIBRARIES} ${OPENNI2_LIBRARIES})
add_dependencies(openni2_camera_node ${PROJECT_NAME}_gencfg ${PROJECT_NAME}_generate_messages_cpp)

add_executable(list_devices
src/list_devices.cpp
)
target_link_libraries(list_devices openni2_wrapper)
target_link_libraries(list_devices openni2_wrapper ${OPENNI2_LIBRARIES})

if (UNIX AND NOT APPLE)
add_executable(usb_reset src/usb_reset.c)
Expand Down
80 changes: 80 additions & 0 deletions cmake/FindOpenNI2.cmake
Original file line number Diff line number Diff line change
@@ -0,0 +1,80 @@
###############################################################################
# Find OpenNI 2
#
# This sets the following variables:
# OPENNI2_FOUND - True if OPENNI 2 was found.
# OPENNI2_INCLUDE_DIRS - Directories containing the OPENNI 2 include files.
# OPENNI2_LIBRARIES - Libraries needed to use OPENNI 2.
# OPENNI2_DEFINITIONS - Compiler flags for OPENNI 2.
#
# For libusb-1.0, add USB_10_ROOT if not found

find_package(PkgConfig QUIET)

# Find LibUSB
if(NOT WIN32)
pkg_check_modules(PC_USB_10 libusb-1.0)
find_path(USB_10_INCLUDE_DIR libusb-1.0/libusb.h
HINTS ${PC_USB_10_INCLUDEDIR} ${PC_USB_10_INCLUDE_DIRS} "${USB_10_ROOT}" "$ENV{USB_10_ROOT}"
PATH_SUFFIXES libusb-1.0)

find_library(USB_10_LIBRARY
NAMES usb-1.0
HINTS ${PC_USB_10_LIBDIR} ${PC_USB_10_LIBRARY_DIRS} "${USB_10_ROOT}" "$ENV{USB_10_ROOT}"
PATH_SUFFIXES lib)

include(FindPackageHandleStandardArgs)
find_package_handle_standard_args(USB_10 DEFAULT_MSG USB_10_LIBRARY USB_10_INCLUDE_DIR)

if(NOT USB_10_FOUND)
message(STATUS "OpenNI 2 disabled because libusb-1.0 not found.")
return()
else()
include_directories(SYSTEM ${USB_10_INCLUDE_DIR})
endif()
endif(NOT WIN32)

if(${CMAKE_VERSION} VERSION_LESS 2.8.2)
pkg_check_modules(PC_OPENNI2 libopenni2)
else()
pkg_check_modules(PC_OPENNI2 QUIET libopenni2)
endif()

set(OPENNI2_DEFINITIONS ${PC_OPENNI_CFLAGS_OTHER})

set(OPENNI2_SUFFIX)
if(WIN32 AND CMAKE_SIZEOF_VOID_P EQUAL 8)
set(OPENNI2_SUFFIX 64)
endif(WIN32 AND CMAKE_SIZEOF_VOID_P EQUAL 8)

find_path(OPENNI2_INCLUDE_DIRS OpenNI.h
PATHS
"$ENV{OPENNI2_INCLUDE${OPENNI2_SUFFIX}}" # Win64 needs '64' suffix
/usr/include/openni2 # common path for deb packages
)

find_library(OPENNI2_LIBRARY
NAMES OpenNI2 # No suffix needed on Win64
libOpenNI2 # Linux
PATHS "$ENV{OPENNI2_LIB${OPENNI2_SUFFIX}}" # Windows default path, Win64 needs '64' suffix
"$ENV{OPENNI2_REDIST}" # Linux install does not use a separate 'lib' directory
)

if(CMAKE_SYSTEM_NAME STREQUAL "Darwin")
set(OPENNI2_LIBRARIES ${OPENNI2_LIBRARY} ${LIBUSB_1_LIBRARIES})
else()
set(OPENNI2_LIBRARIES ${OPENNI2_LIBRARY})
endif()

include(FindPackageHandleStandardArgs)
find_package_handle_standard_args(OpenNI2 DEFAULT_MSG OPENNI2_LIBRARY OPENNI2_INCLUDE_DIRS)

mark_as_advanced(OPENNI2_LIBRARY OPENNI2_INCLUDE_DIRS)

if(OPENNI2_FOUND)
# Add the include directories
set(OPENNI2_INCLUDE_DIRS ${OPENNI2_INCLUDE_DIR})
set(OPENNI2_REDIST_DIR $ENV{OPENNI2_REDIST${OPENNI2_SUFFIX}})
message(STATUS "OpenNI 2 found (include: ${OPENNI2_INCLUDE_DIRS}, lib: ${OPENNI2_LIBRARY}, redist: ${OPENNI2_REDIST_DIR})")
endif(OPENNI2_FOUND)

2 changes: 1 addition & 1 deletion include/openni2_camera/openni2_convert.h
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@
#include "openni2_camera/openni2_device_info.h"
#include "openni2_camera/openni2_video_mode.h"

#include "OpenNI.h"
#include "ni2/OpenNI.h"

#include <vector>

Expand Down
2 changes: 1 addition & 1 deletion include/openni2_camera/openni2_frame_listener.h
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@

#include <vector>

#include "OpenNI.h"
#include "ni2/OpenNI.h"

namespace openni2_wrapper
{
Expand Down
2 changes: 1 addition & 1 deletion include/openni2_camera/openni2_timer_filter.h
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@

#include <deque>

#include "OpenNI.h"
#include "ni2/OpenNI.h"

namespace openni2_wrapper
{
Expand Down
2 changes: 1 addition & 1 deletion src/openni2_device.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@
* Author: Julius Kammerl ([email protected])
*/

#include "OpenNI.h"
#include "ni2/OpenNI.h"
#include <PS1080.h> // For XN_STREAM_PROPERTY_EMITTER_DCMOS_DISTANCE property

#include <boost/lexical_cast.hpp>
Expand Down
2 changes: 1 addition & 1 deletion src/openni2_device_manager.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@
#include <set>
#include <string>

#include "OpenNI.h"
#include "ni2/OpenNI.h"

namespace openni2_wrapper
{
Expand Down
2 changes: 1 addition & 1 deletion src/openni2_frame_listener.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@
*
* Author: Julius Kammerl ([email protected])
*/
#include "OpenNI.h"
#include "ni2/OpenNI.h"

#include "openni2_camera/openni2_frame_listener.h"
#include "openni2_camera/openni2_timer_filter.h"
Expand Down