ceres-solver¶
- Official
- Hunterized
- Examples:
- Available since v0.18.30
- Added by NeroBurner (pr-648)
- with SuiteSparse support
- Available since v0.19.40
- Added by NeroBurner (pr-898)
- Maintainer: https://github.com/NeroBurner
Ceres Solver is an open source C++ library for modeling and solving large, complicated optimization problems. It can be used to solve Non-linear Least Squares problems with bounds constraints and general unconstrained optimization problems. It is a mature, feature rich, and performant library that has been used in production at Google since 2010. For more, see official website.
Usage¶
hunter_add_package(ceres-solver)
find_package(Ceres CONFIG REQUIRED)
target_link_libraries(... PRIVATE ceres)
with SuiteSparse¶
To get ceres-solver
with SuiteSparse
and static LAPACK
add a local cmake/Hunter/config.cmake
file with the following contents:
hunter_config(ceres-solver
VERSION ${HUNTER_ceres-solver_VERSION} CMAKE_ARGS
LAPACK=ON
SUITESPARSE=ON
CXSPARSE=ON # since 1.14.0-p1
)
Don’t forget to add enable_language(Fortran)
in your projects CMakeLists.txt
.
with SuiteSparse and dynamic LAPACK¶
To get ceres-solver
with SuiteSparse
and dynamic LAPACK
add a local cmake/Hunter/config.cmake
file with the following contents:
hunter_config(ceres-solver
VERSION ${HUNTER_ceres-solver_VERSION} CMAKE_ARGS
LAPACK=ON
SUITESPARSE=ON
CXSPARSE=ON # since 1.14.0-p1
)
hunter_config(LAPACK
VERSION ${HUNTER_LAPACK_VERSION}
CMAKE_ARGS BUILD_SHARED_LIBS=ON
)
With a dynamic LAPACK
library the enable_language(Fortran)
is not needed.
But when shipping your project one must also ship the shared LAPACK
library.
with OpenBLAS as alternative to LAPACK¶
Since v0.3.21
OpenBLAS
provides a f2c-converted copy of LAPACK
v3.9.0
.
This copy is used when building without a Fortran compiler.
Using this in ceres-solver
and SuiteSparse
enables us to build a pure C++ library.
Which means the resulting library can be static with no Fortran runtime dependencies.
Since Hunter v0.24.9
SuiteSparse
per default is built against OpenBLAS
,
which in Hunter per default compiles without Fortran and with LAPACK
enabled.
hunter_config(ceres-solver
VERSION ${HUNTER_ceres-solver_VERSION} CMAKE_ARGS
LAPACK=ON
WITH_OPENBLAS=ON # since 2.1.0-p0
SUITESPARSE=ON
CXSPARSE=ON # since 1.14.0-p1
)