checking if installation script is launch in a terminal

Hi, on installing a target, I launch a cmake script (set with install(SCRIPT...) which, in turn launch shell scripts (with execute_process) in order to prompt the user for some “last minute” input.
Yet if my installation command is launched in a non-interactive way, I’d like to bypass this prompt and resort to default values.
How can I do?

more precisely, the normal situation would be something like that in a terminal:

make install
<prompt user>
<finishing install>

But if I’m not in a terminal (for instance, launching the installation from a daemon at a given hour), I would like to replace <prompt user> by <set default values>

Visibly, I cannot do that from the prompting shell which is already considered as non interactive, as it is launched from cmake script.

A basic workaround would be to pass an additionnal option at configuration time to ask for an install with or without prompt but an automated solution would be better for me.

Thanks, regards
A.

I think CMake could probably learn to pass stdin down to execute_process as-is, but this would be a new flag/feature (not sure if the install would use it by default either). That would let your prompt script do the normal isatty checks on stdin. You may want to ask an environment variable before falling back to a default too as well (not sure if you’d prefer the envvar suppressing the manual request or to act as a fallback only if the prompt can’t be asked).

Is there a way to do this check in cmake? Yet I’m unsure if the pertinence of the output.
For instance, when checking $- == *i* in my prompting script, it tells me that its a non-interactive shell (which is kind of logic, as it is called from inside a cmake execute_process that, I think, is forking a sub-shell).
But maybe that isatty will not give the same info (are we in an interactive terminal instead of is it an interactive shell)?

Besides, I would need an equivalent solution for windows system also.

Thanks

I don’t think so, no.