Skip to content
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
24 changes: 9 additions & 15 deletions .github/workflows/build-ubuntu.yml
Original file line number Diff line number Diff line change
Expand Up @@ -45,15 +45,10 @@ jobs:
with:
fetch-depth: 0 # Full history for accurate git describe

# CMakePresets.json defines one preset per supported Python (py3.11 … py3.13),
# each configuring an isolated build/cmake-cpython-3XX directory. Derive the
# preset name and its build directory once here; later steps (ctest, coverage,
# test packaging, install) need the directory the preset chose.
- name: Resolve CMake preset
run: |
py="${{ matrix.python_version }}"
echo "CMAKE_PRESET=py${py}" >> "$GITHUB_ENV"
echo "BUILD_DIR=build/cmake-cpython-${py//./}" >> "$GITHUB_ENV"
# One build directory per job; later steps (ctest, coverage, test packaging,
# install) all refer to it through BUILD_DIR.
- name: Resolve build directory
run: echo "BUILD_DIR=build" >> "$GITHUB_ENV"

- name: Install uv
uses: ./.github/actions/setup-uv
Expand Down Expand Up @@ -113,9 +108,9 @@ jobs:
path: |
~/vcpkg
${{ env.BUILD_DIR }}/vcpkg_installed
key: vcpkg-${{ runner.os }}-${{ runner.arch }}-${{ env.CMAKE_PRESET }}-${{ env.VCPKG_COMMIT }}-${{ hashFiles('cmake/DepthAIVcpkgManifest.cmake') }}
key: vcpkg-${{ runner.os }}-${{ runner.arch }}-py${{ matrix.python_version }}-${{ env.VCPKG_COMMIT }}-${{ hashFiles('cmake/DepthAIVcpkgManifest.cmake') }}
restore-keys: |
vcpkg-${{ runner.os }}-${{ runner.arch }}-${{ env.CMAKE_PRESET }}-${{ env.VCPKG_COMMIT }}-
vcpkg-${{ runner.os }}-${{ runner.arch }}-py${{ matrix.python_version }}-${{ env.VCPKG_COMMIT }}-

- name: Setup vcpkg
run: |
Expand Down Expand Up @@ -152,9 +147,8 @@ jobs:
)
fi

# The preset supplies ISAAC_TELEOP_PYTHON_VERSION and the per-Python
# build directory; everything else is a command-line -D override.
cmake --preset "${CMAKE_PRESET}" \
cmake -B "${BUILD_DIR}" \
-DISAAC_TELEOP_PYTHON_VERSION=${{ matrix.python_version }} \
-DCMAKE_BUILD_TYPE=${{ matrix.build_type }} \
-DCMAKE_C_COMPILER_LAUNCHER=ccache \
-DCMAKE_CXX_COMPILER_LAUNCHER=ccache \
Expand All @@ -167,7 +161,7 @@ jobs:
"${coverage_args[@]}"

- name: Build
run: cmake --build --preset "${CMAKE_PRESET}" --parallel 4
run: cmake --build "${BUILD_DIR}" --parallel 4

- name: ccache stats
run: ccache --show-stats
Expand Down
22 changes: 7 additions & 15 deletions .github/workflows/build-windows.yml
Original file line number Diff line number Diff line change
Expand Up @@ -25,11 +25,8 @@ jobs:

env:
SCCACHE_GHA_ENABLED: "true"
# CMakePresets.json preset used to configure/build, and the build directory
# it selects. Windows has no Python matrix, so it pins the CMakeLists
# default (3.11); keep the two in sync if that changes.
CMAKE_PRESET: py3.11
BUILD_DIR: build/cmake-cpython-311
# Windows has no Python matrix, so it takes the CMakeLists default (3.11).
BUILD_DIR: build

strategy:
matrix:
Expand All @@ -55,18 +52,16 @@ jobs:
# vcpkg - required when BUILD_PLUGIN_OAK_CAMERA=ON for DepthAI v3.x deps
#
# vcpkg installs manifest ports into ${CMAKE_BINARY_DIR}/vcpkg_installed, so
# this path tracks the preset's build directory. The preset is part of the key
# for the same reason: an entry saved from a different build directory would
# restore to a path this job never reads.
# this path tracks the build directory.
- name: Cache vcpkg
uses: actions/cache@55cc8345863c7cc4c66a329aec7e433d2d1c52a9 # v6.1.0
with:
path: |
C:\vcpkg
${{ env.BUILD_DIR }}/vcpkg_installed
key: vcpkg-${{ runner.os }}-${{ env.CMAKE_PRESET }}-${{ hashFiles('cmake/DepthAIVcpkgManifest.cmake') }}
key: vcpkg-${{ runner.os }}-${{ hashFiles('cmake/DepthAIVcpkgManifest.cmake') }}
restore-keys: |
vcpkg-${{ runner.os }}-${{ env.CMAKE_PRESET }}-
vcpkg-${{ runner.os }}-

- name: Setup vcpkg
run: |
Expand Down Expand Up @@ -104,14 +99,11 @@ jobs:

- name: Configure CMake
# Note:
# The py3.11 preset selects Python 3.11 (the CMakeLists default) and the
# build/cmake-cpython-311 build directory; the generator and the flags below
# are command-line additions on top of it.
# sccache does not work with VSBuild, so we use Ninja generator here.
# -G Ninja would pickup mingw64 by default on Windows, so we explicitly set the compiler to cl.exe
# Force embedded debug info (Z7) to avoid PDB contention whenever debug info is generated.
run: >
cmake --preset ${{ env.CMAKE_PRESET }} -G Ninja
cmake -B ${{ env.BUILD_DIR }} -G Ninja
-DCMAKE_BUILD_TYPE=${{ matrix.build_type }}
-DENABLE_EXPERIMENTAL_WINDOWS_BUILD=ON
-DCMAKE_C_COMPILER_LAUNCHER=sccache
Expand All @@ -124,7 +116,7 @@ jobs:
-DCMAKE_TOOLCHAIN_FILE="${{ env.VCPKG_ROOT }}/scripts/buildsystems/vcpkg.cmake"

- name: Build
run: cmake --build --preset ${{ env.CMAKE_PRESET }} --parallel
run: cmake --build ${{ env.BUILD_DIR }} --parallel

- name: Run All Tests
run: ctest --test-dir ${{ env.BUILD_DIR }} --output-on-failure --parallel
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ package-lock.json

# Build directories
build/
build-wheel/
_build/
**/build/
install/
Expand Down
29 changes: 0 additions & 29 deletions CMakePresets.json

This file was deleted.

2 changes: 0 additions & 2 deletions CMakePresets.json.license

This file was deleted.

26 changes: 24 additions & 2 deletions cmake/SetupPython.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,27 @@ isaac_teleop_enforce_python_version(

option(BUILD_PYTHON_BINDINGS "Build Python bindings" ON)

# Build trees configured before this stamp existed hold a bare TRUE. Their version
# is unknowable, so adopt them instead of failing on a value we cannot compare.
if(ISAAC_TELEOP_PYTHON_CONFIGURED STREQUAL "TRUE")
set(ISAAC_TELEOP_PYTHON_CONFIGURED "${ISAAC_TELEOP_PYTHON_VERSION}" CACHE INTERNAL
"Python version this build directory was configured for")
endif()

# Discovery runs once per build tree. Re-running it on a version change would not
# be enough anyway: the NumPy build venv below is keyed to the interpreter it was
# created from. So reject the change and require a fresh directory, rather than
# configuring for one version while compiling extensions against another.
if(ISAAC_TELEOP_PYTHON_CONFIGURED AND
NOT ISAAC_TELEOP_PYTHON_CONFIGURED STREQUAL ISAAC_TELEOP_PYTHON_VERSION)
message(FATAL_ERROR
"This build directory is configured for Python ${ISAAC_TELEOP_PYTHON_CONFIGURED}, "
"but ISAAC_TELEOP_PYTHON_VERSION is now ${ISAAC_TELEOP_PYTHON_VERSION}. The Python "
"version is baked into the CMake cache and the build venv; configure a different "
"build directory instead (cmake -B build-py${ISAAC_TELEOP_PYTHON_VERSION} "
"-DISAAC_TELEOP_PYTHON_VERSION=${ISAAC_TELEOP_PYTHON_VERSION}), or delete this one.")
endif()

# Guard to prevent multiple inclusions from overwriting our settings
if(NOT ISAAC_TELEOP_PYTHON_CONFIGURED)
if(SKBUILD)
Expand Down Expand Up @@ -142,8 +163,9 @@ if(NOT ISAAC_TELEOP_PYTHON_CONFIGURED)
set(PYTHON_INCLUDE_DIRS "${Python3_INCLUDE_DIRS}" CACHE PATH "Python include dirs" FORCE)
set(PYTHON_LIBRARIES "${Python3_LIBRARIES}" CACHE FILEPATH "Python libraries" FORCE)

# Mark as configured to prevent re-running
set(ISAAC_TELEOP_PYTHON_CONFIGURED TRUE CACHE INTERNAL "Python configuration completed")
# Stamp the version, not a bare TRUE, so the guard above can catch a change.
set(ISAAC_TELEOP_PYTHON_CONFIGURED "${ISAAC_TELEOP_PYTHON_VERSION}" CACHE INTERNAL
"Python version this build directory was configured for")
endif()

# ==============================================================================
Expand Down
85 changes: 41 additions & 44 deletions docs/source/getting_started/build_from_source/index.rst
Original file line number Diff line number Diff line change
Expand Up @@ -107,30 +107,28 @@ See :ref:`dedicated-cloudxr-runtime`.
2. CMake: Configure and build
-----------------------------

From the project root, configure with a **preset** — there is one per supported
Python version (``py3.11`` … ``py3.13``; see :code-file:`CMakePresets.json`). A
preset selects the Python version and an isolated per-version build directory, so
different versions never share (and clobber) one configured CMake cache:
From the project root:

.. code-block:: bash

cmake --preset py3.12 # configure
cmake --build --preset py3.12 --parallel # build
cmake --install build/cmake-cpython-312 # install
cmake -B build # configure
cmake --build build --parallel # build
cmake --install build # install

``cmake --preset py3.12`` is shorthand for the explicit configure it expands to —
an isolated build directory plus the Python version:
Add any other options as ``-D`` flags on the configure line, for example
``cmake -B build -DCMAKE_BUILD_TYPE=Debug``.

.. code-block:: bash
.. important::

The Python version is baked into a build directory's CMake cache and its build
venv, so ``ISAAC_TELEOP_PYTHON_VERSION`` cannot be changed on an existing tree —
configuring again with a different value fails with an explanatory error. Give
each version its own directory:

cmake -B build/cmake-cpython-312 -DISAAC_TELEOP_PYTHON_VERSION=3.12
.. code-block:: bash

Add any other options as ``-D`` flags on the same line; a command-line ``-D``
overrides the preset (e.g. ``cmake --preset py3.12 -DCMAKE_BUILD_TYPE=Debug``).
Pick the preset that matches your interpreter rather than overriding
``ISAAC_TELEOP_PYTHON_VERSION`` by hand. (A bare ``cmake -B build`` still works
for a quick default build — Python 3.11 into ``./build`` — but the presets are
the recommended path.)
cmake -B build-py3.12 -DISAAC_TELEOP_PYTHON_VERSION=3.12
cmake --build build-py3.12 --parallel

This will:

Expand All @@ -151,7 +149,7 @@ To disable enforcement, set ``ENABLE_CLANG_FORMAT_CHECK`` to ``OFF``:

.. code-block:: bash

cmake --preset py3.12 -DENABLE_CLANG_FORMAT_CHECK=OFF
cmake -B build -DENABLE_CLANG_FORMAT_CHECK=OFF

Useful targets:

Expand All @@ -160,8 +158,8 @@ Useful targets:

.. code-block:: bash

cmake --build --preset py3.12 --target clang_format_check
cmake --build --preset py3.12 --target clang_format_fix
cmake --build build --target clang_format_check
cmake --build build --target clang_format_fix

Other Build options
~~~~~~~~~~~~~~~~~~~
Expand Down Expand Up @@ -228,55 +226,55 @@ The CMake options (defined in root :code-file:`CMakeLists.txt` and :code-file:`c
Examples
~~~~~~~~

Build for a different Python version — use the matching preset (``py3.11``,
``py3.12``, ``py3.13``):
Build for a different Python version — each needs its own build directory
(``3.11``, ``3.12``, ``3.13`` are supported):

.. code-block:: bash

cmake --preset py3.12
cmake --build --preset py3.12 --parallel
cmake -B build-py3.12 -DISAAC_TELEOP_PYTHON_VERSION=3.12
cmake --build build-py3.12 --parallel

Debug build:

.. code-block:: bash

cmake --preset py3.12 -DCMAKE_BUILD_TYPE=Debug
cmake --build --preset py3.12
cmake -B build -DCMAKE_BUILD_TYPE=Debug
cmake --build build

Build without examples:

.. code-block:: bash

cmake --preset py3.12 -DBUILD_EXAMPLES=OFF
cmake --build --preset py3.12
cmake -B build -DBUILD_EXAMPLES=OFF
cmake --build build

Build without Python bindings:

.. code-block:: bash

cmake --preset py3.12 -DBUILD_PYTHON_BINDINGS=OFF
cmake --build --preset py3.12
cmake -B build -DBUILD_PYTHON_BINDINGS=OFF
cmake --build build

Build with OAK camera plugin (pulls Hunter/DepthAI):

.. code-block:: bash

cmake --preset py3.12 -DBUILD_PLUGIN_OAK_CAMERA=ON
cmake --build --preset py3.12
cmake -B build -DBUILD_PLUGIN_OAK_CAMERA=ON
cmake --build build

Build only the teleop_ros2 example (e.g. for Docker, as in :code-file:`build-ubuntu.yml <.github/workflows/build-ubuntu.yml>` teleop-ros2-docker job):

.. code-block:: bash

cmake --preset py3.12 -DBUILD_EXAMPLES=OFF -DBUILD_EXAMPLE_TELEOP_ROS2=ON
cmake --build --preset py3.12
cmake -B build -DBUILD_EXAMPLES=OFF -DBUILD_EXAMPLE_TELEOP_ROS2=ON
cmake --build build

Clean rebuild (``--fresh`` wipes the preset's CMake cache and reconfigures):
Clean rebuild (``--fresh`` wipes the CMake cache and reconfigures):

.. code-block:: bash

cmake --preset py3.12 --fresh
cmake --build --preset py3.12
cmake -B build --fresh
cmake --build build

3. Running tests
----------------
Expand All @@ -285,10 +283,10 @@ When ``BUILD_TESTING`` is ``ON``, CTest is enabled at the top level. Run all tes

.. code-block:: bash

cmake --build --preset py3.12 --target test
cmake --build build --target test

# Or with ctest (e.g. parallel, output on failure)
ctest --test-dir build/cmake-cpython-312 --output-on-failure --parallel
ctest --test-dir build --output-on-failure --parallel

The CI uses ``ctest`` (see :code-file:`build-ubuntu.yml <.github/workflows/build-ubuntu.yml>`).

Expand Down Expand Up @@ -327,12 +325,11 @@ the released wheels) is unchanged, so the two coexist.

.. note::

The CMake build tree is kept under ``build/wheel-<cache-tag>/`` (e.g.
``build/wheel-cpython-311/``) — one per Python version, so different
The CMake build tree is kept under ``build-wheel/<cache-tag>/`` (e.g.
``build-wheel/cpython-311/``) — one per Python version, so different
interpreters never share a configured CMake cache — instead of a temporary
directory. Re-installs are therefore incremental. The classic CMake path uses
sibling ``build/cmake-<cache-tag>/`` trees (via the presets below) with the same
per-version tag, so the two never collide; ``build/`` is gitignored.
directory. Re-installs are therefore incremental. It sits outside ``build/``, so
it never collides with a classic ``cmake -B build`` tree. Both are gitignored.

What this path does and how it differs from the classic flow:

Expand Down
Loading
Loading