Feature Request: New CMake command cmake_exit(<exit-code>)
Hi,
We are using CMake more and more to do our general CI/CLI scripting for our C++ focused projects (using cmake -P <script-file>
a lot).
For cases where we reach an error-state in a script we currently only have message(FATAL_ERROR ...)
to exit the script early, which prints a full stack-trace alongside the error-message, and also sets the exit-code of cmake always to 1
.
We would really like to have a way to exit our CI/CLI scripts in such error cases, with explicitly setting the exit-code and also without any additional output to stdout/stderr.
A new CMake command like:
cmake_exit(<exit-code>)
Does this sound like a reasonable feature / maybe there would be interest in such a command by others ?! I would also be willing to make this feature-contribution myself, but first I wanted to check if this is a feature that would be accepted into main-line CMake (we don't want to use a custom-build CMake, we are really happy with all the features that CMake already has & supports so well)
Thanks