You asked: (1) Is there an easy way to display these variables without having to run cmake in the CMakeLists.txt file and (2) without having to manually check the config.cmake file?
I can give you the answer "yes" (2), but it requires that you (re) run cmake. But since you can re-run your cmake configuration step by simply doing cmake . in the build directory, re-executing cmake should not stop you from trying this approach. My answer is given in this SO answer and uses the get_cmake_property command. Here is this code encapsulated in the cmake macro, print_all_variables , so I can use it when debugging my cmake scripts.
macro(print_all_variables) message(STATUS "print_all_variables------------------------------------------{") get_cmake_property(_variableNames VARIABLES) foreach (_variableName ${_variableNames}) message(STATUS "${_variableName}=${${_variableName}}") endforeach() message(STATUS "print_all_variables------------------------------------------}") endmacro()
source share