Skip to content

Add missing cmath include - #320

Open
ethanmusser wants to merge 1 commit into
carnegierobotics:masterfrom
ethanmusser:ethanmusser/bug/missing-cmath-include
Open

ethanmusser wants to merge 1 commit into
carnegierobotics:masterfrom
ethanmusser:ethanmusser/bug/missing-cmath-include

Conversation

@ethanmusser

Copy link
Copy Markdown
Contributor

This header is required due to usage of std::abs in this source file.

See e.g. this failing CI run for the corresponding error, which is as follows.

Processing ./.
  Installing build dependencies: started
  Installing build dependencies: finished with status 'done'
  Getting requirements to build wheel: started
  Getting requirements to build wheel: finished with status 'done'
  Preparing metadata (pyproject.toml): started
  Preparing metadata (pyproject.toml): finished with status 'done'
Building wheels for collected packages: libmultisense
  Building wheel for libmultisense (pyproject.toml): started
  Building wheel for libmultisense (pyproject.toml): finished with status 'error'
  error: subprocess-exited-with-error
  
  × Building wheel for libmultisense (pyproject.toml) did not run successfully.
  │ exit code: 1
  ╰─> [96 lines of output]
      *** scikit-build-core 1.1.0 using CMake 4.4.3 (wheel)
      *** Configuring CMake...
      loading initial cache file /var/folders/36/tjdph2t965j8snz9_vkdnw0r0000gn/T/tmp64epq3l8/build/CMakeInit.txt
      -- The C compiler identification is Clang 23.1.0
      -- The CXX compiler identification is Clang 23.1.0
      -- Detecting C compiler ABI info
      -- Detecting C compiler ABI info - done
      -- Check for working C compiler: /opt/homebrew/opt/llvm/bin/clang - 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: /opt/homebrew/opt/llvm/bin/clang++ - skipped
      -- Detecting CXX compile features
      -- Detecting CXX compile features - done
      -- Performing Test HAVE_STD_FILESYSTEM
      -- Performing Test HAVE_STD_FILESYSTEM - Success
      -- Performing Test HAVE_CONSTEXPR
      -- Performing Test HAVE_CONSTEXPR - Success
      -- Found nlohmann_json: /opt/homebrew/share/cmake/nlohmann_json/nlohmann_jsonConfig.cmake (found suitable version "3.12.0", minimum required is "3.9")
      -- Building JSON serialization helper functions
      -- Looking for vasprintf
      -- Looking for vasprintf - found
      -- Performing Test CMAKE_HAVE_LIBC_PTHREAD
      -- Performing Test CMAKE_HAVE_LIBC_PTHREAD - Success
      -- Found Threads: TRUE
      CMake Warning (author) at /private/var/folders/36/tjdph2t965j8snz9_vkdnw0r0000gn/T/pip-build-env-1xnfh1z_/overlay/lib/python3.14/site-packages/pybind11/share/cmake/pybind11/FindPythonLibsNew.cmake:101 (message):
        Policy CMP0148 is not set: The FindPythonInterp and FindPythonLibs modules
        are removed.  Run "cmake --help-policy CMP0148" for policy details.  Use
        the cmake_policy command to set the policy and suppress this warning, or
        preferably upgrade to using FindPython, either by calling it explicitly
        before pybind11, or by setting PYBIND11_FINDPYTHON ON before pybind11.
      Call Stack (most recent call first):
        /private/var/folders/36/tjdph2t965j8snz9_vkdnw0r0000gn/T/pip-build-env-1xnfh1z_/overlay/lib/python3.14/site-packages/pybind11/share/cmake/pybind11/pybind11Tools.cmake:44 (find_package)
        /private/var/folders/36/tjdph2t965j8snz9_vkdnw0r0000gn/T/pip-build-env-1xnfh1z_/overlay/lib/python3.14/site-packages/pybind11/share/cmake/pybind11/pybind11Common.cmake:243 (include)
        /private/var/folders/36/tjdph2t965j8snz9_vkdnw0r0000gn/T/pip-build-env-1xnfh1z_/overlay/lib/python3.14/site-packages/pybind11/share/cmake/pybind11/pybind11Config.cmake:257 (include)
        python/CMakeLists.txt:4 (find_package)
      This warning is for project developers.  Use -Wno-author to suppress it.
      
      CMake Warning (deprecated) at /private/var/folders/36/tjdph2t965j8snz9_vkdnw0r0000gn/T/pip-build-env-1xnfh1z_/overlay/lib/python3.14/site-packages/pybind11/share/cmake/pybind11/FindPythonLibsNew.cmake:110 (cmake_policy):
        The OLD behavior for policy CMP0148 will be removed from a future version
        of CMake.
      
        The cmake-policies(7) manual explains that the OLD behaviors of all
        policies are deprecated and that a policy should be set to OLD only under
        specific short-term circumstances.  Projects should be ported to the NEW
        behavior and not rely on setting a policy to OLD.
      Call Stack (most recent call first):
        /private/var/folders/36/tjdph2t965j8snz9_vkdnw0r0000gn/T/pip-build-env-1xnfh1z_/overlay/lib/python3.14/site-packages/pybind11/share/cmake/pybind11/pybind11Tools.cmake:44 (find_package)
        /private/var/folders/36/tjdph2t965j8snz9_vkdnw0r0000gn/T/pip-build-env-1xnfh1z_/overlay/lib/python3.14/site-packages/pybind11/share/cmake/pybind11/pybind11Common.cmake:243 (include)
        /private/var/folders/36/tjdph2t965j8snz9_vkdnw0r0000gn/T/pip-build-env-1xnfh1z_/overlay/lib/python3.14/site-packages/pybind11/share/cmake/pybind11/pybind11Config.cmake:257 (include)
        python/CMakeLists.txt:4 (find_package)
      This warning is for project developers.  Use -Wno-author or -Wno-deprecated
      to suppress it.
      
      -- Found PythonInterp: /Users/runner/work/LibMultiSense/LibMultiSense/.venv/bin/python3 (found suitable version "3.14.7", minimum required is "3.9")
      -- Found PythonLibs: /opt/homebrew/opt/[email protected]/Frameworks/Python.framework/Versions/3.14/Python
      -- Performing Test HAS_FLTO_THIN
      -- Performing Test HAS_FLTO_THIN - Success
      -- Performing Test HAS_FLTO
      -- Performing Test HAS_FLTO - Success
      -- Found pybind11: /private/var/folders/36/tjdph2t965j8snz9_vkdnw0r0000gn/T/pip-build-env-1xnfh1z_/overlay/lib/python3.14/site-packages/pybind11/include (found version "3.1.0")
      Building python bindings with json print support
      -- Configuring done (4.0s)
      -- Generating done (0.0s)
      -- Build files have been written to: /var/folders/36/tjdph2t965j8snz9_vkdnw0r0000gn/T/tmp64epq3l8/build
      *** Building project with Ninja...
      [1/20] Building CXX object source/Wire/CMakeFiles/MultiSenseWire.dir/source/utility/TimeStamp.cc.o
      [2/20] Building CXX object source/Wire/CMakeFiles/MultiSenseWire.dir/source/utility/Exception.cc.o
      [3/20] Building CXX object source/LibMultiSense/CMakeFiles/MultiSense.dir/details/factory.cc.o
      [4/20] Linking CXX static library source/Wire/libMultiSenseWire.a
      [5/20] Building CXX object source/LibMultiSense/CMakeFiles/MultiSense.dir/details/multi_channel.cc.o
      [6/20] Building CXX object source/LibMultiSense/CMakeFiles/MultiSense.dir/details/legacy/calibration.cc.o
      FAILED: [code=1] source/LibMultiSense/CMakeFiles/MultiSense.dir/details/legacy/calibration.cc.o
      /opt/homebrew/opt/llvm/bin/clang++ -DCRL_HAVE_CONSTEXPR -DMultiSense_STATIC -I/Users/runner/work/LibMultiSense/LibMultiSense/source/LibMultiSense/include -I/Users/runner/work/LibMultiSense/LibMultiSense/source/Shared -I/Users/runner/work/LibMultiSense/LibMultiSense/source/Wire/include -isystem /opt/homebrew/include -O3 -DNDEBUG -std=gnu++17 -arch arm64 -fPIC -Wall -Wextra -Werror -Wpedantic -Wno-variadic-macros -Wno-gnu-zero-variadic-macro-arguments -MD -MT source/LibMultiSense/CMakeFiles/MultiSense.dir/details/legacy/calibration.cc.o -MF source/LibMultiSense/CMakeFiles/MultiSense.dir/details/legacy/calibration.cc.o.d -o source/LibMultiSense/CMakeFiles/MultiSense.dir/details/legacy/calibration.cc.o -c /Users/runner/work/LibMultiSense/LibMultiSense/source/LibMultiSense/details/legacy/calibration.cc
      /Users/runner/work/LibMultiSense/LibMultiSense/source/LibMultiSense/details/legacy/calibration.cc:48:93: error: no member named 'abs' in namespace 'std'; did you mean 'std::chrono::abs'?
         48 |     if (cal.M[0][0] < 0.1 || cal.M[0][2] < 0.1 || cal.M[1][1] < 0.1 || cal.M[1][2] < 0.1 || std::abs(cal.D[0]) < 1e-10)
            |                                                                                             ^~~~~~~~
            |                                                                                             std::chrono::abs
      /opt/homebrew/Cellar/llvm/23.1.0/bin/../include/c++/v1/__chrono/time_point.h:132:78: note: 'std::chrono::abs' declared here
        132 | [[nodiscard]] inline _LIBCPP_HIDE_FROM_ABI constexpr duration<_Rep, _Period> abs(duration<_Rep, _Period> __d) {
            |                                                                              ^
      /Users/runner/work/LibMultiSense/LibMultiSense/source/LibMultiSense/details/legacy/calibration.cc:48:98: error: no matching function for call to 'abs'
         48 |     if (cal.M[0][0] < 0.1 || cal.M[0][2] < 0.1 || cal.M[1][1] < 0.1 || cal.M[1][2] < 0.1 || std::abs(cal.D[0]) < 1e-10)
            |                                                                                                  ^~~
      /opt/homebrew/Cellar/llvm/23.1.0/bin/../include/c++/v1/__chrono/time_point.h:132:78: note: candidate template ignored: could not match 'duration<_Rep, _Period>' against 'float'
        132 | [[nodiscard]] inline _LIBCPP_HIDE_FROM_ABI constexpr duration<_Rep, _Period> abs(duration<_Rep, _Period> __d) {
            |                                                                              ^
      2 errors generated.
      [7/20] Building CXX object source/LibMultiSense/CMakeFiles/MultiSense.dir/details/utilities.cc.o
      [8/20] Building CXX object source/LibMultiSense/CMakeFiles/MultiSense.dir/details/secondary_application.cc.o
      [9/20] Building CXX object source/LibMultiSense/CMakeFiles/MultiSense.dir/details/legacy/configuration.cc.o
      [10/20] Building CXX object source/LibMultiSense/CMakeFiles/MultiSense.dir/details/legacy/channel.cc.o
      ninja: build stopped: subcommand failed.
      
      *** CMake build failed
      [end of output]
  
  note: This error originates from a subprocess, and is likely not a problem with pip.
  ERROR: Failed building wheel for libmultisense
ERROR: Failed to build one or more wheels
Failed to build libmultisense

This header is required due to usage of `std::abs` in this source file.
@ethanmusser ethanmusser self-assigned this Oct 1, 2026
@ethanmusser ethanmusser added the bug Something isn't working label Oct 1, 2026
@ethanmusser
ethanmusser marked this pull request as ready for review October 1, 2026 20:14
@codecov

codecov Bot commented Oct 1, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.

📢 Thoughts on this report? Let us know!

@ethanmusser
ethanmusser enabled auto-merge (squash) October 5, 2026 16:18
@ethanmusser
ethanmusser disabled auto-merge October 5, 2026 16:18
@ethanmusser
ethanmusser enabled auto-merge (squash) October 5, 2026 16:18
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug Something isn't working

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant