Skip to content

build: add project C++ warning set with opt-in warnings-as-errors - #882

Draft
maxwbuckley wants to merge 1 commit into
NVIDIA:mainfrom
maxwbuckley:chore/cpp-compiler-warnings
Draft

build: add project C++ warning set with opt-in warnings-as-errors#882
maxwbuckley wants to merge 1 commit into
NVIDIA:mainfrom
maxwbuckley:chore/cpp-compiler-warnings

Conversation

@maxwbuckley

@maxwbuckley maxwbuckley commented Aug 4, 2026

Copy link
Copy Markdown

Description

Adds cmake/CompilerWarnings.cmake, included from the root CMakeLists.txt after
add_subdirectory(deps). Directory-scope compile options are only inherited by
subdirectories added after the call, so first-party targets get the flags while the
third-party trees (OpenXR SDK, yaml-cpp, pybind11, mcap, flatbuffers, Catch2) keep
their own.

Flags on GNU/Clang: -Wall -Wextra -Wno-missing-field-initializers -Wnon-virtual-dtor -Woverloaded-virtual -Wimplicit-fallthrough -Wextra-semi. MSVC gets /W4 /permissive-.
Two options: ISAAC_TELEOP_ENABLE_WARNINGS (ON) and ISAAC_TELEOP_WARNINGS_AS_ERRORS
(OFF, opt in per build/CI).

Ordering handles deps/, but not a tree fetched from inside an already-flagged
directory: a subdirectory snapshots COMPILE_OPTIONS at the point it is added, so what
the plugins pull in via FetchContent would inherit our flags. The OAK plugin fetches
DepthAI, which fetches XLink, and XLink does not build at -Wall -Wextra -Werror — it
sets -Wno-unused-parameter for itself precisely because it does not hold to that. Two
mechanisms keep our flags out:

  • isaac_teleop_third_party_scope_begin()/_end() clear the calling directory's
    COMPILE_OPTIONS across the add_subdirectory()/FetchContent_MakeAvailable() and
    restore them afterwards, so the fetched tree builds with its own flags while
    first-party targets later in the same file still get ours. Used for DepthAI and SDL2
    in the OAK plugin, and nlohmann/json in OGLO.
  • isaac_teleop_mark_include_dirs_system() moves a dependency's interface includes to
    -isystem, because a warning raised inside a header is attributed to the first-party
    TU that included it — DepthAI's headers alone accounted for 128 -Wextra-semi hits in
    our own sources. (add_subdirectory(... SYSTEM) does this in one step but needs CMake
    3.25; the project floor is 3.20.)

Fixes everything the set surfaced on first-party code:

  • properties.serial is a fixed char[256], never a pointer, so the
    properties.serial ? ... : "" guard was always-true dead code
    (-Wpointer-bool-conversion, 3 sites). Replaced with a strnlen-bounded
    std::string construction, which additionally guards against a runtime that fills
    the array without a terminator.
  • Removed the empty, unused print_xdev_info (-Wunused-function).
  • Commented out the unused argc parameter name in six main() definitions.
  • oak_camera.cpp called the deprecated dai::DeviceInfo::getMxId()
    (-Wdeprecated-declarations); the same file already used getDeviceId() in the two
    neighbouring call sites.

robstride_bus's private members are used only inside #ifdef __linux__, so Clang
reports them unused when the file compiles to its throwing stub. That warning is
correct but unactionable off Linux (GCC has no equivalent), so it is suppressed for
that one target on non-Linux only.

C++/CMake only — no Python is touched. A companion PR configures the ruff lint rules
for the Python side; the two are independent and can land in either order.

Type of change

  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to change)
  • Documentation update

Testing

GCC 13.3 / x86_64, Ubuntu 24.04, RTX PRO 6000 Blackwell, CUDA 13.0

cmake --preset py3.12 -DCMAKE_BUILD_TYPE=Release -DISAAC_TELEOP_WARNINGS_AS_ERRORS=ON
cmake --build --preset py3.12 --parallel 24 --clean-first
  • 339 first-party TUs, zero warnings, clean under -Werror, with
    BUILD_PLUGIN_OGLO=ON and BUILD_PLUGIN_NOITOM_MOCAP=ON. This includes
    rebot_devarm_leader on its real SocketCAN path (so the -Wno-unused-private-field
    suppression above is confirmed to be needed only off Linux), and the whole Televiz
    tree with BUILD_VIZ auto-ON (Vulkan + CUDA + glslang all present).
  • BUILD_PLUGIN_OAK_CAMERA=ON (vcpkg toolchain) also builds clean under -Werror.
    Verified from the generated flags.make that the containment cuts in one direction
    only: camera_plugin_oak gets the full project set including -Werror and reaches
    DepthAI's headers via -isystem, while depthai-core and XLink compile with their
    own upstream warning flags and none of ours. Before the containment this configuration
    failed with 41 errors inside xlink-src.
  • ctest: 309/310. The one failure, cloudxr_test_launcher, is the missing CloudXR SDK
    (no NGC key on this host, so the download 404s and get_sdk_path() raises) — an
    environment gap, not a code failure.
  • SKIP=check-copyright-year pre-commit run --all-files: all hooks pass.

MSVC is unvalidated, so CI is deliberately left at the ISAAC_TELEOP_WARNINGS_AS_ERRORS
OFF default.

Checklist

  • I have read and understood the contribution guidelines
  • I have run the linter and formatter with SKIP=check-copyright-year pre-commit run --all-files
  • I have made corresponding changes to the documentation
  • I have added tests that prove my fix/feature works (or explained why not)
  • I have signed off all my commits (git commit -s) per the DCO

Documentation: no user-facing behaviour changes, so no doc updates. The two new CMake
options are documented in the header comment of cmake/CompilerWarnings.cmake.

Tests: no new tests — this is a build-configuration change, and it is exercised by the
existing suite building and passing under -Werror on both toolchains above.

@coderabbitai

coderabbitai Bot commented Aug 4, 2026

Copy link
Copy Markdown
Contributor

Important

Review skipped

Draft detected.

Please check the settings in the CodeRabbit UI or the .coderabbit.yaml file in this repository. To trigger a single review, invoke the @coderabbitai review command.

⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Enterprise

Run ID: 76c4bb2f-4f54-45f5-8656-d5990e0caa88

You can disable this status message by setting the reviews.review_status to false in the CodeRabbit configuration file.

Use the checkbox below for a quick retry:

  • 🔍 Trigger review

Comment @coderabbitai help to get the list of available commands.

@github-actions

github-actions Bot commented Aug 4, 2026

Copy link
Copy Markdown
Contributor

📝 Docs preview is not auto-deployed for fork PRs.

A maintainer with write access to NVIDIA/IsaacTeleop can deploy a preview by
commenting /preview-docs on this PR. Once deployed, the preview
will live at:

https://nvidia.github.io/IsaacTeleop/preview/pr-882/

Adds cmake/CompilerWarnings.cmake, included from the root CMakeLists.txt
*after* add_subdirectory(deps). Directory-scope compile options are only
inherited by subdirectories added after the call, so first-party targets get
the flags while third-party trees (OpenXR SDK, yaml-cpp, pybind11, mcap,
flatbuffers, Catch2) keep their own.

Flags on GNU/Clang: -Wall -Wextra -Wno-missing-field-initializers
-Wnon-virtual-dtor -Woverloaded-virtual -Wimplicit-fallthrough -Wextra-semi.
MSVC gets /W4 /permissive-. Two options: ISAAC_TELEOP_ENABLE_WARNINGS (ON)
and ISAAC_TELEOP_WARNINGS_AS_ERRORS (OFF, opt in per build/CI).

Ordering handles deps/, but not a tree fetched from *inside* an already-flagged
directory: a subdirectory snapshots COMPILE_OPTIONS at the point it is added, so
what the plugins pull in via FetchContent would inherit our flags. The OAK plugin
fetches DepthAI, which fetches XLink, and XLink does not build at -Wall -Wextra
-Werror — it sets -Wno-unused-parameter for itself precisely because it does not
hold to that. Two mechanisms keep it out:

- isaac_teleop_third_party_scope_begin()/_end() clear the calling directory's
  COMPILE_OPTIONS across the add_subdirectory()/FetchContent_MakeAvailable() and
  restore them afterwards, so the fetched tree builds with its own flags while
  first-party targets later in the same file still get ours. Used for DepthAI and
  SDL2 in the OAK plugin, and nlohmann/json in OGLO.
- isaac_teleop_mark_include_dirs_system() moves a dependency's interface includes
  to -isystem, because a warning raised inside a header is attributed to the
  first-party TU that included it — DepthAI's headers alone accounted for 128
  -Wextra-semi hits in our own sources. (add_subdirectory(... SYSTEM) does this in
  one step but needs CMake 3.25; the project floor is 3.20.)

Fixes everything the set surfaced on first-party code:

- properties.serial is a fixed char[256], never a pointer, so the
  `properties.serial ? ... : ""` guard was always-true dead code
  (-Wpointer-bool-conversion, 3 sites). Replaced with a strnlen-bounded
  std::string construction, which additionally guards against a runtime that
  fills the array without a terminator.
- Removed the empty, unused print_xdev_info (-Wunused-function).
- Commented out the unused argc parameter name in six main() definitions.
- oak_camera.cpp called the deprecated dai::DeviceInfo::getMxId()
  (-Wdeprecated-declarations); the same file already used getDeviceId() in the
  two neighbouring call sites.

robstride_bus's private members are used only inside #ifdef __linux__, so Clang
reports them unused when the file compiles to its throwing stub. That warning is
correct but unactionable off Linux (GCC has no equivalent), so it is suppressed
for that one target on non-Linux only.

Verified on GCC 13.3 / x86_64 (Ubuntu 24.04): clean build of 339 first-party TUs
with ISAAC_TELEOP_WARNINGS_AS_ERRORS=ON and zero warnings, including the OGLO and
Noitom plugins and the Televiz tree; BUILD_PLUGIN_OAK_CAMERA=ON also builds clean
under -Werror, DepthAI and XLink compiling with their own flags throughout. ctest
309/310, the one failure being a missing CloudXR SDK on the host. Not yet
validated on MSVC, so CI is deliberately left at the OFF default.

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
Signed-off-by: Max Buckley <maxwbuckley@gmail.com>
@maxwbuckley
maxwbuckley force-pushed the chore/cpp-compiler-warnings branch from c5900d8 to d8725f2 Compare August 4, 2026 14:12
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants