In CMakeLists.txt
, is there a way to know whether the file was executed from a terminal or via a gui (of some form, e.g. ccmake
or cmake-gui
)? CMAKE_COMMAND
and CMAKE_EDIT_COMMAND
are both populated regardless of whether I am running cmake
or ccmake
.
I was searching through the variables and these two seemed the most promising. I have become enamored with colorizing cmake output, the many wonderful answers there have their drawbacks. Namely, I can either get:
ccmake
.ccmake
terminal is overwritten by colorized output (LOL).Just curious if there is a way to determine this in the CMakeLists.txt
. There were variables for script mode (-P
) that seemed potentially helpful, but I think I would first need to know which executable (cmake
or ccmake
) called my CMakeLists.txt
in the first place.
As far as I know, there is no way to distinguish whether the code was invoked from CMake or from CMake-gui. The code should behave in the same way, everything else would be a surprise for the user.
You could try to detect whether an instance of CMake-gui is running, but this is error-prone and is not justified for real use cases.