From 52ec8cbf32b67ffff03ef2492764d0c78623ebda Mon Sep 17 00:00:00 2001 From: Matthias Goldhoorn Date: Wed, 12 Nov 2014 16:17:08 +0100 Subject: [PATCH] protonect: added install target and use pkg-config to find dependancis The install targets for protonect was missing, now the lib and all headers got installes. Also make it configurable wether the internal-find algorithm should be used, or if it is assumed that the depending libraries (libusb/glfw/glew) are installed in the system. This needs a fix of the include of libusb itself in the headers. All changes should be backward compatible. --- examples/protonect/CMakeLists.txt | 45 ++++++++++++++----- .../protocol/command_transaction.h | 2 +- .../libfreenect2/protocol/usb_control.h | 2 +- .../include/libfreenect2/usb/transfer_pool.h | 2 +- examples/protonect/src/event_loop.cpp | 2 +- examples/protonect/src/libfreenect2.cpp | 2 +- 6 files changed, 39 insertions(+), 16 deletions(-) diff --git a/examples/protonect/CMakeLists.txt b/examples/protonect/CMakeLists.txt index 1441eba65..eb87d1d5d 100644 --- a/examples/protonect/CMakeLists.txt +++ b/examples/protonect/CMakeLists.txt @@ -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 @@ -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 @@ -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 @@ -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) diff --git a/examples/protonect/include/libfreenect2/protocol/command_transaction.h b/examples/protonect/include/libfreenect2/protocol/command_transaction.h index 6994c9104..a4b6d4017 100644 --- a/examples/protonect/include/libfreenect2/protocol/command_transaction.h +++ b/examples/protonect/include/libfreenect2/protocol/command_transaction.h @@ -27,7 +27,7 @@ #ifndef COMMAND_TRANSACTION_H_ #define COMMAND_TRANSACTION_H_ -#include +#include #include namespace libfreenect2 diff --git a/examples/protonect/include/libfreenect2/protocol/usb_control.h b/examples/protonect/include/libfreenect2/protocol/usb_control.h index f42cafed0..65f02c746 100644 --- a/examples/protonect/include/libfreenect2/protocol/usb_control.h +++ b/examples/protonect/include/libfreenect2/protocol/usb_control.h @@ -27,7 +27,7 @@ #ifndef USB_CONTROL_H_ #define USB_CONTROL_H_ -#include +#include namespace libfreenect2 { diff --git a/examples/protonect/include/libfreenect2/usb/transfer_pool.h b/examples/protonect/include/libfreenect2/usb/transfer_pool.h index 8346da902..fd5312445 100644 --- a/examples/protonect/include/libfreenect2/usb/transfer_pool.h +++ b/examples/protonect/include/libfreenect2/usb/transfer_pool.h @@ -27,7 +27,7 @@ #ifndef TRANSFER_POOL_H_ #define TRANSFER_POOL_H_ -#include +#include #include diff --git a/examples/protonect/src/event_loop.cpp b/examples/protonect/src/event_loop.cpp index bd89ce8ce..434a28b40 100644 --- a/examples/protonect/src/event_loop.cpp +++ b/examples/protonect/src/event_loop.cpp @@ -26,7 +26,7 @@ #include -#include +#include #ifdef _WIN32 #include #else diff --git a/examples/protonect/src/libfreenect2.cpp b/examples/protonect/src/libfreenect2.cpp index ea984f4ac..4b411b056 100644 --- a/examples/protonect/src/libfreenect2.cpp +++ b/examples/protonect/src/libfreenect2.cpp @@ -27,7 +27,7 @@ #include #include #include -#include +#include #include