macro: Add policy to preserve backslashes in arguments

Preserve backslashes in arguments passed to macros by re-escaping
them before substituting in the macro body, where they will be
parsed again.

Fixes: #19281, #22157, #23641, #25803, #27645, #20891
This commit is contained in:
Alex Reinking
2026-05-31 14:36:15 -04:00
parent d0deabd995
commit 9d2e85373a
54 changed files with 771 additions and 7 deletions
+15
View File
@@ -1186,6 +1186,20 @@ public:
cm::optional<std::string> DeferGetCallIds() const;
cm::optional<std::string> DeferGetCall(std::string const& id) const;
//! Check CMP0219 policy status for the given callee and arguments.
//! Returns the effective policy status: OLD, NEW, or WARN (only on
//! first occurrence of calleeName with backslashes present). The
//! caller is responsible for issuing any warning when WARN is returned.
cmPolicies::PolicyStatus CheckCMP0219(std::string const& calleeName,
std::vector<std::string> const& args);
cmPolicies::PolicyStatus CheckCMP0219(
std::string const& calleeName,
std::vector<cmListFileArgument> const& args);
void IssueCMP0219Warning(std::string const& calleeName,
std::vector<std::string> const& args) const;
void IssueCMP0219Warning(std::string const& calleeName,
std::vector<cmListFileArgument> const& args) const;
protected:
// add link libraries and directories to the target
void AddGlobalLinkInformation(cmTarget& target);
@@ -1350,6 +1364,7 @@ private:
bool CheckCMP0000;
std::set<std::string> WarnedCMP0074;
std::set<std::string> WarnedCMP0144;
std::set<std::string> WarnedCMP0219;
bool IsSourceFileTryCompile;
ImportedTargetScope CurrentImportedTargetScope = ImportedTargetScope::Local;
};