Files
cmake/Source/cmBinUtilsLinker.cxx
T
Matthew Woehlke a7415d243a Diagnostics: Simplify issuing policy warnings
Add and use a couple helper functions for issuing policy warnings. This
improves consistency and allows some simplification of many call sites.
(One or two instances in particular are greatly simplified.)
2026-05-20 11:55:13 -04:00

44 lines
1.1 KiB
C++

/* Distributed under the OSI-approved BSD 3-Clause License. See accompanying
file LICENSE.rst or https://cmake.org/licensing for details. */
#include "cmBinUtilsLinker.h"
#include <utility>
#include "cmCMakePath.h"
#include "cmMakefile.h"
#include "cmPolicies.h"
#include "cmRuntimeDependencyArchive.h"
#include "cmStringAlgorithms.h"
cmBinUtilsLinker::cmBinUtilsLinker(cmRuntimeDependencyArchive* archive)
: Archive(archive)
{
}
void cmBinUtilsLinker::SetError(std::string const& e)
{
this->Archive->SetError(e);
}
void cmBinUtilsLinker::NormalizePath(std::string& path) const
{
std::string normalizedPath =
cmCMakePath(path, cmCMakePath::auto_format).GenericString();
if (path == normalizedPath) {
return;
}
cmPolicies::PolicyStatus policy =
this->Archive->GetMakefile()->GetPolicyStatus(cmPolicies::CMP0207);
if (policy == cmPolicies::WARN) {
this->Archive->GetMakefile()->IssuePolicyWarning(
cmPolicies::CMP0207, {},
cmStrCat("Path\n \"", path, "\"\nwould be converted to\n \"",
normalizedPath, "\"\n"));
} else if (policy == cmPolicies::NEW) {
path = std::move(normalizedPath);
}
}