Can you use message? Here is a sample from a useful script from cmake.
# the compiler flags for compiling C sources
MESSAGE( STATUS "CMAKE_C_FLAGS: " ${CMAKE_C_FLAGS} )
# the compiler flags for compiling C++ sources
MESSAGE( STATUS "CMAKE_CXX_FLAGS: " ${CMAKE_CXX_FLAGS} )
Otherwise, I will often compile with a verbose mode. Since I use Ninja as my generator, it looks like this:
cmake .. -GNinja
ninja -v
The output to console contains the full compilation command which in my case looks something like this:
[1/2] C:\msys64\mingw32\bin\c++.exe -D<Defines> -I<Includes> -isystem C:/msys64/mingw32/include -g -MD -MT <object>.obj -MF <object>.obj.d -o <object>.obj -c <object>.cpp
[2/2] C:\msys64\mingw32\bin\c++.exe -g <object1>.obj <object2>.obj <objectN>.obj -o <Application>.exe -Wl,--major-image-version,0,--minor-image-version,0 <library1>.dll.a <library2>.dll.a -l<systemlib1> -l<systemlib2>
You can also try setting set( CMAKE_VERBOSE_MAKEFILE on )
in your CMakeLists.txt or cmake .. -DCMAKE_VERBOSE_MAKEFILE=ON
at the command line to try it from cmake without using your generator. You can check out that variable here.