1 .. _chapter-building: 2 3 ======================= 4 Building & Installation 5 ======================= 6 7 Getting the source code 8 ======================= 9 .. _section-source: 10 11 You can start with the `latest stable release 12 <http://ceres-solver.org/ceres-solver-1.9.0.tar.gz>`_ . Or if you want 13 the latest version, you can clone the git repository 14 15 .. code-block:: bash 16 17 git clone https://ceres-solver.googlesource.com/ceres-solver 18 19 .. _section-dependencies: 20 21 Dependencies 22 ============ 23 24 Ceres relies on a number of open source libraries, some of which are 25 optional. For details on customizing the build process, see 26 :ref:`section-customizing` . 27 28 - `Eigen <http://eigen.tuxfamily.org/index.php?title=Main_Page>`_ 29 3.2.1 or later. **Required** 30 31 .. NOTE :: 32 33 Ceres can also use Eigen as a sparse linear algebra 34 library. Please see the documentation for ``-DEIGENSPARSE`` for 35 more details. 36 37 - `CMake <http://www.cmake.org>`_ 2.8.0 or later. 38 **Required on all platforms except for Android.** 39 40 - `Google Log <http://code.google.com/p/google-glog>`_ 0.3.1 or 41 later. **Recommended** 42 43 .. NOTE:: 44 45 Ceres has a minimal replacement of ``glog`` called ``miniglog`` 46 that can be enabled with the ``MINIGLOG`` build 47 option. ``miniglog`` is needed on Android as ``glog`` currently 48 does not build using the NDK. It can however be used on other 49 platforms too. 50 51 **We do not advise using** ``miniglog`` **on platforms other than 52 Android due to the various performance and functionality 53 compromises in** ``miniglog``. 54 55 - `Google Flags <http://code.google.com/p/gflags>`_. Needed to build 56 examples and tests. 57 58 - `SuiteSparse 59 <http://www.cise.ufl.edu/research/sparse/SuiteSparse/>`_. Needed for 60 solving large sparse linear systems. **Optional; strongly recomended 61 for large scale bundle adjustment** 62 63 - `CXSparse <http://www.cise.ufl.edu/research/sparse/CXSparse/>`_. 64 Similar to ``SuiteSparse`` but simpler and slower. CXSparse has 65 no dependencies on ``LAPACK`` and ``BLAS``. This makes for a simpler 66 build process and a smaller binary. **Optional** 67 68 - `BLAS <http://www.netlib.org/blas/>`_ and `LAPACK 69 <http://www.netlib.org/lapack/>`_ routines are needed by 70 ``SuiteSparse``, and optionally used by Ceres directly for some 71 operations. 72 73 On ``UNIX`` OSes other than Mac OS X we recommend `ATLAS 74 <http://math-atlas.sourceforge.net/>`_, which includes ``BLAS`` and 75 ``LAPACK`` routines. It is also possible to use `OpenBLAS 76 <https://github.com/xianyi/OpenBLAS>`_ . However, one needs to be 77 careful to `turn off the threading 78 <https://github.com/xianyi/OpenBLAS/wiki/faq#wiki-multi-threaded>`_ 79 inside ``OpenBLAS`` as it conflicts with use of threads in Ceres. 80 81 MAC OS X 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 85 For Windows things are much more complicated. `LAPACK For 86 Windows <http://icl.cs.utk.edu/lapack-for-windows/lapack/>`_ 87 has detailed instructions.. 88 89 **Optional but required for** ``SuiteSparse``. 90 91 .. _section-linux: 92 93 Linux 94 ===== 95 96 We will use `Ubuntu <http://www.ubuntu.com>`_ as our example linux 97 distribution. 98 99 .. NOTE:: 100 101 Up to at least Ubuntu 13.10, the SuiteSparse package in the official 102 package repository (built from SuiteSparse v3.4.0) **cannot** be used 103 to build Ceres as a *shared* library. Thus if you want to build 104 Ceres as a shared library using SuiteSparse, you must perform a 105 source install of SuiteSparse. It is recommended that you use the 106 current version of SuiteSparse (4.2.1 at the time of writing). 107 108 109 Start by installing all the dependencies. 110 111 .. code-block:: bash 112 113 # CMake 114 sudo apt-get install cmake 115 # gflags 116 tar -xvzf gflags-2.0.tar.gz 117 cd gflags-2.0 118 ./configure --prefix=/usr/local 119 make 120 sudo make install. 121 # google-glog must be configured to use the previously installed gflags 122 tar -xvzf glog-0.3.2.tar.gz 123 cd glog-0.3.2 124 ./configure --with-gflags=/usr/local/ 125 make 126 sudo make install 127 # BLAS & LAPACK 128 sudo apt-get install libatlas-base-dev 129 # Eigen3 130 sudo apt-get install libeigen3-dev 131 # SuiteSparse and CXSparse (optional) 132 # - If you want to build Ceres as a *static* library (the default) 133 # you can use the SuiteSparse package in the main Ubuntu package 134 # repository: 135 sudo apt-get install libsuitesparse-dev 136 # - However, if you want to build Ceres as a *shared* library, you must 137 # perform a source install of SuiteSparse (and uninstall the Ubuntu 138 # package if it is currently installed. 139 140 We are now ready to build, test, and install Ceres. 141 142 .. code-block:: bash 143 144 tar zxf ceres-solver-1.9.0.tar.gz 145 mkdir ceres-bin 146 cd ceres-bin 147 cmake ../ceres-solver-1.9.0 148 make -j3 149 make test 150 make install 151 152 You can also try running the command line bundling application with one of the 153 included problems, which comes from the University of Washington's BAL 154 dataset [Agarwal]_. 155 156 .. code-block:: bash 157 158 bin/simple_bundle_adjuster ../ceres-solver-1.9.0/data/problem-16-22106-pre.txt 159 160 This runs Ceres for a maximum of 10 iterations using the 161 ``DENSE_SCHUR`` linear solver. The output should look something like 162 this. 163 164 .. code-block:: bash 165 166 iter cost cost_change |gradient| |step| tr_ratio tr_radius ls_iter iter_time total_time 167 0 4.185660e+06 0.00e+00 1.09e+08 0.00e+00 0.00e+00 1.00e+04 0 7.59e-02 3.37e-01 168 1 1.062590e+05 4.08e+06 8.99e+06 5.36e+02 9.82e-01 3.00e+04 1 1.65e-01 5.03e-01 169 2 4.992817e+04 5.63e+04 8.32e+06 3.19e+02 6.52e-01 3.09e+04 1 1.45e-01 6.48e-01 170 3 1.899774e+04 3.09e+04 1.60e+06 1.24e+02 9.77e-01 9.26e+04 1 1.43e-01 7.92e-01 171 4 1.808729e+04 9.10e+02 3.97e+05 6.39e+01 9.51e-01 2.78e+05 1 1.45e-01 9.36e-01 172 5 1.803399e+04 5.33e+01 1.48e+04 1.23e+01 9.99e-01 8.33e+05 1 1.45e-01 1.08e+00 173 6 1.803390e+04 9.02e-02 6.35e+01 8.00e-01 1.00e+00 2.50e+06 1 1.50e-01 1.23e+00 174 175 Ceres Solver v1.10.0 Solve Report 176 ---------------------------------- 177 Original Reduced 178 Parameter blocks 22122 22122 179 Parameters 66462 66462 180 Residual blocks 83718 83718 181 Residual 167436 167436 182 183 Minimizer TRUST_REGION 184 185 Dense linear algebra library EIGEN 186 Trust region strategy LEVENBERG_MARQUARDT 187 188 Given Used 189 Linear solver DENSE_SCHUR DENSE_SCHUR 190 Threads 1 1 191 Linear solver threads 1 1 192 Linear solver ordering AUTOMATIC 22106, 16 193 194 Cost: 195 Initial 4.185660e+06 196 Final 1.803390e+04 197 Change 4.167626e+06 198 199 Minimizer iterations 6 200 Successful steps 6 201 Unsuccessful steps 0 202 203 Time (in seconds): 204 Preprocessor 0.261 205 206 Residual evaluation 0.082 207 Jacobian evaluation 0.412 208 Linear solver 0.442 209 Minimizer 1.051 210 211 Postprocessor 0.002 212 Total 1.357 213 214 Termination: CONVERGENCE (Function tolerance reached. |cost_change|/cost: 1.769766e-09 <= 1.000000e-06) 215 216 .. section-osx: 217 218 Mac OS X 219 ======== 220 .. NOTE:: 221 222 Ceres will not compile using Xcode 4.5.x (Clang version 4.1) due to a bug in that version of 223 Clang. If you are running Xcode 4.5.x, please update to Xcode >= 4.6.x before attempting to 224 build Ceres. 225 226 227 On OS X, we recommend using the `homebrew 228 <http://mxcl.github.com/homebrew/>`_ package manager to install Ceres. 229 230 .. code-block:: bash 231 232 brew install ceres-solver 233 234 will install the latest stable version along with all the required 235 dependencies and 236 237 .. code-block:: bash 238 239 brew install ceres-solver --HEAD 240 241 will install the latest version in the git repo. 242 243 You can also install each of the dependencies by hand using `homebrew 244 <http://mxcl.github.com/homebrew/>`_. There is no need to install 245 ``BLAS`` or ``LAPACK`` separately as OS X ships with optimized 246 ``BLAS`` and ``LAPACK`` routines as part of the `vecLib 247 <https://developer.apple.com/library/mac/#documentation/Performance/Conceptual/vecLib/Reference/reference.html>`_ 248 framework. 249 250 .. code-block:: bash 251 252 # CMake 253 brew install cmake 254 # google-glog and gflags 255 brew install glog 256 # Eigen3 257 brew install eigen 258 # SuiteSparse and CXSparse 259 brew install suite-sparse 260 261 We are now ready to build, test, and install Ceres. 262 263 .. code-block:: bash 264 265 tar zxf ceres-solver-1.9.0.tar.gz 266 mkdir ceres-bin 267 cd ceres-bin 268 cmake ../ceres-solver-1.9.0 269 make -j3 270 make test 271 make install 272 273 Like the Linux build, you should now be able to run 274 ``bin/simple_bundle_adjuster``. 275 276 .. _section-windows: 277 278 Windows 279 ======= 280 281 On Windows, we support building with Visual Studio 2010 or newer. Note 282 that the Windows port is less featureful and less tested than the 283 Linux or Mac OS X versions due to the lack of an officially supported 284 way of building SuiteSparse and CXSparse. There are however a number 285 of unofficial ways of building these libraries. Building on Windows 286 also a bit more involved since there is no automated way to install 287 dependencies. 288 289 .. NOTE:: Using ``google-glog`` & ``miniglog`` with windows.h. 290 291 The windows.h header if used with GDI (Graphics Device Interface) 292 defines ``ERROR``, which conflicts with the definition of ``ERROR`` 293 as a LogSeverity level in ``google-glog`` and ``miniglog``. There 294 are at least two possible fixes to this problem: 295 296 #. Use ``google-glog`` and define ``GLOG_NO_ABBREVIATED_SEVERITIES`` 297 when building Ceres and your own project, as documented 298 `here <http://google-glog.googlecode.com/svn/trunk/doc/glog.html>`__. 299 Note that this fix will not work for ``miniglog``, 300 but use of ``miniglog`` is strongly discouraged on any platform for which 301 ``google-glog`` is available (which includes Windows). 302 #. If you do not require GDI, then define ``NOGDI`` **before** including 303 windows.h. This solution should work for both ``google-glog`` and 304 ``miniglog`` and is documented for ``google-glog`` 305 `here <https://code.google.com/p/google-glog/issues/detail?id=33>`__. 306 307 #. Make a toplevel directory for deps & build & src somewhere: ``ceres/`` 308 #. Get dependencies; unpack them as subdirectories in ``ceres/`` 309 (``ceres/eigen``, ``ceres/glog``, etc) 310 311 #. ``Eigen`` 3.1 (needed on Windows; 3.0.x will not work). There is 312 no need to build anything; just unpack the source tarball. 313 314 #. ``google-glog`` Open up the Visual Studio solution and build it. 315 #. ``gflags`` Open up the Visual Studio solution and build it. 316 317 #. (Experimental) ``SuiteSparse`` Previously SuiteSparse was not available 318 on Windows, recently it has become possible to build it on Windows using 319 the `suitesparse-metis-for-windows <https://github.com/jlblancoc/suitesparse-metis-for-windows>`_ 320 project. If you wish to use ``SuiteSparse``, follow their instructions 321 for obtaining and building it. 322 323 #. (Experimental) ``CXSparse`` Previously CXSparse was not available on 324 Windows, there are now several ports that enable it to be, including: 325 `[1] <https://github.com/PetterS/CXSparse>`_ and 326 `[2] <https://github.com/TheFrenchLeaf/CXSparse>`_. If you wish to use 327 ``CXSparse``, follow their instructions for obtaining and building it. 328 329 #. Unpack the Ceres tarball into ``ceres``. For the tarball, you 330 should get a directory inside ``ceres`` similar to 331 ``ceres-solver-1.3.0``. Alternately, checkout Ceres via ``git`` to 332 get ``ceres-solver.git`` inside ``ceres``. 333 334 #. Install ``CMake``, 335 336 #. Make a dir ``ceres/ceres-bin`` (for an out-of-tree build) 337 338 #. Run ``CMake``; select the ``ceres-solver-X.Y.Z`` or 339 ``ceres-solver.git`` directory for the CMake file. Then select the 340 ``ceres-bin`` for the build dir. 341 342 #. Try running ``Configure``. It won't work. It'll show a bunch of options. 343 You'll need to set: 344 345 #. ``EIGEN_INCLUDE_DIR_HINTS`` 346 #. ``GLOG_INCLUDE_DIR_HINTS`` 347 #. ``GLOG_LIBRARY_DIR_HINTS`` 348 #. ``GFLAGS_INCLUDE_DIR_HINTS`` 349 #. ``GFLAGS_LIBRARY_DIR_HINTS`` 350 #. (Optional) ``SUITESPARSE_INCLUDE_DIR_HINTS`` 351 #. (Optional) ``SUITESPARSE_LIBRARY_DIR_HINTS`` 352 #. (Optional) ``CXSPARSE_INCLUDE_DIR_HINTS`` 353 #. (Optional) ``CXSPARSE_LIBRARY_DIR_HINTS`` 354 355 to the appropriate directories where you unpacked/built them. If any of 356 the variables are not visible in the ``CMake`` GUI, create a new entry 357 for them. We recommend using the ``<NAME>_(INCLUDE/LIBRARY)_DIR_HINTS`` 358 variables rather than setting the ``<NAME>_INCLUDE_DIR`` & 359 ``<NAME>_LIBRARY`` variables directly to keep all of the validity 360 checking, and to avoid having to specify the library files manually. 361 362 #. You may have to tweak some more settings to generate a MSVC 363 project. After each adjustment, try pressing Configure & Generate 364 until it generates successfully. 365 366 #. Open the solution and build it in MSVC 367 368 369 To run the tests, select the ``RUN_TESTS`` target and hit **Build 370 RUN_TESTS** from the build menu. 371 372 Like the Linux build, you should now be able to run 373 ``bin/simple_bundle_adjuster``. 374 375 Notes: 376 377 #. The default build is Debug; consider switching it to release mode. 378 #. Currently ``system_test`` is not working properly. 379 #. CMake puts the resulting test binaries in ``ceres-bin/examples/Debug`` 380 by default. 381 #. The solvers supported on Windows are ``DENSE_QR``, ``DENSE_SCHUR``, 382 ``CGNR``, and ``ITERATIVE_SCHUR``. 383 #. We're looking for someone to work with upstream ``SuiteSparse`` to 384 port their build system to something sane like ``CMake``, and get a 385 fully supported Windows port. 386 387 388 .. _section-android: 389 390 Android 391 ======= 392 393 Download the ``Android NDK`` version ``r9d`` or later. Run 394 ``ndk-build`` from inside the ``jni`` directory. Use the 395 ``libceres.a`` that gets created. 396 397 .. _section-ios: 398 399 iOS 400 === 401 402 .. NOTE:: 403 404 You need iOS version 6.0 or higher to build Ceres Solver. 405 406 To build Ceres for iOS, we need to force ``CMake`` to find the toolchains from 407 the iOS SDK instead of using the standard ones. For example: 408 409 .. code-block:: bash 410 411 cmake ../ceres-solver \ 412 -DCMAKE_TOOLCHAIN_FILE=../ceres-solver/cmake/iOS.cmake \ 413 -DEIGEN_INCLUDE_DIR=/path/to/eigen/header \ 414 -DIOS_PLATFORM=<PLATFORM> 415 416 ``PLATFORM`` can be one of ``OS``, ``SIMULATOR`` and ``SIMULATOR64``. You can 417 build for ``OS`` (``armv7``, ``armv7s``, ``arm64``), ``SIMULATOR`` (``i386``) or 418 ``SIMULATOR64`` (``x86_64``) separately and use ``LIPO`` to merge them into 419 one static library. See ``cmake/iOS.cmake`` for more options. 420 421 After building, you will get a ``libceres.a`` library, which you will need to 422 add to your Xcode project. 423 424 The default CMake configuration builds a bare bones version of Ceres 425 Solver that only depends on Eigen (``MINIGLOG`` is compiled into Ceres if it is 426 used), this should be sufficient for solving small to moderate sized problems 427 (No ``SPARSE_SCHUR``, ``SPARSE_NORMAL_CHOLESKY`` linear solvers and no 428 ``CLUSTER_JACOBI`` and ``CLUSTER_TRIDIAGONAL`` preconditioners). 429 430 If you decide to use ``LAPACK`` and ``BLAS``, then you also need to add 431 ``Accelerate.framework`` to your XCode project's linking dependency. 432 433 .. _section-customizing: 434 435 Customizing the build 436 ===================== 437 438 It is possible to reduce the libraries needed to build Ceres and 439 customize the build process by setting the appropriate options in 440 ``CMake``. These options can either be set in the ``CMake`` GUI, 441 or via ``-D<OPTION>=<ON/OFF>`` when running ``CMake`` from the 442 command line. In general, you should only modify these options from 443 their defaults if you know what you are doing. 444 445 .. NOTE:: 446 447 If you are setting variables via ``-D<VARIABLE>=<VALUE>`` when calling 448 ``CMake``, it is important to understand that this forcibly **overwrites** the 449 variable ``<VARIABLE>`` in the ``CMake`` cache at the start of *every configure*. 450 451 This can lead to confusion if you are invoking the ``CMake`` 452 `curses <http://www.gnu.org/software/ncurses/ncurses.html>`_ terminal GUI 453 (via ``ccmake``, e.g. ```ccmake -D<VARIABLE>=<VALUE> <PATH_TO_SRC>``). 454 In this case, even if you change the value of ``<VARIABLE>`` in the ``CMake`` 455 GUI, your changes will be **overwritten** with the value passed via 456 ``-D<VARIABLE>=<VALUE>`` (if one exists) at the start of each configure. 457 458 As such, it is generally easier not to pass values to ``CMake`` via ``-D`` 459 and instead interactively experiment with their values in the ``CMake`` GUI. 460 If they are not present in the *Standard View*, toggle to the *Advanced View* 461 with ``<t>``. 462 463 Options controlling Ceres configuration 464 --------------------------------------- 465 466 #. ``LAPACK [Default: ON]``: By default Ceres will use ``LAPACK`` (& 467 ``BLAS``) if they are found. Turn this ``OFF`` to build Ceres 468 without ``LAPACK``. Turning this ``OFF`` also disables 469 ``SUITESPARSE`` as it depends on ``LAPACK``. 470 471 #. ``SUITESPARSE [Default: ON]``: By default, Ceres will link to 472 ``SuiteSparse`` if it and all of its dependencies are present. Turn 473 this ``OFF`` to build Ceres without ``SuiteSparse``. Note that 474 ``LAPACK`` must be ``ON`` in order to build with ``SuiteSparse``. 475 476 #. ``CXSPARSE [Default: ON]``: By default, Ceres will link to 477 ``CXSparse`` if all its dependencies are present. Turn this ``OFF`` 478 to build Ceres without ``CXSparse``. 479 480 #. ``EIGENSPARSE [Default: OFF]``: By default, Ceres will not use 481 Eigen's sparse Cholesky factorization. The is because this part of 482 the code is licensed under the ``LGPL`` and since ``Eigen`` is a 483 header only library, including this code will result in an ``LGPL`` 484 licensed version of Ceres. 485 486 #. ``GFLAGS [Default: ON]``: Turn this ``OFF`` to build Ceres without 487 ``gflags``. This will also prevent some of the example code from 488 building. 489 490 #. ``MINIGLOG [Default: OFF]``: Ceres includes a stripped-down, 491 minimal implementation of ``glog`` which can optionally be used as 492 a substitute for ``glog``, thus removing ``glog`` as a required 493 dependency. Turn this ``ON`` to use this minimal ``glog`` 494 implementation. 495 496 #. ``SCHUR_SPECIALIZATIONS [Default: ON]``: If you are concerned about 497 binary size/compilation time over some small (10-20%) performance 498 gains in the ``SPARSE_SCHUR`` solver, you can disable some of the 499 template specializations by turning this ``OFF``. 500 501 #. ``OPENMP [Default: ON]``: On certain platforms like Android, 502 multi-threading with ``OpenMP`` is not supported. Turn this ``OFF`` 503 to disable multithreading. 504 505 #. ``BUILD_SHARED_LIBS [Default: OFF]``: By default Ceres is built as 506 a static library, turn this ``ON`` to instead build Ceres as a 507 shared library. 508 509 #. ``BUILD_DOCUMENTATION [Default: OFF]``: Use this to enable building 510 the documentation, requires `Sphinx <http://sphinx-doc.org/>`_ and the 511 `sphinx_rtd_theme <https://pypi.python.org/pypi/sphinx_rtd_theme>`_ 512 package available from the Python package index. In addition, 513 ``make ceres_docs`` can be used to build only the documentation. 514 515 #. ``MSVC_USE_STATIC_CRT [Default: OFF]`` *Windows Only*: By default 516 Ceres will use the Visual Studio default, *shared* C-Run Time (CRT) library. 517 Turn this ``ON`` to use the *static* C-Run Time library instead. 518 519 520 Options controlling Ceres dependency locations 521 ---------------------------------------------- 522 523 Ceres uses the ``CMake`` 524 `find_package <http://www.cmake.org/cmake/help/v2.8.12/cmake.html#command:find_package>`_ 525 function to find all of its dependencies using 526 ``Find<DEPENDENCY_NAME>.cmake`` scripts which are either included in Ceres 527 (for most dependencies) or are shipped as standard with ``CMake`` 528 (for ``LAPACK`` & ``BLAS``). These scripts will search all of the "standard" 529 install locations for various OSs for each dependency. However, particularly 530 for Windows, they may fail to find the library, in this case you will have to 531 manually specify its installed location. The ``Find<DEPENDENCY_NAME>.cmake`` 532 scripts shipped with Ceres support two ways for you to do this: 533 534 #. Set the *hints* variables specifying the *directories* to search in 535 preference, but in addition, to the search directories in the 536 ``Find<DEPENDENCY_NAME>.cmake`` script: 537 538 - ``<DEPENDENCY_NAME (CAPS)>_INCLUDE_DIR_HINTS`` 539 - ``<DEPENDENCY_NAME (CAPS)>_LIBRARY_DIR_HINTS`` 540 541 These variables should be set via ``-D<VAR>=<VALUE>`` 542 ``CMake`` arguments as they are not visible in the GUI. 543 544 #. Set the variables specifying the *explicit* include directory 545 and library file to use: 546 547 - ``<DEPENDENCY_NAME (CAPS)>_INCLUDE_DIR`` 548 - ``<DEPENDENCY_NAME (CAPS)>_LIBRARY`` 549 550 This bypasses *all* searching in the 551 ``Find<DEPENDENCY_NAME>.cmake`` script, but validation is still 552 performed. 553 554 These variables are available to set in the ``CMake`` GUI. They 555 are visible in the *Standard View* if the library has not been 556 found (but the current Ceres configuration requires it), but 557 are always visible in the *Advanced View*. They can also be 558 set directly via ``-D<VAR>=<VALUE>`` arguments to ``CMake``. 559 560 Building using custom BLAS & LAPACK installs 561 ---------------------------------------------- 562 563 If the standard find package scripts for ``BLAS`` & ``LAPACK`` which ship with 564 ``CMake`` fail to find the desired libraries on your system, try setting 565 ``CMAKE_LIBRARY_PATH`` to the path(s) to the directories containing the 566 ``BLAS`` & ``LAPACK`` libraries when invoking ``CMake`` to build Ceres via 567 ``-D<VAR>=<VALUE>``. This should result in the libraries being found for any 568 common variant of each. 569 570 If you are building on an exotic system, or setting ``CMAKE_LIBRARY_PATH`` 571 does not work, or is not appropriate for some other reason, one option would be 572 to write your own custom versions of ``FindBLAS.cmake`` & 573 ``FindLAPACK.cmake`` specific to your environment. In this case you must set 574 ``CMAKE_MODULE_PATH`` to the directory containing these custom scripts when 575 invoking ``CMake`` to build Ceres and they will be used in preference to the 576 default versions. However, in order for this to work, your scripts must provide 577 the full set of variables provided by the default scripts. Also, if you are 578 building Ceres with ``SuiteSparse``, the versions of ``BLAS`` & ``LAPACK`` 579 used by ``SuiteSparse`` and Ceres should be the same. 580 581 .. _section-using-ceres: 582 583 Using Ceres with CMake 584 ====================== 585 586 Once the library is installed with ``make install``, it is possible to 587 use CMake with `FIND_PACKAGE() 588 <http://www.cmake.org/cmake/help/v2.8.10/cmake.html#command:find_package>`_ 589 in order to compile **user code** against Ceres. For example, for 590 `examples/helloworld.cc 591 <https://ceres-solver.googlesource.com/ceres-solver/+/master/examples/helloworld.cc>`_ 592 the following CMakeList.txt can be used: 593 594 .. code-block:: cmake 595 596 CMAKE_MINIMUM_REQUIRED(VERSION 2.8) 597 598 PROJECT(helloworld) 599 600 FIND_PACKAGE(Ceres REQUIRED) 601 INCLUDE_DIRECTORIES(${CERES_INCLUDE_DIRS}) 602 603 # helloworld 604 ADD_EXECUTABLE(helloworld helloworld.cc) 605 TARGET_LINK_LIBRARIES(helloworld ${CERES_LIBRARIES}) 606 607 Specify Ceres version 608 --------------------- 609 610 Additionally, when CMake has found Ceres it can check the package 611 version, if it has been specified in the `FIND_PACKAGE() 612 <http://www.cmake.org/cmake/help/v2.8.10/cmake.html#command:find_package>`_ 613 call. For example: 614 615 .. code-block:: cmake 616 617 FIND_PACKAGE(Ceres 1.2.3 REQUIRED) 618 619 The version is an optional argument. 620 621 Local installations 622 ------------------- 623 624 If Ceres was installed in a non-standard path by specifying 625 -DCMAKE_INSTALL_PREFIX="/some/where/local", then the user should add 626 the **PATHS** option to the ``FIND_PACKAGE()`` command. e.g., 627 628 .. code-block:: cmake 629 630 FIND_PACKAGE(Ceres REQUIRED PATHS "/some/where/local/") 631 632 Note that this can be used to have multiple versions of Ceres 633 installed. 634