diff options
author | Matthew Woehlke <matthew.woehlke@kitware.com> | 2022-09-28 17:41:11 (GMT) |
---|---|---|
committer | Matthew Woehlke <matthew.woehlke@kitware.com> | 2022-09-28 17:41:11 (GMT) |
commit | 09b30515247b95358fa9126ce76e35f2d177c241 (patch) | |
tree | 6f629179462e2601bcd80e91ff297ced963f3ddf /Help/command | |
parent | 164a156c7c26aaf4f30e73ae0cdb6d2e8a10e0a4 (diff) | |
download | CMake-09b30515247b95358fa9126ce76e35f2d177c241.zip CMake-09b30515247b95358fa9126ce76e35f2d177c241.tar.gz CMake-09b30515247b95358fa9126ce76e35f2d177c241.tar.bz2 |
try_compile: Add NO_CACHE option (also try_run)
Add NO_CACHE option to try_compile and try_run, which places the results
in regular, rather than cache, variables.
Issue: #22799
Diffstat (limited to 'Help/command')
-rw-r--r-- | Help/command/try_compile.rst | 27 | ||||
-rw-r--r-- | Help/command/try_run.rst | 2 |
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>...] |