summaryrefslogtreecommitdiffstats
path: root/Help/command
diff options
context:
space:
mode:
authorBrad King <brad.king@kitware.com>2022-09-29 11:58:52 (GMT)
committerKitware Robot <kwrobot@kitware.com>2022-09-29 11:59:02 (GMT)
commitcadcb6a5f0e1ebaefd74f8c52151e410c57cfa96 (patch)
tree7f8c0b72d3d8e7a01cc06262fa1ef37047503217 /Help/command
parentb1ecce8ae7b8aea03b98f11335ca6514b425e7c5 (diff)
parent09b30515247b95358fa9126ce76e35f2d177c241 (diff)
downloadCMake-cadcb6a5f0e1ebaefd74f8c52151e410c57cfa96.zip
CMake-cadcb6a5f0e1ebaefd74f8c52151e410c57cfa96.tar.gz
CMake-cadcb6a5f0e1ebaefd74f8c52151e410c57cfa96.tar.bz2
Merge topic 'try_compile-no-cache'
09b3051524 try_compile: Add NO_CACHE option (also try_run) Acked-by: Kitware Robot <kwrobot@kitware.com> Acked-by: buildbot <buildbot@kitware.com> Merge-request: !7723
Diffstat (limited to 'Help/command')
-rw-r--r--Help/command/try_compile.rst27
-rw-r--r--Help/command/try_run.rst2
2 files changed, 28 insertions, 1 deletions
diff --git a/Help/command/try_compile.rst b/Help/command/try_compile.rst
index 4632cd9..6cb4f99 100644
--- a/Help/command/try_compile.rst
+++ b/Help/command/try_compile.rst
@@ -18,6 +18,7 @@ Try Compiling Whole Projects
SOURCE_DIR <srcdir>
[BINARY_DIR <bindir>]
[TARGET <targetName>]
+ [NO_CACHE]
[CMAKE_FLAGS <flags>...]
[OUTPUT_VARIABLE <var>])
@@ -45,7 +46,9 @@ which was present in older versions of CMake:
.. code-block:: cmake
try_compile(<resultVar> <bindir> <srcdir>
- <projectName> [<targetName>] [CMAKE_FLAGS <flags>...]
+ <projectName> [<targetName>]
+ [NO_CACHE]
+ [CMAKE_FLAGS <flags>...]
[OUTPUT_VARIABLE <var>])
.. _`Try Compiling Source Files`:
@@ -60,6 +63,7 @@ Try Compiling Source Files
SOURCE_FROM_ARG <name> <content>] |
SOURCE_FROM_VAR <name> <var>] |
SOURCE_FROM_FILE <name> <path> >...
+ [NO_CACHE]
[CMAKE_FLAGS <flags>...]
[COMPILE_DEFINITIONS <defs>...]
[LINK_OPTIONS <options>...]
@@ -111,6 +115,7 @@ which was present in older versions of CMake:
.. code-block:: cmake
try_compile(<resultVar> <bindir> <srcfile|SOURCES srcfile...>
+ [NO_CACHE]
[CMAKE_FLAGS <flags>...]
[COMPILE_DEFINITIONS <defs>...]
[LINK_OPTIONS <options>...]
@@ -166,6 +171,26 @@ The options are:
set the :prop_tgt:`STATIC_LIBRARY_OPTIONS` target property in the generated
project, depending on the :variable:`CMAKE_TRY_COMPILE_TARGET_TYPE` variable.
+``NO_CACHE``
+ .. versionadded:: 3.25
+
+ The result 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
+ to avoid repeating the test on subsequent executions of CMake:
+
+ .. code-block:: cmake
+
+ if(NOT DEFINED RESULTVAR)
+ # ...(check-specific setup code)...
+ try_compile(RESULTVAR ...)
+ # ...(check-specific logging and cleanup code)...
+ endif()
+
+ If the guard variable and result variable are not the same (for example, if
+ the test is part of a larger inspection), ``NO_CACHE`` may be useful to avoid
+ leaking the intermediate result variable into the cache.
+
``OUTPUT_VARIABLE <var>``
Store the output from the build process in the given variable.
diff --git a/Help/command/try_run.rst b/Help/command/try_run.rst
index efc10ec..8393e1b 100644
--- a/Help/command/try_run.rst
+++ b/Help/command/try_run.rst
@@ -17,6 +17,7 @@ Try Compiling and Running Source Files
SOURCE_FROM_ARG <name> <content>] |
SOURCE_FROM_VAR <name> <var>] |
SOURCE_FROM_FILE <name> <path> >...
+ [NO_CACHE]
[CMAKE_FLAGS <flags>...]
[COMPILE_DEFINITIONS <defs>...]
[LINK_OPTIONS <options>...]
@@ -54,6 +55,7 @@ which was present in older versions of CMake:
try_run(<runResultVar> <compileResultVar>
<bindir> <srcfile|SOURCES srcfile...>
+ [NO_CACHE]
[CMAKE_FLAGS <flags>...]
[COMPILE_DEFINITIONS <defs>...]
[LINK_OPTIONS <options>...]