
There is more
Sometimes, packages are not installed in standard locations and CMake might fail to locate them correctly. It is possible to tell CMake to look into certain specific locations to find certain software using the CLI switch -D to pass the appropriate option. In the case of the Python interpreter, you may configure with the following:
$ cmake -D PYTHON_EXECUTABLE=/custom/location/python ..
This will correctly identify the Python executable in the non-standard /custom/location/python installation directory.
Independently of detecting packages, we would like to mention a handy helper module for printing variables. In this recipe, we have used the following:
message(STATUS "RESULT_VARIABLE is: ${_status}")
message(STATUS "OUTPUT_VARIABLE is: ${_hello_world}")
A handy alternative for debugging is to use the following:
include(CMakePrintHelpers)
cmake_print_variables(_status _hello_world)
This produces the following output:
-- _status="0" ; _hello_world="Hello, world!"
For more documentation on convenience macros for printing properties and variables, see https://cmake.org/cmake/help/v3.5/module/CMakePrintHelpers.html.