summaryrefslogtreecommitdiffstats
path: root/Source
diff options
context:
space:
mode:
authorBrad King <brad.king@kitware.com>2023-01-13 16:55:56 (GMT)
committerBrad King <brad.king@kitware.com>2023-01-16 22:18:07 (GMT)
commit48292c8624b901a842b6d4f8a88ca00f898e5639 (patch)
tree3fe69130b088d51d082fb842d6d3688c874455a9 /Source
parentd4bf7d80c618930e6b88c35d271a5b0a0656bb7b (diff)
downloadCMake-48292c8624b901a842b6d4f8a88ca00f898e5639.zip
CMake-48292c8624b901a842b6d4f8a88ca00f898e5639.tar.gz
CMake-48292c8624b901a842b6d4f8a88ca00f898e5639.tar.bz2
try_compile: Record stack of in-progess checks in configure log
Many `try_compile` and `try_run` calls occur inside check modules between `message(CHECK_START)` and `message(CHECK_{PASS,FAIL})` pairs. Add a field to configure log entries to report this context. Issue: #23200
Diffstat (limited to 'Source')
-rw-r--r--Source/cmConfigureLog.cxx16
-rw-r--r--Source/cmConfigureLog.h1
-rw-r--r--Source/cmTryCompileCommand.cxx1
-rw-r--r--Source/cmTryRunCommand.cxx1
-rw-r--r--Source/cmake.h4
5 files changed, 23 insertions, 0 deletions
diff --git a/Source/cmConfigureLog.cxx b/Source/cmConfigureLog.cxx
index c2a5b5e..1b00b4f 100644
--- a/Source/cmConfigureLog.cxx
+++ b/Source/cmConfigureLog.cxx
@@ -17,6 +17,7 @@
#include "cmListFileCache.h"
#include "cmMakefile.h"
+#include "cmRange.h"
#include "cmStringAlgorithms.h"
#include "cmSystemTools.h"
#include "cmake.h"
@@ -78,6 +79,21 @@ void cmConfigureLog::WriteBacktrace(cmMakefile const& mf)
this->WriteValue("backtrace"_s, backtrace);
}
+void cmConfigureLog::WriteChecks(cmMakefile const& mf)
+{
+ if (!mf.GetCMakeInstance()->HasCheckInProgress()) {
+ return;
+ }
+ this->BeginObject("checks"_s);
+ for (auto const& value :
+ cmReverseRange(mf.GetCMakeInstance()->GetCheckInProgressMessages())) {
+ this->BeginLine() << "- ";
+ this->Encoder->write(value, &this->Stream);
+ this->EndLine();
+ }
+ this->EndObject();
+}
+
void cmConfigureLog::EnsureInit()
{
if (this->Opened) {
diff --git a/Source/cmConfigureLog.h b/Source/cmConfigureLog.h
index 9caac66..d672445 100644
--- a/Source/cmConfigureLog.h
+++ b/Source/cmConfigureLog.h
@@ -29,6 +29,7 @@ public:
bool IsAnyLogVersionEnabled(std::vector<unsigned long> const& v) const;
void WriteBacktrace(cmMakefile const& mf);
+ void WriteChecks(cmMakefile const& mf);
void EnsureInit();
diff --git a/Source/cmTryCompileCommand.cxx b/Source/cmTryCompileCommand.cxx
index ebbb4f2..789ffe9 100644
--- a/Source/cmTryCompileCommand.cxx
+++ b/Source/cmTryCompileCommand.cxx
@@ -27,6 +27,7 @@ void WriteTryCompileEvent(cmConfigureLog& log, cmMakefile const& mf,
if (log.IsAnyLogVersionEnabled(LogVersionsWithTryCompileV1)) {
log.BeginEvent("try_compile-v1");
log.WriteBacktrace(mf);
+ log.WriteChecks(mf);
cmCoreTryCompile::WriteTryCompileEventFields(log, compileResult);
log.EndEvent();
}
diff --git a/Source/cmTryRunCommand.cxx b/Source/cmTryRunCommand.cxx
index a8e8b48..21bd95a 100644
--- a/Source/cmTryRunCommand.cxx
+++ b/Source/cmTryRunCommand.cxx
@@ -46,6 +46,7 @@ void WriteTryRunEvent(cmConfigureLog& log, cmMakefile const& mf,
if (log.IsAnyLogVersionEnabled(LogVersionsWithTryRunV1)) {
log.BeginEvent("try_run-v1");
log.WriteBacktrace(mf);
+ log.WriteChecks(mf);
cmCoreTryCompile::WriteTryCompileEventFields(log, compileResult);
log.BeginObject("runResult"_s);
diff --git a/Source/cmake.h b/Source/cmake.h
index 12160ad..d1f388a 100644
--- a/Source/cmake.h
+++ b/Source/cmake.h
@@ -479,6 +479,10 @@ public:
{
this->CheckInProgressMessages.emplace_back(std::move(message));
}
+ std::vector<std::string> const& GetCheckInProgressMessages() const
+ {
+ return this->CheckInProgressMessages;
+ }
//! Should `message` command display context.
bool GetShowLogContext() const { return this->LogContext; }