Skip to content

Commit eea5c0c

Browse files
author
Adrien Kunysz
committed
Allow disabling vendoring.
psmoveapi ships its own version of PS3EYEDriver, glm, hidapi and libusb-1.0. It is often desirable for downstream maintainers to use their own version of these packages. However the psmoveapi CMake configuration currently does not allow that. This change introduces a new `PSMOVEAPI_VENDORING` CMake variable which is enabled by default. When it is disabled, we disable all references to the `external/` directory across the build system and we let CMake look for its dependencies in the usual locations. This is still explicitly broken for Windows and Darwin as I have no access to such systems and am not able to test whether this works. Successfully tested on Debian 12.13: ``` $ mkdir build && cd build && cmake -DPSMOVEAPI_VENDORING=OFF .. -- The C compiler identification is GNU 12.2.0 -- The CXX compiler identification is GNU 12.2.0 -- Detecting C compiler ABI info -- Detecting C compiler ABI info - done -- Check for working C compiler: /usr/bin/cc - skipped -- Detecting C compile features -- Detecting C compile features - done -- Detecting CXX compiler ABI info -- Detecting CXX compiler ABI info - done -- Check for working CXX compiler: /usr/bin/c++ - skipped -- Detecting CXX compile features -- Detecting CXX compile features - done -- Found PkgConfig: /usr/bin/pkg-config (found version "1.8.1") -- Performing Test CMAKE_HAVE_LIBC_PTHREAD -- Performing Test CMAKE_HAVE_LIBC_PTHREAD - Success -- Found Threads: TRUE -- Checking for module 'dbus-1' -- Found dbus-1, version 1.14.10 -- Checking for module 'libudev' -- Found libudev, version 252 -- Checking for module 'bluez>=5' -- Found bluez, version 5.66 -- Checking for module 'hidapi-hidraw' -- Found hidapi-hidraw, version 0.13.1 -- Checking for module 'glm' -- Found glm, version 0.9.9.8 Tracker Tracker library: Yes (OpenCV version 4.6.0) Camera control driver: V4L2 Build configuration Debug build: No Library license: BSD (see README.md for details) Additional targets C example apps: Yes NavCon test: Yes (using SDL2 joystick API) -- Configuring done -- Generating done -- Build files have been written to: build $ make [ 3%] Building C object CMakeFiles/psmoveapi.dir/src/psmove.c.o [ 6%] Building C object CMakeFiles/psmoveapi.dir/src/psmove_calibration.c.o [ 9%] Building CXX object CMakeFiles/psmoveapi.dir/src/psmove_orientation.cpp.o [ 12%] Building CXX object CMakeFiles/psmoveapi.dir/src/psmoveapi.cpp.o [ 16%] Building C object CMakeFiles/psmoveapi.dir/src/daemon/moved_monitor_linux.c.o [ 19%] Building CXX object CMakeFiles/psmoveapi.dir/src/daemon/moved_client.cpp.o [ 22%] Building CXX object CMakeFiles/psmoveapi.dir/src/platform/psmove_port_linux.cpp.o [ 25%] Building CXX object CMakeFiles/psmoveapi.dir/src/math/psmove_alignment.cpp.o [ 29%] Building C object CMakeFiles/psmoveapi.dir/src/math/psmove_math.c.o [ 32%] Building CXX object CMakeFiles/psmoveapi.dir/src/math/psmove_quaternion.cpp.o [ 35%] Building C object CMakeFiles/psmoveapi.dir/src/math/psmove_vector.c.o [ 38%] Linking CXX shared library libpsmoveapi.so [ 38%] Built target psmoveapi [ 41%] Building CXX object CMakeFiles/psmoveapi_tracker.dir/src/tracker/psmove_tracker_hue_calibration.cpp.o [ 45%] Building CXX object CMakeFiles/psmoveapi_tracker.dir/src/tracker/psmove_tracker.cpp.o [ 48%] Building CXX object CMakeFiles/psmoveapi_tracker.dir/src/tracker/psmove_fusion.cpp.o [ 51%] Building CXX object CMakeFiles/psmoveapi_tracker.dir/src/tracker/tracker_helpers.cpp.o [ 54%] Building CXX object CMakeFiles/psmoveapi_tracker.dir/src/tracker/camera_control.cpp.o [ 58%] Building CXX object CMakeFiles/psmoveapi_tracker.dir/src/tracker/camera_control_driver.cpp.o [ 61%] Building CXX object CMakeFiles/psmoveapi_tracker.dir/src/tracker/camera_control_layouts.cpp.o [ 64%] Building CXX object CMakeFiles/psmoveapi_tracker.dir/src/tracker/camera_control_driver_v4l2.cpp.o [ 67%] Linking CXX shared library libpsmoveapi_tracker.so [ 67%] Built target psmoveapi_tracker [ 70%] Building CXX object CMakeFiles/psmove.dir/src/utils/psmovecli.cpp.o [ 74%] Linking CXX executable psmove [ 74%] Built target psmove [ 77%] Building C object CMakeFiles/example.dir/examples/c/example.c.o [ 80%] Linking C executable example [ 80%] Built target example [ 83%] Building C object CMakeFiles/multiple.dir/examples/c/multiple.c.o [ 87%] Linking C executable multiple [ 87%] Built target multiple [ 90%] Building CXX object CMakeFiles/example_new_api.dir/examples/c/example_new_api.cpp.o [ 93%] Linking CXX executable example_new_api [ 93%] Built target example_new_api [ 96%] Building CXX object CMakeFiles/test_navcon.dir/examples/c/test_navcon.cpp.o [100%] Linking CXX executable test_navcon [100%] Built target test_navcon ``` As per #510
1 parent b0d50ba commit eea5c0c

4 files changed

Lines changed: 44 additions & 13 deletions

File tree

CMakeLists.txt

Lines changed: 12 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -2,16 +2,20 @@ cmake_minimum_required(VERSION 3.16)
22

33
project(PSMoveAPI)
44

5-
if(NOT EXISTS "${CMAKE_CURRENT_SOURCE_DIR}/external/hidapi/hidapi/hidapi.h")
6-
message(FATAL_ERROR "hidapi not found, did you forget to run 'git submodule update --init'?")
7-
endif()
5+
option(PSMOVEAPI_VENDORING "Vendor dependencies" ON)
86

9-
if(NOT EXISTS "${CMAKE_CURRENT_SOURCE_DIR}/external/libusb-1.0/libusb/libusb.h")
10-
message(FATAL_ERROR "libusb not found, did you forget to run 'git submodule update --init'?")
11-
endif()
7+
if (PSMOVEAPI_VENDORING)
8+
if(NOT EXISTS "${CMAKE_CURRENT_SOURCE_DIR}/external/hidapi/hidapi/hidapi.h")
9+
message(FATAL_ERROR "hidapi not found, did you forget to run 'git submodule update --init'?")
10+
endif()
11+
12+
if(NOT EXISTS "${CMAKE_CURRENT_SOURCE_DIR}/external/libusb-1.0/libusb/libusb.h")
13+
message(FATAL_ERROR "libusb not found, did you forget to run 'git submodule update --init'?")
14+
endif()
1215

13-
if(NOT EXISTS "${CMAKE_CURRENT_SOURCE_DIR}/external/PS3EYEDriver/src/ps3eye.h")
14-
message(FATAL_ERROR "PS3EYEDriver not found, did you forget to run 'git submodule update --init'?")
16+
if(NOT EXISTS "${CMAKE_CURRENT_SOURCE_DIR}/external/PS3EYEDriver/src/ps3eye.h")
17+
message(FATAL_ERROR "PS3EYEDriver not found, did you forget to run 'git submodule update --init'?")
18+
endif()
1519
endif()
1620

1721
# get rid of Visual Studio's default "Debug" and "Release" output directories

cmake/FindUSB1.cmake

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,9 @@ IF (LIBUSB_INCLUDE_DIR AND LIBUSB_LIBRARIES)
2121
set(LIBUSB_FOUND TRUE)
2222

2323
ELSE (LIBUSB_INCLUDE_DIR AND LIBUSB_LIBRARIES)
24+
IF (NOT PSMOVEAPI_VENDORING)
25+
message(FATAL_ERROR "libusb was not found and vendoring is disabled")
26+
ENDIF()
2427
# Because we want to use the static library,
2528
# look locally only.
2629
find_path(LIBUSB_INCLUDE_DIR

src/CMakeLists.txt

Lines changed: 26 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -15,8 +15,11 @@ set(PSMOVEAPI_PLATFORM_SRC) # Container for source files
1515
set(PSMOVEAPI_INSTALL_TARGETS) # Container for build targets to be installed
1616
set(PSMOVEAPI_MATH_SRC) # Container for math related source files
1717

18-
include_directories(${ROOT_DIR}/external/hidapi/hidapi)
19-
include_directories(${ROOT_DIR}/external/glm)
18+
19+
IF(PSMOVEAPI_VENDORING)
20+
include_directories(${ROOT_DIR}/external/hidapi/hidapi)
21+
include_directories(${ROOT_DIR}/external/glm)
22+
ENDIF()
2023
include_directories(${CMAKE_BINARY_DIR})
2124

2225
set(INFO_LICENSE "BSD")
@@ -54,7 +57,11 @@ IF(${CMAKE_SYSTEM_NAME} MATCHES "Darwin")
5457
list(APPEND PSMOVEAPI_REQUIRED_LIBS ${COREFOUNDATION})
5558
list(APPEND PSMOVEAPI_REQUIRED_LIBS ${IOBLUETOOTH})
5659

57-
set(HIDAPI_SRC ${ROOT_DIR}/external/hidapi/mac/hid.c)
60+
IF(PSMOVEAPI_VENDORING)
61+
set(HIDAPI_SRC ${ROOT_DIR}/external/hidapi/mac/hid.c)
62+
ELSE()
63+
message(FATAL_ERROR "disabling vendoring is currently not supported for ${CMAKE_SYSTEM_NAME}")
64+
ENDIF()
5865

5966
list(APPEND PSMOVEAPI_PLATFORM_SRC
6067
${CMAKE_CURRENT_LIST_DIR}/platform/psmove_port_osx.mm)
@@ -69,7 +76,11 @@ IF(${CMAKE_SYSTEM_NAME} MATCHES "Darwin")
6976
ELSEIF(${CMAKE_SYSTEM_NAME} MATCHES "Windows")
7077
list(APPEND PSMOVEAPI_REQUIRED_LIBS setupapi bthprops kernel32 ws2_32 winmm version imm32)
7178

72-
set(HIDAPI_SRC ${ROOT_DIR}/external/hidapi/windows/hid.c)
79+
IF(PSMOVEAPI_VENDORING)
80+
set(HIDAPI_SRC ${ROOT_DIR}/external/hidapi/windows/hid.c)
81+
ELSE()
82+
message(FATAL_ERROR "disabling vendoring is currently not supported for ${CMAKE_SYSTEM_NAME}")
83+
ENDIF()
7384

7485
list(APPEND PSMOVEAPI_PLATFORM_SRC
7586
${CMAKE_CURRENT_LIST_DIR}/platform/psmove_port_windows.c)
@@ -93,7 +104,17 @@ ELSE()
93104
include_directories(${BLUEZ_INCLUDE_DIRS})
94105
list(APPEND PSMOVEAPI_REQUIRED_LIBS ${BLUEZ_LIBRARIES})
95106

96-
set(HIDAPI_SRC ${ROOT_DIR}/external/hidapi/linux/hid.c)
107+
IF(PSMOVEAPI_VENDORING)
108+
set(HIDAPI_SRC ${ROOT_DIR}/external/hidapi/linux/hid.c)
109+
ELSE()
110+
pkg_check_modules(HIDAPI REQUIRED hidapi-hidraw)
111+
include_directories(${HIDAPI_INCLUDE_DIRS})
112+
list(APPEND PSMOVEAPI_REQUIRED_LIBS hidapi-hidraw)
113+
114+
pkg_check_modules(GLM REQUIRED glm)
115+
include_directories(${GLM_INCLUDE_DIRS})
116+
list(APPEND PSMOVEAPI_REQUIRED_LIBS ${GLM_LIBRARIES})
117+
ENDIF()
97118

98119
list(APPEND PSMOVEAPI_PLATFORM_SRC
99120
${CMAKE_CURRENT_LIST_DIR}/platform/psmove_port_linux.cpp)

src/tracker/CMakeLists.txt

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,9 @@ option(PSMOVE_USE_DEBUG_CAPTURE "Always show camera capture input" OFF)
1616

1717

1818
IF(PSMOVE_USE_PS3EYE_DRIVER)
19+
IF(NOT PSMOVEAPI_VENDORING)
20+
message(FATAL_ERROR "disabling vendoring is currently not supported for PS3EYEDriver")
21+
ENDIF()
1922
# PS3EYEDriver is based on GPL'd code
2023
set(INFO_LICENSE "GPL")
2124

0 commit comments

Comments
 (0)