Help: Note try_compile/try_run caching

This commit is contained in:
scivision 2024-12-17 12:39:18 -05:00 committed by Brad King
parent abb3d39bbc
commit 9be6e42499
2 changed files with 16 additions and 13 deletions

View File

@ -92,10 +92,11 @@ Try Compiling Source Files
.. versionadded:: 3.25
Try building an executable or static library from one or more source files
(which one is determined by the :variable:`CMAKE_TRY_COMPILE_TARGET_TYPE`
variable). Build success returns ``TRUE`` and build failure returns ``FALSE``
in ``<compileResultVar>``.
Try building an executable or static library from one or more source files.
The binary type is determined by variable
:variable:`CMAKE_TRY_COMPILE_TARGET_TYPE`.
Build success returns boolean ``true`` and build failure returns boolean
``false`` in ``<compileResultVar>`` (cached unless ``NO_CACHE`` is specified).
In this form, one or more source files must be provided. Additionally, one of
``SOURCES`` and/or ``SOURCE_FROM_*`` must precede other keywords.
@ -211,9 +212,10 @@ The options for the above signatures are:
``NO_CACHE``
.. versionadded:: 3.25
The result will be stored in a normal variable rather than a cache entry.
``<compileResultVar>`` will be stored in a normal variable rather than a
cache entry.
The result variable is normally cached so that a simple pattern can be used
``<compileResultVar>`` is normally cached so that a simple pattern can be used
to avoid repeating the test on subsequent executions of CMake:
.. code-block:: cmake

View File

@ -40,13 +40,14 @@ Try Compiling and Running Source Files
.. versionadded:: 3.25
Try building an executable from one or more source files. Build success
returns ``TRUE`` and build failure returns ``FALSE`` in ``<compileResultVar>``.
If the build succeeds, this runs the executable and stores the exit code in
``<runResultVar>``. If the executable was built, but failed to run, then
``<runResultVar>`` will be set to ``FAILED_TO_RUN``. See command
:command:`try_compile` for documentation of options common to both commands,
and for information on how the test project is constructed to build the source
file.
returns boolean ``true`` and build failure returns boolean ``false`` in
``<compileResultVar>`` (cached unless ``NO_CACHE`` is specified).
If the build succeeds, this runs the executable and stores the exit code
in ``<runResultVar>`` (cached unless ``NO_CACHE`` is specified).
If the executable was built, but failed to run, then ``<runResultVar>``
will be set to ``FAILED_TO_RUN``. See command :command:`try_compile` for
documentation of options common to both commands, and for information on
how the test project is constructed to build the source file.
One or more source files must be provided. Additionally, one of ``SOURCES``
and/or ``SOURCE_FROM_*`` must precede other keywords.