Add Linux Debug, sanitizer jobs, and install smoke tests to CI - Add a debug-and-sanitizers job in linux.yml running on ubuntu-26.04 with gcc-debug (exercising DCHECK and eigen_assert), clang-asan-ubsan, and clang-tsan (testing concurrency primitives under ThreadSanitizer). - Add cmake/smoke_test/ as a minimal find_package(Ceres REQUIRED) consumer and run it in the Verify Install step of linux.yml (no-cuda) and macos.yml (host). - Install FindAccelerateSparse.cmake and add find_dependency(AccelerateSparse) to CeresConfig.cmake.in when AccelerateSparse is enabled so installed macOS packages resolve AccelerateSparse::Accelerate cleanly. Change-Id: Ia8f4e6046c604d27859a42e9830eb65ea9bc9e0b
diff --git a/.github/workflows/linux.yml b/.github/workflows/linux.yml index 79cae55..eb04041 100644 --- a/.github/workflows/linux.yml +++ b/.github/workflows/linux.yml
@@ -181,3 +181,100 @@ cmake --build build_${{matrix.build_type}}/ \ --config ${{matrix.build_type}} \ --target install + + - name: Verify Install + if: matrix.gpu == 'no-cuda' + run: | + cmake -S cmake/smoke_test -B build_smoke_test \ + -DCMAKE_PREFIX_PATH=${{github.workspace}}/install + cmake --build build_smoke_test + ./build_smoke_test/smoke + + debug-and-sanitizers: + name: ubuntu-26.04-${{matrix.config}} + runs-on: ubuntu-26.04 + defaults: + run: + shell: bash -e -o pipefail {0} + env: + CCACHE_COMPRESS: 1 + CCACHE_DIR: ${{github.workspace}}/ccache + CCACHE_MAXSIZE: 500M + CMAKE_GENERATOR: Ninja + DEBIAN_FRONTEND: noninteractive + strategy: + fail-fast: false + matrix: + include: + - config: gcc-debug + cc: gcc + cxx: g++ + build_type: Debug + flags: "" + - config: clang-asan-ubsan + cc: clang + cxx: clang++ + build_type: RelWithDebInfo + flags: "-fsanitize=address,undefined -fno-omit-frame-pointer" + - config: clang-tsan + cc: clang + cxx: clang++ + build_type: RelWithDebInfo + flags: "-fsanitize=thread -fno-omit-frame-pointer" + + steps: + - name: Setup Dependencies + run: | + sudo apt-get update + sudo apt-get install -y \ + build-essential \ + ccache \ + clang \ + cmake \ + libblas-dev \ + libeigen3-dev \ + liblapack-dev \ + libmetis-dev \ + libsuitesparse-dev \ + ninja-build + + - uses: actions/checkout@v7 + with: + submodules: recursive + + - name: Cache Build + uses: actions/cache@v6 + with: + path: ${{env.CCACHE_DIR}} + key: ubuntu-26.04-ccache-${{matrix.config}}-${{github.run_id}} + restore-keys: ubuntu-26.04-ccache-${{matrix.config}}- + + - name: Configure + env: + CC: ${{matrix.cc}} + CXX: ${{matrix.cxx}} + run: | + cmake -S . -B build \ + -DBUILD_BENCHMARKS=OFF \ + -DBUILD_EXAMPLES=OFF \ + -DBUILD_SHARED_LIBS=OFF \ + -DCMAKE_BUILD_TYPE=${{matrix.build_type}} \ + -DCMAKE_C_COMPILER_LAUNCHER=$(which ccache) \ + -DCMAKE_CXX_COMPILER_LAUNCHER=$(which ccache) \ + -DCMAKE_C_FLAGS="${{matrix.flags}}" \ + -DCMAKE_CXX_FLAGS="${{matrix.flags}}" \ + -DWITH_CUDA=OFF \ + -DWITH_SUITESPARSE=ON + + - name: Build + run: cmake --build build + + - name: Test + env: + ASAN_OPTIONS: detect_leaks=1 + TSAN_OPTIONS: halt_on_error=1 + UBSAN_OPTIONS: print_stacktrace=1:halt_on_error=1 + run: | + ctest --test-dir build \ + --output-on-failure \ + -j$(nproc)
diff --git a/.github/workflows/macos.yml b/.github/workflows/macos.yml index 92faace..422ab23 100644 --- a/.github/workflows/macos.yml +++ b/.github/workflows/macos.yml
@@ -116,3 +116,11 @@ cmake --build build_${{matrix.build_type}}/ \ --config ${{matrix.build_type}} \ --target install + + - name: Verify Install + if: matrix.target == 'host' + run: | + cmake -S cmake/smoke_test -B build_smoke_test \ + -DCMAKE_PREFIX_PATH=${{github.workspace}}/install + cmake --build build_smoke_test + ./build_smoke_test/smoke
diff --git a/CMakeLists.txt b/CMakeLists.txt index 1d64d09..f3774e7 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt
@@ -493,7 +493,11 @@ list (APPEND CERES_COMPILE_OPTIONS CERES_NO_EIGEN_METIS) endif() -if (NOT _Ceres_FEATURE_ACCELERATE) +if (_Ceres_FEATURE_ACCELERATE) + set(AccelerateSparse_DEPENDENCY "find_dependency(AccelerateSparse)") + list(APPEND _Ceres_CONFIG_DEPENDENCY_MODULES + ${Ceres_SOURCE_DIR}/cmake/FindAccelerateSparse.cmake) +else() list(APPEND CERES_COMPILE_OPTIONS CERES_NO_ACCELERATE_SPARSE) mark_as_advanced(FORCE AccelerateSparse_INCLUDE_DIR AccelerateSparse_LIBRARY)
diff --git a/cmake/CeresConfig.cmake.in b/cmake/CeresConfig.cmake.in index 34e095a..0f7a006 100644 --- a/cmake/CeresConfig.cmake.in +++ b/cmake/CeresConfig.cmake.in
@@ -106,6 +106,7 @@ find_dependency(Threads) # Optional dependencies +@AccelerateSparse_DEPENDENCY@ @METIS_DEPENDENCY@ @SuiteSparse_DEPENDENCY@ @CUDAToolkit_DEPENDENCY@
diff --git a/cmake/smoke_test/CMakeLists.txt b/cmake/smoke_test/CMakeLists.txt new file mode 100644 index 0000000..2a311bc --- /dev/null +++ b/cmake/smoke_test/CMakeLists.txt
@@ -0,0 +1,35 @@ +# Ceres Solver - A fast non-linear least squares minimizer +# Copyright 2026 Google Inc. All rights reserved. +# http://ceres-solver.org/ +# +# Redistribution and use in source and binary forms, with or without +# modification, are permitted provided that the following conditions are met: +# +# * Redistributions of source code must retain the above copyright notice, +# this list of conditions and the following disclaimer. +# * Redistributions in binary form must reproduce the above copyright notice, +# this list of conditions and the following disclaimer in the documentation +# and/or other materials provided with the distribution. +# * Neither the name of Google Inc. nor the names of its contributors may be +# used to endorse or promote products derived from this software without +# specific prior written permission. +# +# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" +# AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE +# IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE +# ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE +# LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR +# CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF +# SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS +# INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN +# CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) +# ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE +# POSSIBILITY OF SUCH DAMAGE. + +cmake_minimum_required(VERSION 3.28) +project(ceres_smoke_test LANGUAGES CXX) + +find_package(Ceres REQUIRED) + +add_executable(smoke main.cc) +target_link_libraries(smoke PRIVATE Ceres::ceres)
diff --git a/cmake/smoke_test/main.cc b/cmake/smoke_test/main.cc new file mode 100644 index 0000000..c24e270 --- /dev/null +++ b/cmake/smoke_test/main.cc
@@ -0,0 +1,50 @@ +// Ceres Solver - A fast non-linear least squares minimizer +// Copyright 2026 Google Inc. All rights reserved. +// http://ceres-solver.org/ +// +// Redistribution and use in source and binary forms, with or without +// modification, are permitted provided that the following conditions are met: +// +// * Redistributions of source code must retain the above copyright notice, +// this list of conditions and the following disclaimer. +// * Redistributions in binary form must reproduce the above copyright notice, +// this list of conditions and the following disclaimer in the documentation +// and/or other materials provided with the distribution. +// * Neither the name of Google Inc. nor the names of its contributors may be +// used to endorse or promote products derived from this software without +// specific prior written permission. +// +// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" +// AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE +// IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE +// ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE +// LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR +// CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF +// SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS +// INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN +// CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) +// ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE +// POSSIBILITY OF SUCH DAMAGE. + +#include <cstdlib> + +#include "ceres/ceres.h" + +struct CostFunctor { + template <typename T> + bool operator()(const T* const x, T* residual) const { + residual[0] = T(10.0) - x[0]; + return true; + } +}; + +int main() { + double x = 0.5; + ceres::Problem problem; + problem.AddResidualBlock( + new ceres::AutoDiffCostFunction<CostFunctor, 1, 1>(), nullptr, &x); + ceres::Solver::Options options; + ceres::Solver::Summary summary; + ceres::Solve(options, &problem, &summary); + return summary.IsSolutionUsable() ? EXIT_SUCCESS : EXIT_FAILURE; +}