Suggestion: add some CMAKE cheat-sheet items

150 views
Skip to first unread message

Dustin Lang

unread,
May 20, 2014, 5:21:03 PM5/20/14
to ceres-...@googlegroups.com
Hi,

I think it would be very useful to give a couple of hints about cmake in the Ceres build instructions page,
http://ceres-solver.org/building.html

For example, the fact that to specify a dynamic lib -- unlike ./configure and most other systems -- you have to give the full path to the .so.

Another big example: how do you tell ceres where to install itself.

Another: you recommend ATLAS, yet don't really say how to tell ceres where to find it, if it's not in the standard place.  And it's not at all obvious!

Half for my own future reference, here's what I had to do:

cmake ../ceres-solver-1.8.0 \
-DEIGEN_INCLUDE_DIR=${EIGEN_DIR}/include/eigen3 \
-DBLAS_LIBRARIES=${ATLAS_DIR}/lib/libsatlas.so \
-DLAPACK_LIBRARIES=${ATLAS_DIR}/lib/libsatlas.so \
-DSUITESPARSE_INCLUDE_DIR_HINTS=${SUITESPARSE_DIR}/include \
-DSUITESPARSE_LIBRARY_DIR_HINTS=${SUITESPARSE_DIR}/lib \
-DGFLAGS_INCLUDE_DIR=${GFLAGS_DIR}/include \
-DGFLAGS_LIBRARY=${GFLAGS_DIR}/lib/libgflags.a \
-DGLOG_INCLUDE_DIR=${GLOG_DIR}/include \
-DGLOG_LIBRARY=${GLOG_DIR}/lib/libglog.a \
-DBUILD_TESTING=FALSE \
-DBUILD_EXAMPLES=FALSE \
-DCMAKE_INSTALL_PREFIX=/tmp/ceres


Thanks,
--dustin

Dustin Lang

unread,
May 20, 2014, 5:39:25 PM5/20/14
to ceres-...@googlegroups.com
Err, make that


cmake ../ceres-solver-1.8.0 \
-DEIGEN_INCLUDE_DIR=${EIGEN_DIR}/include/eigen3 \
-DBLAS_LIBRARIES=${ATLAS_DIR}/lib/libsatlas.so \
-DLAPACK_LIBRARIES=${ATLAS_DIR}/lib/libsatlas.so \
-DSUITESPARSE_INCLUDE_DIR_HINTS=${SUITESPARSE_DIR}/include \
-DSUITESPARSE_LIBRARY_DIR_HINTS=${SUITESPARSE_DIR}/lib \
-DGFLAGS_INCLUDE_DIR=${GFLAGS_DIR}/include \
-DGFLAGS_LIBRARY=${GFLAGS_DIR}/lib/libgflags.so \
-DGLOG_INCLUDE_DIR=${GLOG_DIR}/include \
-DGLOG_LIBRARY=${GLOG_DIR}/lib/libglog.so \
-DBUILD_TESTING=FALSE \
-DBUILD_EXAMPLES=FALSE \
-DBUILD_SHARED_LIBS=ON \
-DCMAKE_INSTALL_PREFIX=/tmp/ceres

to build a shared lib.

(Still hunting down a problem with a missing symbol from ATLAS... argh)
--dstn


Sameer Agarwal

unread,
May 21, 2014, 1:36:45 AM5/21/14
to ceres-...@googlegroups.com
Dustin,
Would you mind sending a change to the documentation via Gerrit. I would gladly accept any changes that improve the build documentation.
Sameer



--
You received this message because you are subscribed to the Google Groups "Ceres Solver" group.
To unsubscribe from this group and stop receiving emails from it, send an email to ceres-solver...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/ceres-solver/c56ee0aa-fb36-4f00-a62b-cc0cd69b9beb%40googlegroups.com.

For more options, visit https://groups.google.com/d/optout.

Max Pfingsthorn

unread,
May 21, 2014, 3:01:01 AM5/21/14
to ceres-...@googlegroups.com
Dear Dustin, dear all,

cmake comes with interactive variants: ccmake (curses) and cmake-gui (qt). These have nice displays on what was found where, and the qt one even highlights missing deps in red. Since it displays all custom and some standard variables of the project with description (if it was supplied), it's quite easy to browse options for what you want. This includes the install target. 

The closest thing to this is ./configure --help

You can set the variables in the gui and generate your makefiles right there, eliminating the need for command line arguments to cmake proper.

Cheers,
max

Alex Stewart

unread,
May 21, 2014, 4:47:07 AM5/21/14
to ceres-...@googlegroups.com
Dustin,

The reason you're having problems / having to specify the libraries manually is because they are installed in non-standard locations.  The Find[Package/Library/File] functions in CMake automatically search a set of typical install locations depending upon the OS, and we add some more in the FindPackage scripts that ship with Ceres.

If all of your dependencies that are not installed in standard system locations were installed to the _same_ (non-standard) location <foo>/include & <foo>/lib, then you can set the variable CMAKE_PREFIX_PATH to <foo> and then everything should work without you having to specify any additional paths.  Note that CMAKE_PREFIX_PATH expects a single path.  If specified it ensures that the specified location is searched (with appropriate suffixes) by all of the CMake find functions in the FindPackage scripts (both the ones shipped with CMake, and the ones shipped with Ceres).


Note that if you disable the tests & examples, then gflags is not required.  For dependencies other than LAPACK & BLAS, you can use the variables 

<DEPENDENCY_NAME (CAPS)>_INCLUDE_DIR_HINTS
<DEPENDENCY_NAME (CAPS)>_LIBRARY_DIR_HINTS

To specify additional header & library directories to search without having to manually specify the individual libraries, I see you're doing this for SuiteSparse, but this also works for CXSparse, gflags & glog (and Eigen).


Max is quite right, using the CMake GUI (personally I prefer the ncurses one as it has fewer dependencies) is generally an easier way to experiment with these things, you will also see the options for the project clearly laid out with descriptions.  You may also want to use <t> in the GUI to toggle between the advanced and standard views.

If you are going to use the CMake GUI _and_ set values via -D though, please read the note above the section in the docs here:


In summary, -D always wins, if you pass -DFOO=BAR and attempt to change the value for FOO in the GUI, when you reconfigure FOO --> BAR again before generation.

-Alex

Dustin Lang

unread,
May 21, 2014, 8:33:08 AM5/21/14
to ceres-...@googlegroups.com
Indeed, my libraries are installed in non-standard places.  I'm working on the NERSC supercomputer "carver"
  www.nersc.gov/users/computational-systems/carver/
which uses the "modules" system to manage multiple versions of software installed in different places.  There is absolutely no chance of having everything installed within one base directory.  This is a completely typical situation on large shared machines.

Yes, ccmake helps a bit.  However, the HINTS options aren't exposed, so to tell it that SuiteSparse is in a non-standard location, you have to type the full path for amd, camd, cholmod, ccolamd, etcetc.  Annoying.  Also, it would be helpful if ccmake had an option (maybe it does?) to produce an equivalent cmake command-line.  It's nice to have an easily reproducible script for how a package was built.

Ok, so I can use the HINTS for other deps, but in another thread I'm trying to figure out how to ask Ceres to use MKL for BLAS/LAPACK, and failing...  any tips there?

thanks,
--dustin


Paul Furgale

unread,
May 21, 2014, 4:30:59 PM5/21/14
to ceres-...@googlegroups.com
Hi Dustin,
We have similar problems here when running on our computing cluster.
Instead, we switched to CDE, which allows us to build locally and deploy
the binaries.

http://pgbovine.net/cde.html

--
Dr. Paul Furgale
Deputy Director
Autonomous Systems Lab
ETH Zurich
http://www.asl.ethz.ch/
http://paulfurgale.info
> --
> You received this message because you are subscribed to the Google
> Groups "Ceres Solver" group.
> To unsubscribe from this group and stop receiving emails from it, send
> an email to ceres-solver...@googlegroups.com.
> To view this discussion on the web visit
> https://groups.google.com/d/msgid/ceres-solver/af6986da-45c2-4b3f-b0b9-f82f9daf48fb%40googlegroups.com.
Reply all
Reply to author
Forward
0 new messages