summaryrefslogtreecommitdiffstats
path: root/Source
diff options
context:
space:
mode:
authorBrad King <brad.king@kitware.com>2023-01-13 16:19:29 (GMT)
committerBrad King <brad.king@kitware.com>2023-01-16 21:58:50 (GMT)
commit9d9e8450a872a4a9ec1a74cc7a73df100c32c7e8 (patch)
tree0ccb5c395ecf839e8d3d8252a4df0ddd563221cc /Source
parent65ed5c2ca816f8ba4068b163a2dcdab079df0038 (diff)
downloadCMake-9d9e8450a872a4a9ec1a74cc7a73df100c32c7e8.zip
CMake-9d9e8450a872a4a9ec1a74cc7a73df100c32c7e8.tar.gz
CMake-9d9e8450a872a4a9ec1a74cc7a73df100c32c7e8.tar.bz2
try_compile: Add optional LOG_DESCRIPTION to record in configure log
Issue: #23200
Diffstat (limited to 'Source')
-rw-r--r--Source/cmCoreTryCompile.cxx7
-rw-r--r--Source/cmCoreTryCompile.h3
2 files changed, 10 insertions, 0 deletions
diff --git a/Source/cmCoreTryCompile.cxx b/Source/cmCoreTryCompile.cxx
index 1883816..29f6a98 100644
--- a/Source/cmCoreTryCompile.cxx
+++ b/Source/cmCoreTryCompile.cxx
@@ -151,6 +151,7 @@ cmArgumentParser<Arguments> makeTryRunParser(
auto const TryCompileBaseArgParser =
cmArgumentParser<Arguments>{}
.Bind(0, &Arguments::CompileResultVariable)
+ .Bind("LOG_DESCRIPTION"_s, &Arguments::LogDescription)
.Bind("NO_CACHE"_s, &Arguments::NoCache)
.Bind("CMAKE_FLAGS"_s, &Arguments::CMakeFlags)
.Bind("__CMAKE_INTERNAL"_s, &Arguments::CMakeInternal)
@@ -1138,6 +1139,9 @@ cm::optional<cmTryCompileResult> cmCoreTryCompile::TryCompileCode(
}
cmTryCompileResult result;
+ if (arguments.LogDescription) {
+ result.LogDescription = *arguments.LogDescription;
+ }
result.SourceDirectory = sourceDirectory;
result.BinaryDirectory = this->BinaryDirectory;
result.Variable = *arguments.CompileResultVariable;
@@ -1290,6 +1294,9 @@ void cmCoreTryCompile::WriteTryCompileEventFields(
cmConfigureLog& log, cmTryCompileResult const& compileResult)
{
#ifndef CMAKE_BOOTSTRAP
+ if (compileResult.LogDescription) {
+ log.WriteValue("description"_s, *compileResult.LogDescription);
+ }
log.BeginObject("directories"_s);
log.WriteValue("source"_s, compileResult.SourceDirectory);
log.WriteValue("binary"_s, compileResult.BinaryDirectory);
diff --git a/Source/cmCoreTryCompile.h b/Source/cmCoreTryCompile.h
index 6d29586..efd58e5 100644
--- a/Source/cmCoreTryCompile.h
+++ b/Source/cmCoreTryCompile.h
@@ -21,6 +21,8 @@ class cmRange;
struct cmTryCompileResult
{
+ cm::optional<std::string> LogDescription;
+
std::string SourceDirectory;
std::string BinaryDirectory;
@@ -71,6 +73,7 @@ public:
cm::optional<std::string> OutputVariable;
cm::optional<std::string> CopyFileTo;
cm::optional<std::string> CopyFileError;
+ cm::optional<ArgumentParser::NonEmpty<std::string>> LogDescription;
bool NoCache = false;
// Argument for try_run only.