Skip to content

Commit c3dba60

Browse files
committed
Allow custom RPATH settings
Package distributors can use RPATH to specify local libusb.
1 parent 369ce88 commit c3dba60

File tree

1 file changed

+17
-1
lines changed

1 file changed

+17
-1
lines changed

examples/protonect/CMakeLists.txt

Lines changed: 17 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -184,7 +184,23 @@ IF(ENABLE_OPENCL)
184184
ENDIF(OPENCL_FOUND)
185185
ENDIF(ENABLE_OPENCL)
186186

187-
SET(CMAKE_INSTALL_RPATH ${LibUSB_LIBDIR})
187+
# RPATH handling for private libusb copies
188+
# Users have two options:
189+
# 1. Build libusb in depends/ and leave it there:
190+
# Do NOT set CMAKE_INSTALL_RPATH. It works by default.
191+
# 2. Build libusb and install it somewhere:
192+
# Set CMAKE_INSTALL_RPATH to the libusb.so installation directory before compiling.
193+
# Both command line -DCMAKE_INSTALL_RPATH=... and CMake GUI settings are accepted.
194+
#
195+
# Anyway if wrong versions of libusb is used, errors will be reported explicitly.
196+
IF(NOT DEFINED CMAKE_INSTALL_RPATH)
197+
SET(CMAKE_INSTALL_RPATH ${LibUSB_LIBDIR} CACHE STRING "Set RPATH for a private libusb")
198+
ELSE()
199+
SET(CMAKE_INSTALL_RPATH ${CMAKE_INSTALL_RPATH} CACHE STRING "Set RPATH for a private libusb")
200+
ENDIF()
201+
IF(DEFINED CMAKE_INSTALL_RPATH)
202+
MESSAGE(STATUS "RPATH set to ${CMAKE_INSTALL_RPATH}")
203+
ENDIF()
188204

189205
CONFIGURE_FILE("${MY_DIR}/include/libfreenect2/config.h.in" "${MY_DIR}/include/libfreenect2/config.h" @ONLY)
190206
GENERATE_RESOURCES(${RESOURCES_INC_FILE} ${MY_DIR} ${RESOURCES})

0 commit comments

Comments
 (0)