Skip to content

Commit

Permalink
ceres-solver: update to v2.1.0-p0 with OpenBLAS support (#643)
Browse files Browse the repository at this point in the history
Update `ceres-solver` to `v2.1.0-p0`.

Add option `WITH_OPENBLAS` (disabled in Hunter per default) to build
against `OpenBLAS` instead of generic `LAPACK`.

`OpenBLAS` `v0.3.21` provides a f2c-converted `LAPACK` `v3.9.0` copy,
which is used when building without a Fortran compiler.
This enables us to have a C++ only build, making static libraries
easier (no fortran runtime libs anymore).

Update dynLAPACK example with the new OpenBLAS settings (for SuiteSparse
as well).

* SuiteSparse: fix WITH_OPENBLAS setting, LAPACK doesn't have this flag
  • Loading branch information
NeroBurner authored Dec 14, 2022
1 parent cb28720 commit 0042dd2
Show file tree
Hide file tree
Showing 6 changed files with 54 additions and 4 deletions.
2 changes: 1 addition & 1 deletion cmake/configs/default.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -219,7 +219,7 @@ hunter_default_version(catkin VERSION 0.7.17-p0)
hunter_default_version(cctz VERSION 2.2.0)
hunter_default_version(ccv VERSION 0.7-p6)
hunter_default_version(cereal VERSION 1.2.2-p0)
hunter_default_version(ceres-solver VERSION 2.0.0-p0)
hunter_default_version(ceres-solver VERSION 2.1.0-p0)
hunter_default_version(cgltf VERSION 1.10-f9a8804-p0)
hunter_default_version(check_ci_tag VERSION 1.0.0)
hunter_default_version(chromium_zlib VERSION 0.0.0-f87c2b10efb4-p0)
Expand Down
13 changes: 13 additions & 0 deletions cmake/projects/ceres-solver/hunter.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -76,13 +76,26 @@ hunter_add_version(
868f7b45b127d4eb2777ce889e0d273bd11f5f73
)

hunter_add_version(
PACKAGE_NAME
ceres-solver
VERSION
"2.1.0-p0"
URL
"https://github.com/cpp-pm/ceres-solver/archive/refs/tags/v2.1.0-p0.tar.gz"
SHA1
315d16137f08ed4b4ee303d505a6355f96b9a3aa
)

hunter_cmake_args(ceres-solver CMAKE_ARGS
# explicitly remove dependency on gflags (only needed for tests)
GFLAGS=OFF
# explicitly disable suitesparse support
LAPACK=OFF
SUITESPARSE=OFF
CXSPARSE=OFF # since 1.14.0-p0
# OpenBLAS flag, alternative to LAPACK since v2.1.0-p0
WITH_OPENBLAS=OFF
# don't build tests
BUILD_TESTING=OFF
# also don't build examples: when suitesparse is enabled the examples need Fortran libraries
Expand Down
24 changes: 24 additions & 0 deletions docs/packages/pkg/ceres-solver.rst
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@

ceres
performant
OpenBLAS
Fortran

.. index:: unsorted ; ceres-solver

Expand Down Expand Up @@ -85,3 +87,25 @@ add a local ``cmake/Hunter/config.cmake`` file with the following contents:
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 <https://github.com/cpp-pm/hunter/releases/tag/v0.24.9>`__
``SuiteSparse`` per default is built against ``OpenBLAS``,
which in Hunter per default compiles without Fortran and with ``LAPACK`` enabled.

.. code-block:: cmake
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
)
8 changes: 6 additions & 2 deletions examples/SuiteSparse-dynLAPACK/config.cmake
Original file line number Diff line number Diff line change
@@ -1,7 +1,11 @@
hunter_config(SuiteSparse
VERSION ${HUNTER_SuiteSparse_VERSION}
CMAKE_ARGS
BUILD_METIS=ON
WITH_OPENBLAS=OFF # we want to test generic LAPACK dynamic lib, not OpenBLAS
)
hunter_config(LAPACK
VERSION ${HUNTER_LAPACK_VERSION}
CMAKE_ARGS
BUILD_SHARED_LIBS=ON
BUILD_METIS=ON
WITH_OPENBLAS=OFF # we want to test generic LAPACK dynamic lib, not OpenBLAS
)
9 changes: 8 additions & 1 deletion examples/ceres-solver-suitesparse-dynLAPACK/config.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,14 @@ hunter_config(ceres-solver
VERSION ${HUNTER_ceres-solver_VERSION} CMAKE_ARGS
LAPACK=ON
SUITESPARSE=ON
CXSPARSE=ON # since 1.14.0-p1
CXSPARSE=OFF # since 1.14.0-p1
WITH_OPENBLAS=OFF # we want to test generic LAPACK dynamic lib, not OpenBLAS
)
hunter_config(SuiteSparse
VERSION ${HUNTER_SuiteSparse_VERSION}
CMAKE_ARGS
BUILD_METIS=ON
WITH_OPENBLAS=OFF # we want to test generic LAPACK dynamic lib, not OpenBLAS
)
hunter_config(LAPACK
VERSION ${HUNTER_LAPACK_VERSION}
Expand Down
2 changes: 2 additions & 0 deletions examples/ceres-solver-suitesparse/config.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -3,4 +3,6 @@ hunter_config(ceres-solver
LAPACK=ON
SUITESPARSE=ON
CXSPARSE=ON # since 1.14.0-p1
# sine 2.1.0, SuiteSparse 5.4.0 per default builds against OpenBLAS as well
WITH_OPENBLAS=ON
)

0 comments on commit 0042dd2

Please sign in to comment.