summaryrefslogtreecommitdiffstats
path: root/Source/cmTryRunCommand.cxx
diff options
context:
space:
mode:
authorMatthew Woehlke <matthew.woehlke@kitware.com>2022-09-28 17:41:11 (GMT)
committerMatthew Woehlke <matthew.woehlke@kitware.com>2022-09-28 17:41:11 (GMT)
commit09b30515247b95358fa9126ce76e35f2d177c241 (patch)
tree6f629179462e2601bcd80e91ff297ced963f3ddf /Source/cmTryRunCommand.cxx
parent164a156c7c26aaf4f30e73ae0cdb6d2e8a10e0a4 (diff)
downloadCMake-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 'Source/cmTryRunCommand.cxx')
-rw-r--r--Source/cmTryRunCommand.cxx12
1 files changed, 9 insertions, 3 deletions
diff --git a/Source/cmTryRunCommand.cxx b/Source/cmTryRunCommand.cxx
index 70c7cf1..1e81195 100644
--- a/Source/cmTryRunCommand.cxx
+++ b/Source/cmTryRunCommand.cxx
@@ -46,6 +46,7 @@ public:
std::string* runOutputStdOutContents,
std::string* runOutputStdErrContents);
+ bool NoCache;
std::string RunResultVariable;
};
@@ -57,6 +58,7 @@ bool TryRunCommandImpl::TryRunCode(std::vector<std::string> const& argv)
if (!arguments) {
return true;
}
+ this->NoCache = arguments.NoCache;
// although they could be used together, don't allow it, because
// using OUTPUT_VARIABLE makes crosscompiling harder
@@ -222,9 +224,13 @@ void TryRunCommandImpl::RunExecutable(const std::string& runArgs,
} else {
retStr = "FAILED_TO_RUN";
}
- this->Makefile->AddCacheDefinition(this->RunResultVariable, retStr,
- "Result of try_run()",
- cmStateEnums::INTERNAL);
+ if (this->NoCache) {
+ this->Makefile->AddDefinition(this->RunResultVariable, retStr);
+ } else {
+ this->Makefile->AddCacheDefinition(this->RunResultVariable, retStr,
+ "Result of try_run()",
+ cmStateEnums::INTERNAL);
+ }
}
/* This is only used when cross compiling. Instead of running the