Skip to content

Commit 0042dd2

Browse files
authored
ceres-solver: update to v2.1.0-p0 with OpenBLAS support (#643)
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
1 parent cb28720 commit 0042dd2

File tree

6 files changed

+54
-4
lines changed

6 files changed

+54
-4
lines changed

cmake/configs/default.cmake

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -219,7 +219,7 @@ hunter_default_version(catkin VERSION 0.7.17-p0)
219219
hunter_default_version(cctz VERSION 2.2.0)
220220
hunter_default_version(ccv VERSION 0.7-p6)
221221
hunter_default_version(cereal VERSION 1.2.2-p0)
222-
hunter_default_version(ceres-solver VERSION 2.0.0-p0)
222+
hunter_default_version(ceres-solver VERSION 2.1.0-p0)
223223
hunter_default_version(cgltf VERSION 1.10-f9a8804-p0)
224224
hunter_default_version(check_ci_tag VERSION 1.0.0)
225225
hunter_default_version(chromium_zlib VERSION 0.0.0-f87c2b10efb4-p0)

cmake/projects/ceres-solver/hunter.cmake

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -76,13 +76,26 @@ hunter_add_version(
7676
868f7b45b127d4eb2777ce889e0d273bd11f5f73
7777
)
7878

79+
hunter_add_version(
80+
PACKAGE_NAME
81+
ceres-solver
82+
VERSION
83+
"2.1.0-p0"
84+
URL
85+
"https://github.com/cpp-pm/ceres-solver/archive/refs/tags/v2.1.0-p0.tar.gz"
86+
SHA1
87+
315d16137f08ed4b4ee303d505a6355f96b9a3aa
88+
)
89+
7990
hunter_cmake_args(ceres-solver CMAKE_ARGS
8091
# explicitly remove dependency on gflags (only needed for tests)
8192
GFLAGS=OFF
8293
# explicitly disable suitesparse support
8394
LAPACK=OFF
8495
SUITESPARSE=OFF
8596
CXSPARSE=OFF # since 1.14.0-p0
97+
# OpenBLAS flag, alternative to LAPACK since v2.1.0-p0
98+
WITH_OPENBLAS=OFF
8699
# don't build tests
87100
BUILD_TESTING=OFF
88101
# also don't build examples: when suitesparse is enabled the examples need Fortran libraries

docs/packages/pkg/ceres-solver.rst

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,8 @@
22

33
ceres
44
performant
5+
OpenBLAS
6+
Fortran
57

68
.. index:: unsorted ; ceres-solver
79

@@ -85,3 +87,25 @@ add a local ``cmake/Hunter/config.cmake`` file with the following contents:
8587
8688
With a dynamic ``LAPACK`` library the ``enable_language(Fortran)`` is not needed.
8789
But when shipping your project one must also ship the shared ``LAPACK`` library.
90+
91+
with OpenBLAS as alternative to LAPACK
92+
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
93+
94+
Since ``v0.3.21`` ``OpenBLAS`` provides a f2c-converted copy of ``LAPACK`` ``v3.9.0``.
95+
This copy is used when building without a Fortran compiler.
96+
Using this in ``ceres-solver`` and ``SuiteSparse`` enables us to build a pure C++ library.
97+
Which means the resulting library can be static with no Fortran runtime dependencies.
98+
99+
Since Hunter `v0.24.9 <https://github.com/cpp-pm/hunter/releases/tag/v0.24.9>`__
100+
``SuiteSparse`` per default is built against ``OpenBLAS``,
101+
which in Hunter per default compiles without Fortran and with ``LAPACK`` enabled.
102+
103+
.. code-block:: cmake
104+
105+
hunter_config(ceres-solver
106+
VERSION ${HUNTER_ceres-solver_VERSION} CMAKE_ARGS
107+
LAPACK=ON
108+
WITH_OPENBLAS=ON # since 2.1.0-p0
109+
SUITESPARSE=ON
110+
CXSPARSE=ON # since 1.14.0-p1
111+
)
Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,11 @@
1+
hunter_config(SuiteSparse
2+
VERSION ${HUNTER_SuiteSparse_VERSION}
3+
CMAKE_ARGS
4+
BUILD_METIS=ON
5+
WITH_OPENBLAS=OFF # we want to test generic LAPACK dynamic lib, not OpenBLAS
6+
)
17
hunter_config(LAPACK
28
VERSION ${HUNTER_LAPACK_VERSION}
39
CMAKE_ARGS
410
BUILD_SHARED_LIBS=ON
5-
BUILD_METIS=ON
6-
WITH_OPENBLAS=OFF # we want to test generic LAPACK dynamic lib, not OpenBLAS
711
)

examples/ceres-solver-suitesparse-dynLAPACK/config.cmake

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,14 @@ hunter_config(ceres-solver
22
VERSION ${HUNTER_ceres-solver_VERSION} CMAKE_ARGS
33
LAPACK=ON
44
SUITESPARSE=ON
5-
CXSPARSE=ON # since 1.14.0-p1
5+
CXSPARSE=OFF # since 1.14.0-p1
6+
WITH_OPENBLAS=OFF # we want to test generic LAPACK dynamic lib, not OpenBLAS
7+
)
8+
hunter_config(SuiteSparse
9+
VERSION ${HUNTER_SuiteSparse_VERSION}
10+
CMAKE_ARGS
11+
BUILD_METIS=ON
12+
WITH_OPENBLAS=OFF # we want to test generic LAPACK dynamic lib, not OpenBLAS
613
)
714
hunter_config(LAPACK
815
VERSION ${HUNTER_LAPACK_VERSION}

examples/ceres-solver-suitesparse/config.cmake

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,4 +3,6 @@ hunter_config(ceres-solver
33
LAPACK=ON
44
SUITESPARSE=ON
55
CXSPARSE=ON # since 1.14.0-p1
6+
# sine 2.1.0, SuiteSparse 5.4.0 per default builds against OpenBLAS as well
7+
WITH_OPENBLAS=ON
68
)

0 commit comments

Comments
 (0)