How-to on cmake

Q&A for cmake

This Q&A is for the users of ohmms, qmcPlusPlus and other codes based on them.

Basic topics

1. Cannot find XYZ library
2. Why not use the C/C++ options provided by cmake?
3. I want to use MPI but my system uses mpic++.
4. cmake stops with the message Please set the following variables: MPI_LIBRARY (ADVANCED)
1.

Cannot find XYZ library

Check CMake/FindXYZ.cmake included with the source files. If XYZ_HOME is found among the environment variables, this should not happen but ocasionally an odd thing can happen. Then, edit the file CMake/FindXYZ.cmake. Look for PATHS and add the directory name to the list and cmake again.

2.

Why not use the C/C++ options provided by cmake?

The compiler options are chosen for very aggressive optimizations. Since different compiler versions behave so differently, we decide to use customized options and make developers or users choose their own, if necessary. Use the options as the references and feel free to experiment.

3.

I want to use MPI but my system uses mpic++.

Set CXX to mpic++. With csh/tcsh, setenv CXX mpic++

4.

cmake stops with the message “Please set the following variables: MPI_LIBRARY (ADVANCED)

This happens when you use a compiler wrapper, such as mpic++, as the compiler. Since all the MPI-related libraries will be correctly linked, you can simply edit CMakeCache.txt file to continue build/install. Look for the line:

//Where can one of the mpi or mpich libraries be found
MPI_LIBRARY:FILEPATH=MPI_LIBRARY-NOTFOUND

and change (simply remove MPI_LIBRARY-NOTFOUND)

//Where can one of the mpi or mpich libraries be found
MPI_LIBRARY:FILEPATH=

When a similar message is issued, two possibilities are i) you don't need to specify it (already included) or ii) the library is not where it is supposed be. First step is to remove XYZ_LIBRARY-NOTFOUND, and move on.