summaryrefslogtreecommitdiffstats
path: root/Source
diff options
context:
space:
mode:
authorBrad King <brad.king@kitware.com>2023-02-28 22:41:46 (GMT)
committerBrad King <brad.king@kitware.com>2023-02-28 23:07:36 (GMT)
commitb909be9e230af1767d7fdcb15a5266ab7c25fcfc (patch)
tree4acd8b2e42aedd6b245853ce17eba247acf9e4b1 /Source
parent4a3e79048b6afd7eb86f72b1365028e6233c92b0 (diff)
downloadCMake-b909be9e230af1767d7fdcb15a5266ab7c25fcfc.zip
CMake-b909be9e230af1767d7fdcb15a5266ab7c25fcfc.tar.gz
CMake-b909be9e230af1767d7fdcb15a5266ab7c25fcfc.tar.bz2
target_sources: Fix backtrace on missing source
If a source file is not found, the error message reports a backtrace. Previously the backtrace pointed at where the target was created. In the case of `target_sources`, the missing source may have been named elsewhere. Fixes: #24538
Diffstat (limited to 'Source')
-rw-r--r--Source/cmGeneratorTarget.cxx13
1 files changed, 6 insertions, 7 deletions
diff --git a/Source/cmGeneratorTarget.cxx b/Source/cmGeneratorTarget.cxx
index cfb2887..ca02509 100644
--- a/Source/cmGeneratorTarget.cxx
+++ b/Source/cmGeneratorTarget.cxx
@@ -1714,7 +1714,8 @@ void addFileSetEntry(cmGeneratorTarget const* headTarget,
std::move(entryCge), fileSet);
entries.Entries.emplace_back(
EvaluateTargetPropertyEntry(headTarget, config, "", dagChecker, tpe));
- for (auto const& file : entries.Entries.back().Values) {
+ EvaluatedTargetPropertyEntry const& entry = entries.Entries.back();
+ for (auto const& file : entry.Values) {
auto* sf = headTarget->Makefile->GetOrCreateSource(file);
if (fileSet->GetType() == "HEADERS"_s) {
sf->SetProperty("HEADER_FILE_ONLY", "TRUE");
@@ -1725,13 +1726,11 @@ void addFileSetEntry(cmGeneratorTarget const* headTarget,
std::string w;
auto path = sf->ResolveFullPath(&e, &w);
if (!w.empty()) {
- cm->IssueMessage(MessageType::AUTHOR_WARNING, w,
- headTarget->GetBacktrace());
+ cm->IssueMessage(MessageType::AUTHOR_WARNING, w, entry.Backtrace);
}
if (path.empty()) {
if (!e.empty()) {
- cm->IssueMessage(MessageType::FATAL_ERROR, e,
- headTarget->GetBacktrace());
+ cm->IssueMessage(MessageType::FATAL_ERROR, e, entry.Backtrace);
}
return;
}
@@ -1806,11 +1805,11 @@ bool processSources(cmGeneratorTarget const* tgt,
std::string fullPath = sf->ResolveFullPath(&e, &w);
cmake* cm = tgt->GetLocalGenerator()->GetCMakeInstance();
if (!w.empty()) {
- cm->IssueMessage(MessageType::AUTHOR_WARNING, w, tgt->GetBacktrace());
+ cm->IssueMessage(MessageType::AUTHOR_WARNING, w, entry.Backtrace);
}
if (fullPath.empty()) {
if (!e.empty()) {
- cm->IssueMessage(MessageType::FATAL_ERROR, e, tgt->GetBacktrace());
+ cm->IssueMessage(MessageType::FATAL_ERROR, e, entry.Backtrace);
}
return contextDependent;
}