diff options
author | Brad King <brad.king@kitware.com> | 2022-09-29 11:58:52 (GMT) |
---|---|---|
committer | Kitware Robot <kwrobot@kitware.com> | 2022-09-29 11:59:02 (GMT) |
commit | cadcb6a5f0e1ebaefd74f8c52151e410c57cfa96 (patch) | |
tree | 7f8c0b72d3d8e7a01cc06262fa1ef37047503217 /Source | |
parent | b1ecce8ae7b8aea03b98f11335ca6514b425e7c5 (diff) | |
parent | 09b30515247b95358fa9126ce76e35f2d177c241 (diff) | |
download | CMake-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 'Source')
-rw-r--r-- | Source/cmCoreTryCompile.cxx | 12 | ||||
-rw-r--r-- | Source/cmCoreTryCompile.h | 1 | ||||
-rw-r--r-- | Source/cmTryRunCommand.cxx | 12 |
3 files changed, 19 insertions, 6 deletions
diff --git a/Source/cmCoreTryCompile.cxx b/Source/cmCoreTryCompile.cxx index f40b3e9..323790e 100644 --- a/Source/cmCoreTryCompile.cxx +++ b/Source/cmCoreTryCompile.cxx @@ -149,6 +149,7 @@ cmArgumentParser<Arguments> makeTryRunParser( auto const TryCompileBaseArgParser = cmArgumentParser<Arguments>{} .Bind(0, &Arguments::CompileResultVariable) + .Bind("NO_CACHE"_s, &Arguments::NoCache) .Bind("CMAKE_FLAGS"_s, &Arguments::CMakeFlags) .Bind("__CMAKE_INTERNAL"_s, &Arguments::CMakeInternal) /* keep semicolon on own line */; @@ -1061,9 +1062,14 @@ bool cmCoreTryCompile::TryCompileCode(Arguments& arguments, } // set the result var to the return value to indicate success or failure - this->Makefile->AddCacheDefinition( - *arguments.CompileResultVariable, (res == 0 ? "TRUE" : "FALSE"), - "Result of TRY_COMPILE", cmStateEnums::INTERNAL); + if (arguments.NoCache) { + this->Makefile->AddDefinition(*arguments.CompileResultVariable, + (res == 0 ? "TRUE" : "FALSE")); + } else { + this->Makefile->AddCacheDefinition( + *arguments.CompileResultVariable, (res == 0 ? "TRUE" : "FALSE"), + "Result of TRY_COMPILE", cmStateEnums::INTERNAL); + } if (arguments.OutputVariable) { this->Makefile->AddDefinition(*arguments.OutputVariable, output); diff --git a/Source/cmCoreTryCompile.h b/Source/cmCoreTryCompile.h index 3f4a4dc..d4c9466 100644 --- a/Source/cmCoreTryCompile.h +++ b/Source/cmCoreTryCompile.h @@ -58,6 +58,7 @@ public: cm::optional<std::string> OutputVariable; cm::optional<std::string> CopyFileTo; cm::optional<std::string> CopyFileError; + bool NoCache = false; // Argument for try_run only. // Keep in sync with warnings in cmCoreTryCompile::ParseArgs. 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 |