Skip to content

Conversation

@baikiet
Copy link

@baikiet baikiet commented Jan 22, 2026

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

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 thp#510
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant