installation.rst 44 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105
  1. .. _chapter-installation:
  2. ============
  3. Installation
  4. ============
  5. Getting the source code
  6. =======================
  7. .. _section-source:
  8. You can start with the `latest stable release
  9. <http://ceres-solver.org/ceres-solver-2.2.0.tar.gz>`_ . Or if you want
  10. the latest version, you can clone the git repository
  11. .. code-block:: bash
  12. git clone https://ceres-solver.googlesource.com/ceres-solver
  13. .. _section-dependencies:
  14. Dependencies
  15. ============
  16. .. note ::
  17. Ceres Solver 2.2 requires a **fully C++17-compliant** compiler.
  18. Ceres relies on a number of open source libraries, some of which are
  19. optional. For details on customizing the build process, see
  20. :ref:`section-customizing` .
  21. - `CMake <http://www.cmake.org>`_ 3.16 or later **required**.
  22. - `Eigen <http://eigen.tuxfamily.org/index.php?title=Main_Page>`_
  23. 3.3 or later **required**.
  24. .. NOTE ::
  25. Ceres can also use Eigen as a sparse linear algebra
  26. library. Please see the documentation for ``EIGENSPARSE`` for
  27. more details.
  28. - `glog <https://github.com/google/glog>`_ 0.3.5 or
  29. later. **Recommended**
  30. ``glog`` is used extensively throughout Ceres for logging detailed
  31. information about memory allocations and time consumed in various
  32. parts of the solve, internal error conditions etc. The Ceres
  33. developers use it extensively to observe and analyze Ceres's
  34. performance. `glog <https://github.com/google/glog>`_ allows you to
  35. control its behaviour from the command line. Starting with
  36. ``-logtostderr`` you can add ``-v=N`` for increasing values of ``N``
  37. to get more and more verbose and detailed information about Ceres
  38. internals.
  39. Ceres also ships with a minimal replacement of ``glog`` called
  40. ``miniglog`` that can be enabled with the ``MINIGLOG`` build option.
  41. ``miniglog`` is supplied for platforms which do not support the full
  42. version of ``glog``.
  43. In an attempt to reduce dependencies, it may be tempting to use
  44. ``miniglog`` on platforms which already support ``glog``. While
  45. there is nothing preventing the user from doing so, we strongly
  46. recommend against it. ``miniglog`` has worse performance than
  47. ``glog`` and is much harder to control and use.
  48. - `gflags <https://github.com/gflags/gflags>`_. Needed to build
  49. examples and tests and usually a dependency for glog.
  50. - `SuiteSparse <http://faculty.cse.tamu.edu/davis/suitesparse.html>`_
  51. 4.5.6 or later. Needed for solving large sparse linear
  52. systems. **Optional; strongly recommended for large scale bundle
  53. adjustment**
  54. .. NOTE ::
  55. If SuiteSparseQR is found, Ceres attempts to find the Intel
  56. Thread Building Blocks (TBB) library. If found, Ceres assumes
  57. SuiteSparseQR was compiled with TBB support and will link to the
  58. found TBB version. You can customize the searched TBB location
  59. with the ``TBB_ROOT`` variable.
  60. A CMake native version of SuiteSparse that can be compiled on a variety of
  61. platforms (e.g., using Visual Studio, Xcode, MinGW, etc.) is maintained by the
  62. `CMake support for SuiteSparse <https://github.com/sergiud/SuiteSparse>`_
  63. project.
  64. - `Apple's Accelerate sparse solvers <https://developer.apple.com/documentation/accelerate/sparse_solvers>`_.
  65. As of Xcode 9.0, Apple's Accelerate framework includes support for
  66. solving sparse linear systems across macOS, iOS et al. **Optional**
  67. - `BLAS <http://www.netlib.org/blas/>`_ and `LAPACK
  68. <http://www.netlib.org/lapack/>`_ routines are needed by
  69. ``SuiteSparse``, and optionally used by Ceres directly for some
  70. operations.
  71. For best performance on ``x86`` based Linux systems we recommend
  72. using `Intel MKL
  73. <https://www.intel.com/content/www/us/en/develop/documentation/get-started-with-mkl-for-dpcpp/top.html>`_.
  74. Two other good options are `ATLAS
  75. <http://math-atlas.sourceforge.net/>`_, which includes ``BLAS`` and
  76. ``LAPACK`` routines and `OpenBLAS
  77. <https://github.com/xianyi/OpenBLAS>`_ . However, one needs to be
  78. careful to `turn off the threading
  79. <https://github.com/xianyi/OpenBLAS/wiki/faq#wiki-multi-threaded>`_
  80. inside ``OpenBLAS`` as it conflicts with use of threads in Ceres.
  81. MacOS ships with an optimized ``LAPACK`` and ``BLAS``
  82. implementation as part of the ``Accelerate`` framework. The Ceres
  83. build system will automatically detect and use it.
  84. For Windows things are much more complicated. `LAPACK For
  85. Windows <http://icl.cs.utk.edu/lapack-for-windows/lapack/>`_
  86. has detailed instructions..
  87. **Optional but required for** ``SuiteSparse``.
  88. - `CUDA <https://developer.nvidia.com/cuda-toolkit>`_ If you have an
  89. NVIDIA GPU then Ceres Solver can use it accelerate the solution of
  90. the Gauss-Newton linear systems using the CMake flag ``USE_CUDA``.
  91. Currently this support is limited to using the dense linear solvers that ship
  92. with ``CUDA``. As a result GPU acceleration can be used to speed up
  93. ``DENSE_QR``, ``DENSE_NORMAL_CHOLESKY`` and
  94. ``DENSE_SCHUR``. This also enables ``CUDA`` mixed precision solves
  95. for ``DENSE_NORMAL_CHOLESKY`` and ``DENSE_SCHUR``. **Optional**.
  96. .. _section-linux:
  97. Linux
  98. =====
  99. We will use `Ubuntu <http://www.ubuntu.com>`_ as our example linux
  100. distribution.
  101. .. NOTE::
  102. Ceres Solver always supports the previous and current Ubuntu LTS
  103. releases, currently 18.04 and 20.04, using the default Ubuntu
  104. repositories and compiler toolchain. Support for earlier versions
  105. is not guaranteed or maintained.
  106. Start by installing all the dependencies.
  107. .. code-block:: bash
  108. # CMake
  109. sudo apt-get install cmake
  110. # google-glog + gflags
  111. sudo apt-get install libgoogle-glog-dev libgflags-dev
  112. # Use ATLAS for BLAS & LAPACK
  113. sudo apt-get install libatlas-base-dev
  114. # Eigen3
  115. sudo apt-get install libeigen3-dev
  116. # SuiteSparse (optional)
  117. sudo apt-get install libsuitesparse-dev
  118. We are now ready to build, test, and install Ceres.
  119. .. code-block:: bash
  120. tar zxf ceres-solver-2.2.0.tar.gz
  121. mkdir ceres-bin
  122. cd ceres-bin
  123. cmake ../ceres-solver-2.2.0
  124. make -j3
  125. make test
  126. # Optionally install Ceres, it can also be exported using CMake which
  127. # allows Ceres to be used without requiring installation, see the documentation
  128. # for the EXPORT_BUILD_DIR option for more information.
  129. make install
  130. You can also try running the command line bundling application with one of the
  131. included problems, which comes from the University of Washington's BAL
  132. dataset [Agarwal]_.
  133. .. code-block:: bash
  134. bin/simple_bundle_adjuster ../ceres-solver-2.2.0/data/problem-16-22106-pre.txt
  135. This runs Ceres for a maximum of 10 iterations using the
  136. ``DENSE_SCHUR`` linear solver. The output should look something like
  137. this.
  138. .. code-block:: bash
  139. iter cost cost_change |gradient| |step| tr_ratio tr_radius ls_iter iter_time total_time
  140. 0 4.185660e+06 0.00e+00 1.09e+08 0.00e+00 0.00e+00 1.00e+04 0 2.18e-02 6.57e-02
  141. 1 1.062590e+05 4.08e+06 8.99e+06 0.00e+00 9.82e-01 3.00e+04 1 5.07e-02 1.16e-01
  142. 2 4.992817e+04 5.63e+04 8.32e+06 3.19e+02 6.52e-01 3.09e+04 1 4.75e-02 1.64e-01
  143. 3 1.899774e+04 3.09e+04 1.60e+06 1.24e+02 9.77e-01 9.26e+04 1 4.74e-02 2.11e-01
  144. 4 1.808729e+04 9.10e+02 3.97e+05 6.39e+01 9.51e-01 2.78e+05 1 4.75e-02 2.59e-01
  145. 5 1.803399e+04 5.33e+01 1.48e+04 1.23e+01 9.99e-01 8.33e+05 1 4.74e-02 3.06e-01
  146. 6 1.803390e+04 9.02e-02 6.35e+01 8.00e-01 1.00e+00 2.50e+06 1 4.76e-02 3.54e-01
  147. Solver Summary (v 2.2.0-eigen-(3.4.0)-lapack-suitesparse-(7.1.0)-metis-(5.1.0)-acceleratesparse-eigensparse)
  148. Original Reduced
  149. Parameter blocks 22122 22122
  150. Parameters 66462 66462
  151. Residual blocks 83718 83718
  152. Residuals 167436 167436
  153. Minimizer TRUST_REGION
  154. Dense linear algebra library EIGEN
  155. Trust region strategy LEVENBERG_MARQUARDT
  156. Given Used
  157. Linear solver DENSE_SCHUR DENSE_SCHUR
  158. Threads 1 1
  159. Linear solver ordering AUTOMATIC 22106,16
  160. Schur structure 2,3,9 2,3,9
  161. Cost:
  162. Initial 4.185660e+06
  163. Final 1.803390e+04
  164. Change 4.167626e+06
  165. Minimizer iterations 7
  166. Successful steps 7
  167. Unsuccessful steps 0
  168. Time (in seconds):
  169. Preprocessor 0.043895
  170. Residual only evaluation 0.029855 (7)
  171. Jacobian & residual evaluation 0.120581 (7)
  172. Linear solver 0.153665 (7)
  173. Minimizer 0.339275
  174. Postprocessor 0.000540
  175. Total 0.383710
  176. Termination: CONVERGENCE (Function tolerance reached. |cost_change|/cost: 1.769759e-09 <= 1.000000e-06)
  177. .. section-macos:
  178. macOS
  179. =====
  180. On macOS, you can either use `Homebrew <https://brew.sh/>`_
  181. (recommended) or `MacPorts <https://www.macports.org/>`_ to install
  182. Ceres Solver.
  183. If using `Homebrew <https://brew.sh/>`_, then
  184. .. code-block:: bash
  185. brew install ceres-solver
  186. will install the latest stable version along with all the required
  187. dependencies and
  188. .. code-block:: bash
  189. brew install ceres-solver --HEAD
  190. will install the latest version in the git repo.
  191. If using `MacPorts <https://www.macports.org/>`_, then
  192. .. code-block:: bash
  193. sudo port install ceres-solver
  194. will install the latest version.
  195. You can also install each of the dependencies by hand using `Homebrew
  196. <https://brew.sh/>`_. There is no need to install
  197. ``BLAS`` or ``LAPACK`` separately as macOS ships with optimized
  198. ``BLAS`` and ``LAPACK`` routines as part of the `vecLib
  199. <https://developer.apple.com/library/mac/#documentation/Performance/Conceptual/vecLib/Reference/reference.html>`_
  200. framework.
  201. .. code-block:: bash
  202. # CMake
  203. brew install cmake
  204. # google-glog and gflags
  205. brew install glog gflags
  206. # Eigen3
  207. brew install eigen
  208. # SuiteSparse
  209. brew install suite-sparse
  210. We are now ready to build, test, and install Ceres.
  211. .. code-block:: bash
  212. tar zxf ceres-solver-2.2.0.tar.gz
  213. mkdir ceres-bin
  214. cd ceres-bin
  215. cmake ../ceres-solver-2.2.0
  216. make -j3
  217. make test
  218. # Optionally install Ceres, it can also be exported using CMake which
  219. # allows Ceres to be used without requiring installation, see the
  220. # documentation for the EXPORT_BUILD_DIR option for more information.
  221. make install
  222. .. _section-windows:
  223. Windows
  224. =======
  225. Using a Library Manager
  226. -----------------------
  227. `vcpkg <https://github.com/microsoft/vcpkg>`_ is a library manager for Microsoft
  228. Windows that can be used to install Ceres Solver and all its dependencies.
  229. #. Install the library manager into a top-level directory ``vcpkg/`` on Windows
  230. following the `guide
  231. <https://github.com/microsoft/vcpkg#quick-start-windows>`_, e.g., using
  232. Visual Studio 2022 community edition, or simply run
  233. .. code:: bat
  234. git clone https://github.com/Microsoft/vcpkg.git
  235. cd vcpkg
  236. .\bootstrap-vcpkg.bat
  237. .\vcpkg integrate install
  238. #. Use vcpkg to install and build Ceres and all its dependencies, e.g., for 64
  239. bit Windows
  240. .. code:: bat
  241. vcpkg\vcpkg.exe install ceres:x64-windows
  242. Or with optional components, e.g., SuiteSparse, using
  243. .. code:: bat
  244. vcpkg\vcpkg.exe install ceres[suitesparse]:x64-windows
  245. #. Integrate vcpkg packages with Visual Studio to allow it to automatically
  246. find all the libraries installed by vcpkg.
  247. .. code:: bat
  248. vcpkg\vcpkg.exe integrate install
  249. #. To use Ceres in a CMake project, follow our :ref:`instructions
  250. <section-using-ceres>`.
  251. Building from Source
  252. --------------------
  253. Ceres Solver can also be built from source. For this purpose, we support Visual
  254. Studio 2019 and newer.
  255. .. NOTE::
  256. If you find the following CMake difficult to set up, then you may
  257. be interested in a `Microsoft Visual Studio wrapper
  258. <https://github.com/tbennun/ceres-windows>`_ for Ceres Solver by Tal
  259. Ben-Nun.
  260. #. Create a top-level directory for dependencies, build, and sources somewhere,
  261. e.g., ``ceres/``
  262. #. Get dependencies; unpack them as subdirectories in ``ceres/``
  263. (``ceres/eigen``, ``ceres/glog``, etc.)
  264. #. ``Eigen`` 3.3 . Configure and optionally install Eigen. It should be
  265. exported into the CMake package registry by default as part of the
  266. configure stage so installation should not be necessary.
  267. #. ``google-glog`` Open up the Visual Studio solution and build it.
  268. #. ``gflags`` Open up the Visual Studio solution and build it.
  269. #. (Experimental) ``SuiteSparse`` Previously SuiteSparse was not
  270. available on Windows, recently it has become possible to build
  271. it on Windows using the `suitesparse-metis-for-windows
  272. <https://github.com/jlblancoc/suitesparse-metis-for-windows>`_
  273. project. If you wish to use ``SuiteSparse``, follow their
  274. instructions for obtaining and building it.
  275. Alternatively, Ceres Solver supports ``SuiteSparse`` binary
  276. packages available for Visual Studio 2019 and 2022 provided by
  277. the `CMake support for SuiteSparse
  278. <https://github.com/sergiud/SuiteSparse>`_ project that also
  279. include `reference LAPACK <http://www.netlib.org/blas>`_ (and
  280. BLAS). The binary packages are used by Ceres Solver for
  281. continuous testing on Github.
  282. #. Unpack the Ceres tarball into ``ceres``. For the tarball, you
  283. should get a directory inside ``ceres`` similar to
  284. ``ceres-solver-2.2.0``. Alternately, checkout Ceres via ``git`` to
  285. get ``ceres-solver.git`` inside ``ceres``.
  286. #. Install ``CMake``,
  287. #. Create a directory ``ceres/ceres-bin`` (for an out-of-tree build)
  288. #. If you use the above binary ``SuiteSparse`` package, make sure CMake can
  289. find it, e.g., by assigning the path of the directory that contains the
  290. unzipped contents to the ``CMAKE_PREFIX_PATH`` environment variable. In a
  291. Windows command prompt this can be achieved as follows:
  292. .. code:: bat
  293. export CMAKE_PREFIX_PATH=C:/Downloads/SuiteSparse-5.11.0-cmake.1-vc16-Win64-Release-shared-gpl
  294. #. Run ``CMake``; select the ``ceres-solver-X.Y.Z`` or
  295. ``ceres-solver.git`` directory for the CMake file. Then select the
  296. ``ceres-bin`` for the build directory.
  297. #. Try running ``Configure`` which can fail at first because some dependencies
  298. cannot be automatically located. In this case, you must set the following
  299. CMake variables to the appropriate directories where you unpacked/built them:
  300. #. ``Eigen3_DIR`` (Set to directory containing ``Eigen3Config.cmake``)
  301. #. ``GLOG_INCLUDE_DIR_HINTS``
  302. #. ``GLOG_LIBRARY_DIR_HINTS``
  303. #. (Optional) ``gflags_DIR`` (Set to directory containing ``gflags-config.cmake``)
  304. #. (SuiteSparse binary package) ``BLAS_blas_LIBRARY`` and
  305. ``LAPACK_lapack_LIBRARY`` CMake variables must be `explicitly set` to
  306. ``<path>/lib/blas.lib`` and ``<path>/lib/lapack.lib``, respectively, both
  307. located in the unzipped package directory ``<path>``.
  308. If any of the variables are not visible in the ``CMake`` GUI, create a new
  309. entry for them. We recommend using the
  310. ``<NAME>_(INCLUDE/LIBRARY)_DIR_HINTS`` variables rather than setting the
  311. ``<NAME>_INCLUDE_DIR`` & ``<NAME>_LIBRARY`` variables directly to keep all of
  312. the validity checking, and to avoid having to specify the library files
  313. manually.
  314. #. You may have to tweak some more settings to generate a MSVC
  315. project. After each adjustment, try pressing Configure & Generate
  316. until it generates successfully.
  317. #. Open the solution and build it in MSVC
  318. To run the tests, select the ``RUN_TESTS`` target and hit **Build
  319. RUN_TESTS** from the build menu.
  320. Like the Linux build, you should now be able to run
  321. ``bin/simple_bundle_adjuster``.
  322. .. note::
  323. #. The default build is ``Debug``; consider switching it to ``Release`` for
  324. optimal performance.
  325. #. CMake puts the resulting test binaries in ``ceres-bin/examples/Debug`` by
  326. default.
  327. #. Without a sparse linear algebra library, only a subset of
  328. solvers is usable, namely: ``DENSE_QR``, ``DENSE_SCHUR``,
  329. ``CGNR``, and ``ITERATIVE_SCHUR``.
  330. .. _section-android:
  331. Android
  332. =======
  333. .. NOTE::
  334. You will need Android NDK r15 or higher to build Ceres solver.
  335. To build Ceres for Android, we need to force ``CMake`` to find
  336. the toolchains from the Android NDK instead of using the standard
  337. ones. For example, assuming you have specified ``$NDK_DIR``:
  338. .. code-block:: bash
  339. cmake \
  340. -DCMAKE_TOOLCHAIN_FILE=\
  341. $NDK_DIR/build/cmake/android.toolchain.cmake \
  342. -DEigen3_DIR=/path/to/Eigen3Config.cmake \
  343. -DANDROID_ABI=arm64-v8a \
  344. -DANDROID_STL=c++_shared \
  345. -DANDROID_NATIVE_API_LEVEL=android-29 \
  346. -DBUILD_SHARED_LIBS=ON \
  347. -DMINIGLOG=ON \
  348. <PATH_TO_CERES_SOURCE>
  349. You can build for any Android STL or ABI, but the c++_shared STL
  350. and the armeabi-v7a or arm64-v8a ABI are recommended for 32bit
  351. and 64bit architectures, respectively. Several API levels may
  352. be supported, but it is recommended that you use the highest
  353. level that is suitable for your Android project.
  354. .. NOTE::
  355. You must always use the same API level and STL library for
  356. your Android project and the Ceres binaries.
  357. After building, you get a ``libceres.so`` library, which you can
  358. link in your Android build system by using a
  359. ``PREBUILT_SHARED_LIBRARY`` target in your build script.
  360. If you are building any Ceres samples and would like to verify
  361. your library, you will need to place them in an executable public
  362. directory together with ``libceres.so`` on your Android device
  363. (e.g. in /data/local/tmp) and ensure that the STL library from
  364. your NDK is present in that same directory. You may then execute
  365. the sample by running for example:
  366. .. code-block:: bash
  367. adb shell
  368. cd /data/local/tmp
  369. LD_LIBRARY_PATH=/data/local/tmp ./helloworld
  370. Note that any solvers or other shared dependencies you include in
  371. your project must also be present in your android build config and
  372. your test directory on Android.
  373. .. _section-ios:
  374. iOS
  375. ===
  376. .. NOTE::
  377. You need iOS version 7.0 or higher to build Ceres Solver.
  378. To build Ceres for iOS, we need to force ``CMake`` to find the
  379. toolchains from the iOS SDK instead of using the standard ones. For
  380. example:
  381. .. code-block:: bash
  382. cmake \
  383. -DCMAKE_TOOLCHAIN_FILE=../ceres-solver/cmake/iOS.cmake \
  384. -DEigen3_DIR=/path/to/Eigen3Config.cmake \
  385. -DIOS_PLATFORM=<PLATFORM> \
  386. <PATH_TO_CERES_SOURCE>
  387. ``PLATFORM`` can be: ``OS``, ``SIMULATOR`` or ``SIMULATOR64``. You can
  388. build for ``OS`` (``armv7``, ``armv7s``, ``arm64``), ``SIMULATOR``
  389. (``i386``) or ``SIMULATOR64`` (``x86_64``) separately and use ``lipo``
  390. to merge them into one static library. See ``cmake/iOS.cmake`` for
  391. more options.
  392. .. NOTE::
  393. iOS version 11.0+ requires a 64-bit architecture, so you cannot
  394. build for armv7/armv7s with iOS 11.0+ (only arm64 is supported).
  395. After building, you will get a ``libceres.a`` library, which you will
  396. need to add to your Xcode project.
  397. The default CMake configuration builds a bare bones version of Ceres
  398. Solver that only depends on Eigen (``MINIGLOG`` is compiled into Ceres
  399. if it is used), this should be sufficient for solving small to
  400. moderate sized problems.
  401. If you decide to use ``LAPACK`` and ``BLAS``, then you also need to
  402. add ``Accelerate.framework`` to your Xcode project's linking
  403. dependency.
  404. .. _section-customizing:
  405. Customizing the build
  406. =====================
  407. It is possible to reduce the libraries needed to build Ceres and
  408. customize the build process by setting the appropriate options in
  409. ``CMake``. These options can either be set in the ``CMake`` GUI, or
  410. via ``-D<OPTION>=<ON/OFF>`` when running ``CMake`` from the command
  411. line. In general, you should only modify these options from their
  412. defaults if you know what you are doing.
  413. .. NOTE::
  414. If you are setting variables via ``-D<VARIABLE>=<VALUE>`` when
  415. calling ``CMake``, it is important to understand that this forcibly
  416. **overwrites** the variable ``<VARIABLE>`` in the ``CMake`` cache at
  417. the start of *every configure*.
  418. This can lead to confusion if you are invoking the ``CMake`` `curses
  419. <http://www.gnu.org/software/ncurses/ncurses.html>`_ terminal GUI
  420. (via ``ccmake``, e.g. ```ccmake -D<VARIABLE>=<VALUE>
  421. <PATH_TO_SRC>``). In this case, even if you change the value of
  422. ``<VARIABLE>`` in the ``CMake`` GUI, your changes will be
  423. **overwritten** with the value passed via ``-D<VARIABLE>=<VALUE>``
  424. (if one exists) at the start of each configure.
  425. As such, it is generally easier not to pass values to ``CMake`` via
  426. ``-D`` and instead interactively experiment with their values in the
  427. ``CMake`` GUI. If they are not present in the *Standard View*,
  428. toggle to the *Advanced View* with ``<t>``.
  429. Modifying default compilation flags
  430. -----------------------------------
  431. The ``CMAKE_CXX_FLAGS`` variable can be used to define additional
  432. default compilation flags for all build types. Any flags specified
  433. in ``CMAKE_CXX_FLAGS`` will be used in addition to the default
  434. flags used by Ceres for the current build type.
  435. For example, if you wished to build Ceres with `-march=native
  436. <https://gcc.gnu.org/onlinedocs/gcc/x86-Options.html>`_ which is not
  437. enabled by default (even if ``CMAKE_BUILD_TYPE=Release``) you would invoke
  438. CMake with:
  439. .. code-block:: bash
  440. cmake -DCMAKE_CXX_FLAGS="-march=native" <PATH_TO_CERES_SOURCE>
  441. .. NOTE ::
  442. The use of ``-march=native`` will limit portability, as it will tune the
  443. implementation to the specific CPU of the compiling machine (e.g. use of
  444. AVX if available). Run-time segfaults may occur if you then tried to
  445. run the resulting binaries on a machine with a different processor, even
  446. if it is from the same family (e.g. x86) if the specific options available
  447. are different. Note that the performance gains from the use of
  448. ``-march=native`` are not guaranteed to be significant.
  449. .. _options-controlling-ceres-configuration:
  450. Options controlling Ceres configuration
  451. ---------------------------------------
  452. #. ``LAPACK [Default: ON]``: If this option is enabled, and the ``BLAS`` and
  453. ``LAPACK`` libraries are found, Ceres will enable **direct** use of
  454. ``LAPACK`` routines (i.e. Ceres itself will call them). If this option is
  455. disabled, then Ceres will not require ``LAPACK`` or ``BLAS``. It is
  456. however still possible that Ceres may call ``LAPACK`` routines indirectly
  457. via SuiteSparse if ``LAPACK=OFF`` and ``SUITESPARSE=ON``. Finally
  458. note that if ``LAPACK=ON`` and ``SUITESPARSE=ON``, the ``LAPACK`` and
  459. ``BLAS`` libraries used by SuiteSparse and Ceres should be the same.
  460. #. ``SUITESPARSE [Default: ON]``: By default, Ceres will link to
  461. ``SuiteSparse`` if it and all of its dependencies are present. Turn
  462. this ``OFF`` to build Ceres without ``SuiteSparse``.
  463. .. NOTE::
  464. SuiteSparse is licensed under a mixture of GPL/LGPL/Commercial
  465. terms. Ceres requires some components that are only licensed under
  466. GPL/Commercial terms.
  467. #. ``ACCELERATESPARSE [Default: ON]``: By default, Ceres will link to
  468. Apple's Accelerate framework directly if a version of it is detected
  469. which supports solving sparse linear systems. Note that on Apple OSs
  470. Accelerate usually also provides the BLAS/LAPACK implementations and
  471. so would be linked against irrespective of the value of ``ACCELERATESPARSE``.
  472. #. ``EIGENSPARSE [Default: ON]``: By default, Ceres will use Eigen's
  473. sparse Cholesky factorization.
  474. #. ``GFLAGS [Default: ON]``: Turn this ``OFF`` to build Ceres without
  475. ``gflags``. This will also prevent some of the example code from
  476. building.
  477. #. ``MINIGLOG [Default: OFF]``: Ceres includes a stripped-down,
  478. minimal implementation of ``glog`` which can optionally be used as
  479. a substitute for ``glog``, thus removing ``glog`` as a required
  480. dependency. Turn this ``ON`` to use this minimal ``glog``
  481. implementation.
  482. #. ``SCHUR_SPECIALIZATIONS [Default: ON]``: If you are concerned about
  483. binary size/compilation time over some small (10-20%) performance
  484. gains in the ``SPARSE_SCHUR`` solver, you can disable some of the
  485. template specializations by turning this ``OFF``.
  486. #. ``BUILD_SHARED_LIBS [Default: OFF]``: By default Ceres is built as
  487. a static library, turn this ``ON`` to instead build Ceres as a
  488. shared library.
  489. #. ``EXPORT_BUILD_DIR [Default: OFF]``: By default Ceres is configured
  490. solely for installation, and so must be installed in order for
  491. clients to use it. Turn this ``ON`` to export Ceres' build
  492. directory location into the `user's local CMake package registry
  493. <http://www.cmake.org/cmake/help/v3.5/manual/cmake-packages.7.html#user-package-registry>`_
  494. where it will be detected **without requiring installation** in a
  495. client project using CMake when `find_package(Ceres)
  496. <http://www.cmake.org/cmake/help/v3.5/command/find_package.html>`_
  497. is invoked.
  498. #. ``BUILD_DOCUMENTATION [Default: OFF]``: Use this to enable building
  499. the documentation, requires `Sphinx <http://sphinx-doc.org/>`_ and
  500. the `sphinx-rtd-theme
  501. <https://pypi.org/project/sphinx-rtd-theme/>`_ package
  502. available from the Python package index. In addition, ``make
  503. ceres_docs`` can be used to build only the documentation.
  504. #. ``MSVC_USE_STATIC_CRT [Default: OFF]`` *Windows Only*: By default
  505. Ceres will use the Visual Studio default, *shared* C-Run Time (CRT)
  506. library. Turn this ``ON`` to use the *static* C-Run Time library
  507. instead.
  508. #. ``LIB_SUFFIX [Default: "64" on non-Debian/Arch based 64-bit Linux,
  509. otherwise: ""]``: The suffix to append to the library install
  510. directory, built from:
  511. ``${CMAKE_INSTALL_PREFIX}/lib${LIB_SUFFIX}``.
  512. The filesystem hierarchy standard recommends that 64-bit systems
  513. install native libraries to lib64 rather than lib. Most Linux
  514. distributions follow this convention, but Debian and Arch based
  515. distros do not. Note that the only generally sensible values for
  516. ``LIB_SUFFIX`` are "" and "64".
  517. Although by default Ceres will auto-detect non-Debian/Arch based
  518. 64-bit Linux distributions and default ``LIB_SUFFIX`` to "64", this
  519. can always be overridden by manually specifying LIB_SUFFIX using:
  520. ``-DLIB_SUFFIX=<VALUE>`` when invoking CMake.
  521. Options controlling Ceres dependency locations
  522. ----------------------------------------------
  523. Ceres uses the ``CMake`` `find_package
  524. <http://www.cmake.org/cmake/help/v3.5/command/find_package.html>`_
  525. function to find all of its dependencies. Dependencies that reliably
  526. provide config files on all supported platforms are expected to be
  527. found in "Config" mode of ``find_package`` (``Eigen``, ``gflags``).
  528. This means you can use the standard ``CMake`` facilities to customize
  529. where these dependencies are found, such as ``CMAKE_PREFIX_PATH``,
  530. the ``<DEPENDENCY_NAME>_DIR`` variables, or since ``CMake`` 3.12 the
  531. ``<DEPENDENCY_NAME>_ROOT`` variables.
  532. Other dependencies are found using
  533. ``Find<DEPENDENCY_NAME>.cmake`` scripts which are either included in
  534. Ceres (for most dependencies) or are shipped as standard with
  535. ``CMake`` (for ``LAPACK`` & ``BLAS``). These scripts will search all
  536. of the "standard" install locations for various OSs for each
  537. dependency. However, particularly for Windows, they may fail to find
  538. the library, in this case you will have to manually specify its
  539. installed location. The ``Find<DEPENDENCY_NAME>.cmake`` scripts
  540. shipped with Ceres support two ways for you to do this:
  541. #. Set the *hints* variables specifying the *directories* to search in
  542. preference, but in addition, to the search directories in the
  543. ``Find<DEPENDENCY_NAME>.cmake`` script:
  544. - ``<DEPENDENCY_NAME (CAPS)>_INCLUDE_DIR_HINTS``
  545. - ``<DEPENDENCY_NAME (CAPS)>_LIBRARY_DIR_HINTS``
  546. These variables should be set via ``-D<VAR>=<VALUE>``
  547. ``CMake`` arguments as they are not visible in the GUI.
  548. #. Set the variables specifying the *explicit* include directory
  549. and library file to use:
  550. - ``<DEPENDENCY_NAME (CAPS)>_INCLUDE_DIR``
  551. - ``<DEPENDENCY_NAME (CAPS)>_LIBRARY``
  552. This bypasses *all* searching in the
  553. ``Find<DEPENDENCY_NAME>.cmake`` script, but validation is still
  554. performed.
  555. These variables are available to set in the ``CMake`` GUI. They are
  556. visible in the *Standard View* if the library has not been found
  557. (but the current Ceres configuration requires it), but are always
  558. visible in the *Advanced View*. They can also be set directly via
  559. ``-D<VAR>=<VALUE>`` arguments to ``CMake``.
  560. Building using custom BLAS & LAPACK installs
  561. ----------------------------------------------
  562. If the standard find package scripts for ``BLAS`` & ``LAPACK`` which
  563. ship with ``CMake`` fail to find the desired libraries on your system,
  564. try setting ``CMAKE_LIBRARY_PATH`` to the path(s) to the directories
  565. containing the ``BLAS`` & ``LAPACK`` libraries when invoking ``CMake``
  566. to build Ceres via ``-D<VAR>=<VALUE>``. This should result in the
  567. libraries being found for any common variant of each.
  568. Alternatively, you may also directly specify the ``BLAS_LIBRARIES`` and
  569. ``LAPACK_LIBRARIES`` variables via ``-D<VAR>=<VALUE>`` when invoking CMake
  570. to configure Ceres.
  571. .. _section-using-ceres:
  572. Using Ceres with CMake
  573. ======================
  574. In order to use Ceres in client code with CMake using `find_package()
  575. <http://www.cmake.org/cmake/help/v3.5/command/find_package.html>`_
  576. then either:
  577. #. Ceres must have been installed with ``make install``. If the
  578. install location is non-standard (i.e. is not in CMake's default
  579. search paths) then it will not be detected by default, see:
  580. :ref:`section-local-installations`.
  581. Note that if you are using a non-standard install location you
  582. should consider exporting Ceres instead, as this will not require
  583. any extra information to be provided in client code for Ceres to
  584. be detected.
  585. #. Or Ceres' build directory must have been exported by enabling the
  586. ``EXPORT_BUILD_DIR`` option when Ceres was configured.
  587. As an example of how to use Ceres, to compile `examples/helloworld.cc
  588. <https://ceres-solver.googlesource.com/ceres-solver/+/master/examples/helloworld.cc>`_
  589. in a separate standalone project, the following CMakeList.txt can be
  590. used:
  591. .. code-block:: cmake
  592. cmake_minimum_required(VERSION 3.5)
  593. project(helloworld)
  594. find_package(Ceres REQUIRED)
  595. # helloworld
  596. add_executable(helloworld helloworld.cc)
  597. target_link_libraries(helloworld Ceres::ceres)
  598. Irrespective of whether Ceres was installed or exported, if multiple
  599. versions are detected, set: ``Ceres_DIR`` to control which is used.
  600. If Ceres was installed ``Ceres_DIR`` should be the path to the
  601. directory containing the installed ``CeresConfig.cmake`` file
  602. (e.g. ``/usr/local/lib/cmake/Ceres``). If Ceres was exported, then
  603. ``Ceres_DIR`` should be the path to the exported Ceres build
  604. directory.
  605. .. NOTE ::
  606. You do not need to call include_directories(${CERES_INCLUDE_DIRS})
  607. as the exported Ceres CMake target already contains the definitions
  608. of its public include directories which will be automatically
  609. included by CMake when compiling a target that links against Ceres.
  610. In fact, since v2.0 ``CERES_INCLUDE_DIRS`` is not even set.
  611. Specify Ceres components
  612. -------------------------------------
  613. You can specify particular Ceres components that you require (in order
  614. for Ceres to be reported as found) when invoking
  615. ``find_package(Ceres)``. This allows you to specify, for example,
  616. that you require a version of Ceres built with SuiteSparse support.
  617. By definition, if you do not specify any components when calling
  618. ``find_package(Ceres)`` (the default) any version of Ceres detected
  619. will be reported as found, irrespective of which components it was
  620. built with.
  621. The Ceres components which can be specified are:
  622. #. ``LAPACK``: Ceres built using LAPACK (``LAPACK=ON``).
  623. #. ``SuiteSparse``: Ceres built with SuiteSparse (``SUITESPARSE=ON``).
  624. #. ``AccelerateSparse``: Ceres built with Apple's Accelerate sparse solvers (``ACCELERATESPARSE=ON``).
  625. #. ``EigenSparse``: Ceres built with Eigen's sparse Cholesky factorization
  626. (``EIGENSPARSE=ON``).
  627. #. ``SparseLinearAlgebraLibrary``: Ceres built with *at least one*
  628. sparse linear algebra library. This is equivalent to
  629. ``SuiteSparse`` **OR** ``AccelerateSparse`` **OR** ``EigenSparse``.
  630. #. ``SchurSpecializations``: Ceres built with Schur specializations
  631. (``SCHUR_SPECIALIZATIONS=ON``).
  632. To specify one/multiple Ceres components use the ``COMPONENTS`` argument to
  633. `find_package()
  634. <http://www.cmake.org/cmake/help/v3.5/command/find_package.html>`_ like so:
  635. .. code-block:: cmake
  636. # Find a version of Ceres compiled with SuiteSparse & EigenSparse support.
  637. #
  638. # NOTE: This will report Ceres as **not** found if the detected version of
  639. # Ceres was not compiled with both SuiteSparse & EigenSparse.
  640. # Remember, if you have multiple versions of Ceres installed, you
  641. # can use Ceres_DIR to specify which should be used.
  642. find_package(Ceres REQUIRED COMPONENTS SuiteSparse EigenSparse)
  643. Specify Ceres version
  644. ---------------------
  645. Additionally, when CMake has found Ceres it can optionally check the package
  646. version, if it has been specified in the `find_package()
  647. <http://www.cmake.org/cmake/help/v3.5/command/find_package.html>`_
  648. call. For example:
  649. .. code-block:: cmake
  650. find_package(Ceres 1.2.3 REQUIRED)
  651. .. _section-local-installations:
  652. Local installations
  653. -------------------
  654. If Ceres was installed in a non-standard path by specifying
  655. ``-DCMAKE_INSTALL_PREFIX="/some/where/local"``, then the user should
  656. add the **PATHS** option to the ``find_package()`` command, e.g.,
  657. .. code-block:: cmake
  658. find_package(Ceres REQUIRED PATHS "/some/where/local/")
  659. Note that this can be used to have multiple versions of Ceres
  660. installed. However, particularly if you have only a single version of
  661. Ceres which you want to use but do not wish to install to a system
  662. location, you should consider exporting Ceres using the
  663. ``EXPORT_BUILD_DIR`` option instead of a local install, as exported
  664. versions of Ceres will be automatically detected by CMake,
  665. irrespective of their location.
  666. Understanding the CMake Package System
  667. ----------------------------------------
  668. Although a full tutorial on CMake is outside the scope of this guide,
  669. here we cover some of the most common CMake misunderstandings that
  670. crop up when using Ceres. For more detailed CMake usage, the
  671. following references are very useful:
  672. - The `official CMake tutorial <http://www.cmake.org/cmake-tutorial/>`_
  673. Provides a tour of the core features of CMake.
  674. - `ProjectConfig tutorial
  675. <http://www.cmake.org/Wiki/CMake/Tutorials/How_to_create_a_ProjectConfig.cmake_file>`_
  676. and the `cmake-packages documentation
  677. <http://www.cmake.org/cmake/help/git-master/manual/cmake-packages.7.html>`_
  678. Cover how to write a ``ProjectConfig.cmake`` file, discussed below,
  679. for your own project when installing or exporting it using CMake.
  680. It also covers how these processes in conjunction with
  681. ``find_package()`` are actually handled by CMake. The
  682. `ProjectConfig tutorial
  683. <http://www.cmake.org/Wiki/CMake/Tutorials/How_to_create_a_ProjectConfig.cmake_file>`_
  684. is the older style, currently used by Ceres for compatibility with
  685. older versions of CMake.
  686. .. NOTE :: **Targets in CMake.**
  687. All libraries and executables built using CMake are represented as
  688. *targets* created using `add_library()
  689. <http://www.cmake.org/cmake/help/v3.5/command/add_library.html>`_
  690. and `add_executable()
  691. <http://www.cmake.org/cmake/help/v3.5/command/add_executable.html>`_.
  692. Targets encapsulate the rules and dependencies (which can be other
  693. targets) required to build or link against an object. This allows
  694. CMake to implicitly manage dependency chains. Thus it is
  695. sufficient to tell CMake that a library target: ``B`` depends on a
  696. previously declared library target ``A``, and CMake will
  697. understand that this means that ``B`` also depends on all of the
  698. public dependencies of ``A``.
  699. When a project like Ceres is installed using CMake, or its build
  700. directory is exported into the local CMake package registry (see
  701. :ref:`section-install-vs-export`), in addition to the public headers
  702. and compiled libraries, a set of CMake-specific project configuration
  703. files are also installed to: ``<INSTALL_ROOT>/lib/cmake/Ceres`` (if Ceres
  704. is installed), or created in the build directory (if Ceres' build
  705. directory is exported). When `find_package
  706. <http://www.cmake.org/cmake/help/v3.5/command/find_package.html>`_ is
  707. invoked, CMake checks various standard install locations (including
  708. ``/usr/local`` on Linux & UNIX systems), and the local CMake package
  709. registry for CMake configuration files for the project to be found
  710. (i.e. Ceres in the case of ``find_package(Ceres)``). Specifically it
  711. looks for:
  712. - ``<PROJECT_NAME>Config.cmake`` (or
  713. ``<lower_case_project_name>-config.cmake``)
  714. Which is written by the developers of the project, and is
  715. configured with the selected options and installed locations when
  716. the project is built and imports the project targets and/or defines
  717. the legacy CMake variables: ``<PROJECT_NAME>_INCLUDE_DIRS`` &
  718. ``<PROJECT_NAME>_LIBRARIES`` which are used by the caller.
  719. The ``<PROJECT_NAME>Config.cmake`` typically includes a second file
  720. installed to the same location:
  721. - ``<PROJECT_NAME>Targets.cmake``
  722. Which is autogenerated by CMake as part of the install process and defines
  723. **imported targets** for the project in the caller's CMake scope.
  724. An **imported target** contains the same information about a library
  725. as a CMake target that was declared locally in the current CMake
  726. project using ``add_library()``. However, imported targets refer to
  727. objects that have already been built by a different CMake project.
  728. Principally, an imported target contains the location of the compiled
  729. object and all of its public dependencies required to link against it
  730. as well as all required include directories. Any locally declared target
  731. can depend on an imported target, and CMake will manage the dependency
  732. chain, just as if the imported target had been declared locally by the
  733. current project.
  734. Crucially, just like any locally declared CMake target, an imported target is
  735. identified by its **name** when adding it as a dependency to another target.
  736. Since v2.0, Ceres has used the target namespace feature of CMake to prefix
  737. its export targets: ``Ceres::ceres``. However, historically the Ceres target
  738. did not have a namespace, and was just called ``ceres``.
  739. Whilst an alias target called ``ceres`` is still provided in v2.0 for backwards
  740. compatibility, it creates a potential drawback, if you failed to call
  741. ``find_package(Ceres)``, and Ceres is installed in a default search path for
  742. your compiler, then instead of matching the imported Ceres target, it will
  743. instead match the installed libceres.so/dylib/a library. If this happens you
  744. will get either compiler errors for missing include directories or linker errors
  745. due to missing references to Ceres public dependencies.
  746. Note that this description applies both to projects that are
  747. **installed** using CMake, and to those whose **build directory is
  748. exported** using `export()
  749. <http://www.cmake.org/cmake/help/v3.5/command/export.html>`_ (instead
  750. of `install()
  751. <http://www.cmake.org/cmake/help/v3.5/command/install.html>`_). Ceres
  752. supports both installation and export of its build directory if the
  753. ``EXPORT_BUILD_DIR`` option is enabled, see
  754. :ref:`section-customizing`.
  755. .. _section-install-vs-export:
  756. Installing a project with CMake vs Exporting its build directory
  757. ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  758. When a project is **installed**, the compiled libraries and headers
  759. are copied from the source & build directory to the install location,
  760. and it is these copied files that are used by any client code. When a
  761. project's build directory is **exported**, instead of copying the
  762. compiled libraries and headers, CMake creates an entry for the project
  763. in the `user's local CMake package registry
  764. <http://www.cmake.org/cmake/help/v3.5/manual/cmake-packages.7.html#user-package-registry>`_,
  765. ``<USER_HOME>/.cmake/packages`` on Linux & macOS, which contains the
  766. path to the project's build directory which will be checked by CMake
  767. during a call to ``find_package()``. The effect of which is that any
  768. client code uses the compiled libraries and headers in the build
  769. directory directly, **thus not requiring the project to be installed
  770. to be used**.
  771. Installing / Exporting a project that uses Ceres
  772. --------------------------------------------------
  773. As described in `Understanding the CMake Package System`_, the contents of
  774. the ``CERES_LIBRARIES`` variable is the **name** of an imported target which
  775. represents Ceres. If you are installing / exporting your *own* project which
  776. *uses* Ceres, it is important to understand that:
  777. **Imported targets are not (re)exported when a project which imported them is
  778. exported**.
  779. Thus, when a project ``Foo`` which uses Ceres is exported, its list of
  780. dependencies as seen by another project ``Bar`` which imports ``Foo``
  781. via: ``find_package(Foo REQUIRED)`` will contain: ``ceres``. However,
  782. the definition of ``ceres`` as an imported target is **not
  783. (re)exported** when Foo is exported. Hence, without any additional
  784. steps, when processing ``Bar``, ``ceres`` will not be defined as an
  785. imported target. Thus, when processing ``Bar``, CMake will assume
  786. that ``ceres`` refers only to: ``libceres.a/so/dylib/lib`` (the
  787. compiled Ceres library) directly if it is on the current list of
  788. search paths. In which case, no CMake errors will occur, but ``Bar``
  789. will not link properly, as it does not have the required public link
  790. dependencies of Ceres, which are stored in the imported target
  791. definition.
  792. The solution to this is for ``Foo`` (i.e., the project that uses
  793. Ceres) to invoke ``find_package(Ceres)`` in ``FooConfig.cmake``, thus
  794. ``ceres`` will be defined as an imported target when CMake processes
  795. ``Bar``. An example of the required modifications to
  796. ``FooConfig.cmake`` are show below:
  797. .. code-block:: cmake
  798. # Importing Ceres in FooConfig.cmake using CMake 3.x style.
  799. #
  800. # In CMake v3.x, the find_dependency() macro exists to forward the REQUIRED
  801. # / QUIET parameters to find_package() when searching for dependencies.
  802. #
  803. # Note that find_dependency() does not take a path hint, so if Ceres was
  804. # installed in a non-standard location, that location must be added to
  805. # CMake's search list before this call.
  806. include(CMakeFindDependencyMacro)
  807. find_dependency(Ceres)
  808. .. _section-migration:
  809. Migration
  810. =========
  811. The following includes some hints for migrating from previous versions.
  812. Version 2.0
  813. -----------
  814. - When using Ceres with CMake, the target name in v2.0 is
  815. ``Ceres::ceres`` following modern naming convetions. The legacy
  816. target ``ceres`` exists for backwards compatibility, but is
  817. deprecated. ``CERES_INCLUDE_DIRS`` is not set any more, as the
  818. exported Ceres CMake target already contains the definitions of its
  819. public include directories which will be automatically included by
  820. CMake when compiling a target that links against Ceres.
  821. - When building Ceres, some dependencies (Eigen, gflags) are not found
  822. using custom ``Find<DEPENDENCY_NAME>.cmake`` modules any
  823. more. Hence, instead of the custom variables (``<DEPENDENCY_NAME (CAPS)>_INCLUDE_DIR_HINTS``,
  824. ``<DEPENDENCY_NAME (CAPS)>_INCLUDE_DIR``, ...) you should use standard
  825. CMake facilities to customize where these dependencies are found, such as
  826. ``CMAKE_PREFIX_PATH``, the ``<DEPENDENCY_NAME>_DIR`` variables, or
  827. since CMake 3.12 the ``<DEPENDENCY_NAME>_ROOT`` variables.
  828. - While TBB is not used any more directly by Ceres, it might still try
  829. to link against it, if SuiteSparseQR was found. The variable (environment
  830. or CMake) to customize this is ``TBB_ROOT`` (used to be ``TBBROOT``).
  831. For example, use ``cmake -DTBB_ROOT=/opt/intel/tbb ...`` if you want to
  832. link against TBB installed from Intel's binary packages on Linux.