Hi was using the mailinglist before, but was told that is kinda dead and I should be asking here.
I’m writing a patch for cmake to address https://gitlab.kitware.com/cmake/cmake/issues/19703
For this I need to generate a rule (aka, a Makefile rule) that will create a given file if
it doesn’t exist yet or if the user supplied COMMAND returns some exit code.
I’m not familiar with all the platforms that cmake supports (in fact, I’m only knowledgeable on linux/UNIX,
but assuming that this will include MacOS when it comes to shell scripting?), so I’d like to know the following:
Will an exit code (failure or success being enough, but a specific exit value would be nice) always be available for a given user COMMAND?
Am I correct that the COMMAND of add_custom_command is already executed in some shell? If so, what are the common traits of this shell?
Assuming there is no common trait that will allow me to simply generate general shell code, aka POSIX shell code:
if ${custom_command} || ! test -e ${stamp_file}; then
${CMAKE_COMMAND} -E touch ${stamp_file}
fi
then what is the correct way to generate a rule that has this functionality with cmake?
On the mailinglist Hendrik Sattler pointed out that I could use ‘&&’ (and hence I presume ‘||’) at
the very least based on the fact that currently cmake generates rules containing:
cd /path/to/workingdir && ${CMAKE_COMMAND} -E touch ${stamp_file}
However, if I look at cmake’s code then the working directory is passed deep into cmake
functions down to operating system dependent implementations, so I am not convinced
anymore that even ‘&&’ is guaranteed to work on every platform.
How can I do this?
Thanks for any help,
Carlo Wood