Skip to content

protonect: added install target and use pkg-config to find dependancis #90

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

Closed
wants to merge 1 commit into from
Closed
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
45 changes: 34 additions & 11 deletions examples/protonect/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,8 @@ CMAKE_MINIMUM_REQUIRED(VERSION 2.6)
PROJECT(libfreenect2)
SET(CMAKE_BUILD_TYPE RelWithDebInfo)

SET(USE_DEPS_EXTERNAL "false" CACHE BOOL "Define wether we should use the deps external or use pkg_config to find them")

SET(MY_DIR ${libfreenect2_SOURCE_DIR})

# additional cmake modules
Expand All @@ -26,17 +28,35 @@ FIND_PACKAGE(OpenCV REQUIRED)
# OpenCV
INCLUDE_DIRECTORIES(${OpenCV_INCLUDE_DIR})

# LibUSB
INCLUDE_DIRECTORIES("${MY_DIR}/../../depends/libusb/include/libusb-1.0/")
LINK_DIRECTORIES("${MY_DIR}/../../depends/libusb/lib/")

# GLEW
INCLUDE_DIRECTORIES("${MY_DIR}/../../depends/glew/include/")
if (APPLE)
LINK_DIRECTORIES("${MY_DIR}/../../depends/glew/lib/")
if(USE_DEPS_EXTERNAL)
include(FindPkgConfig)
pkg_check_modules(libusb REQUIRED "libusb")
pkg_check_modules(GLFW REQUIRED "glfw3")
pkg_check_modules(GLEW REQUIRED "glew")
INCLUDE_DIRECTORIES(${libusb_INCLUDE_DIRS})
LINK_DIRECTORIES(${libusb_LIBDIR})

INCLUDE_DIRECTORIES(${GLFW_INCLUDE_DIRS})
LINK_DIRECTORIES(${GLFW_LIBRARY_DIRS})

INCLUDE_DIRECTORIES(${GLFEW_INCLUDE_DIRS})
LINK_DIRECTORIES(${GLEW_LIBRARY_DIRS})
else()
LINK_DIRECTORIES("${MY_DIR}/../../depends/glew/lib64/")
endif()
INCLUDE_DIRECTORIES("${MY_DIR}/../../depends/libusb/include/")
LINK_DIRECTORIES("${MY_DIR}/../../depends/libusb/lib/")

# GLEW
INCLUDE_DIRECTORIES("${MY_DIR}/../../depends/glew/include/")
if (APPLE)
LINK_DIRECTORIES("${MY_DIR}/../../depends/glew/lib/")
else()
LINK_DIRECTORIES("${MY_DIR}/../../depends/glew/lib64/")
endif()
ADD_SUBDIRECTORY(${MY_DIR}/../../depends/glfw_src/ ${MY_DIR}/../../depends/glfw)
INCLUDE_DIRECTORIES(${MY_DIR}/../../depends/glfw_src/include/)
endif() # USE_DEPS_EXTERNAL

ADD_DEFINITIONS(-DGLEW_MX -DGLEW_STATIC)

# GLFW
Expand All @@ -45,8 +65,6 @@ SET(GLFW_BUILD_EXAMPLES OFF CACHE BOOL "Build the GLFW example programs")
SET(GLFW_BUILD_TESTS OFF CACHE BOOL "Build the GLFW test programs")
SET(GLFW_BUILD_DOCS OFF CACHE BOOL "Build the GLFW documentation")

ADD_SUBDIRECTORY(${MY_DIR}/../../depends/glfw_src/ ${MY_DIR}/../../depends/glfw)
INCLUDE_DIRECTORIES(${MY_DIR}/../../depends/glfw_src/include/)

if (APPLE)
# libjpeg-turbo
Expand Down Expand Up @@ -121,3 +139,8 @@ ADD_EXECUTABLE(Protonect
TARGET_LINK_LIBRARIES(Protonect
freenect2
)


INSTALL(TARGETS Protonect RUNTIME DESTINATION bin)
INSTALL(TARGETS freenect2 LIBRARY DESTINATION lib)
INSTALL(DIRECTORY include/libfreenect2 DESTINATION include)
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@
#ifndef COMMAND_TRANSACTION_H_
#define COMMAND_TRANSACTION_H_

#include <libusb.h>
#include <libusb-1.0/libusb.h>
#include <libfreenect2/protocol/command.h>

namespace libfreenect2
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@
#ifndef USB_CONTROL_H_
#define USB_CONTROL_H_

#include <libusb.h>
#include <libusb-1.0/libusb.h>

namespace libfreenect2
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@
#ifndef TRANSFER_POOL_H_
#define TRANSFER_POOL_H_

#include <libusb.h>
#include <libusb-1.0/libusb.h>
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Any reason why you have to include libusb-1.0 - what happend if the library is named otherwise eventually :) ?

My path to libusb.h is "C:\libraries\libusbx\libusb", so that wouldn't work on my install.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

On 18.11.2014 09:29, Lars wrote:

In examples/protonect/include/libfreenect2/usb/transfer_pool.h:

@@ -27,7 +27,7 @@
#ifndef TRANSFER_POOL_H_
#define TRANSFER_POOL_H_

-#include <libusb.h>
+#include <libusb-1.0/libusb.h>

Any reason why you have to include libusb-1.0 - what happend if the
library is named otherwise eventually :) ?

My path to libusb.h is "C:\libraries\libusbx\libusb", so that
wouldn't work on my install.

In the past the libusb-1.0 was fixed given in the CMakeLists.
The package-config returns the patch to /usr/include and not to
/usr/include/libusb-1.0/
(which is the corretct way).

For compatibility i could extend the include-path in the CMakeLists
instead inside the headers, but this is not the way as headers should be
handeled or installed.


Reply to this email directly or view it on GitHub
https://github.com/OpenKinect/libfreenect2/pull/90/files#r20491420.


#include <deque>

Expand Down
2 changes: 1 addition & 1 deletion examples/protonect/src/event_loop.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@

#include <libfreenect2/usb/event_loop.h>

#include <libusb.h>
#include <libusb-1.0/libusb.h>
#ifdef _WIN32
#include <winsock.h>
#else
Expand Down
2 changes: 1 addition & 1 deletion examples/protonect/src/libfreenect2.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@
#include <iostream>
#include <vector>
#include <algorithm>
#include <libusb.h>
#include <libusb-1.0/libusb.h>

#include <libfreenect2/libfreenect2.hpp>

Expand Down