Executing bash commands from a CMake file

I think my main issue was the lack of quotes around my command arguments. Also, thanks to @Mark Setchell I realized I should be using OUTPUT_VARIABLE in lieu of OUTPUT

At any rate, here is the answer I arrived at:

execute_process (
    COMMAND bash -c "date +'%F %T'"
    OUTPUT_VARIABLE outVar
)

This stores the output of the bash command into the variable outVar

file(WRITE "datestamp" "${outVar}")

And this writes the contents of outVar to a file called “datestamp”.

Leave a Comment

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)