Running CMake for a project creates many variables that are required for its own operation and for the project being built. If you use the CMake GUI, then these are the variables which you see populated after you perform Configure and then Generate. When you want to diagnose a CMake build problem at the shell, it is useful to be able to view these variables.
- To perform a CMake build and then print the cache variables:
$ cmake -L ..
Note that in the above command, I am in the
build directory and the
CMakeLists.txt is in the parent directory. This command builds as usual and at the end prints the CMake variables and their values.
- To perform a CMake build and list all the cache variables, including advanced variables:
$ cmake -LA ..
Note that the number of variables that are printed can be quite high for big projects. I have seen it run into the hundreds.
- To perform a CMake build and list all the cache variables and print the help documentation about each variable too:
$ cmake -LAH ..
- If you have already done a CMake build and just need to print out the cache variables, add the
$ cmake -L -N
This command assumes that the current directory is the build directory containing the cache files, so no directory needs to be specified. This command is quick because it does not do a CMake build. Additionally, you can also add the
-AH options as before if you want.
Tried with: CMake 220.127.116.11 and Ubuntu 16.04