summaryrefslogtreecommitdiffstats
path: root/Help
diff options
context:
space:
mode:
authorleha-bot <leha-bot@yandex.ru>2024-01-05 16:12:22 (GMT)
committerleha-bot <leha-bot@yandex.ru>2024-01-16 07:41:31 (GMT)
commit1bb17692359d675eee12996c43446fa9c9fe5175 (patch)
tree4b303b56a54fd9c22bfbfc57d49feaa5f4feac34 /Help
parent4f160f7906ef8075dad54b9bf2e0ba204a1c41fc (diff)
downloadCMake-1bb17692359d675eee12996c43446fa9c9fe5175.zip
CMake-1bb17692359d675eee12996c43446fa9c9fe5175.tar.gz
CMake-1bb17692359d675eee12996c43446fa9c9fe5175.tar.bz2
cmake_language: Add EXIT subcommand
Add tests to cover these cases: * run as regular CMake module, in NORMAL_MODE (expected to fail); * run as CMake script in SCRIPT_MODE (expected to exit with given code); * run as CMake script that `include()`-s another script with EXIT subcommand; * run as CMake script which EVAL-uates EXIT subcommand via `cmake_language(EVAL CODE "<cmake code>")`. Fixes: #23162
Diffstat (limited to 'Help')
-rw-r--r--Help/command/cmake_language.rst23
-rw-r--r--Help/release/dev/cmake-language-exit.rst5
2 files changed, 28 insertions, 0 deletions
diff --git a/Help/command/cmake_language.rst b/Help/command/cmake_language.rst
index 4b64eb6..45ac569 100644
--- a/Help/command/cmake_language.rst
+++ b/Help/command/cmake_language.rst
@@ -15,6 +15,7 @@ Synopsis
cmake_language(`DEFER`_ <options>... CALL <command> [<arg>...])
cmake_language(`SET_DEPENDENCY_PROVIDER`_ <command> SUPPORTED_METHODS <methods>...)
cmake_language(`GET_MESSAGE_LOG_LEVEL`_ <out-var>)
+ cmake_language(`EXIT`_ <exit-code>)
Introduction
^^^^^^^^^^^^
@@ -506,3 +507,25 @@ Getting current message log level
If both the command line option and the variable are set, the command line
option takes precedence. If neither are set, the default logging level
is returned.
+
+Terminating Scripts
+^^^^^^^^^^^^^^^^^^^
+
+.. versionadded:: 3.29
+
+.. _EXIT:
+.. _exit-code:
+
+.. code-block:: cmake
+
+.. signature::
+ cmake_language(EXIT <exit-code>)
+
+ Terminate the current :option:`cmake -P` script and exit with ``<exit-code>``.
+
+ This command works only in :ref:`script mode <Script Processing Mode>`.
+
+ The ``<exit-code>`` should be non-negative.
+ If ``<exit-code>`` is negative then the behavior
+ is unspecified (e.g., on Windows the error code -1
+ becomes ``0xffffffff``, and on Linux it becomes ``255``).
diff --git a/Help/release/dev/cmake-language-exit.rst b/Help/release/dev/cmake-language-exit.rst
new file mode 100644
index 0000000..42e8ae2
--- /dev/null
+++ b/Help/release/dev/cmake-language-exit.rst
@@ -0,0 +1,5 @@
+cmake-language-exit
+-------------------
+
+* The :command:`cmake_language()` command gained a new ``EXIT``
+ sub-command to exit scripts with a specified exit code.