From ad4487a96ae6e7e93e9b14d0fee67da01e27e12a Mon Sep 17 00:00:00 2001 From: Ben Boeckel Date: Tue, 21 Apr 2020 10:58:34 -0400 Subject: cmIncludeCommand: add infrastructure for deprecated modules --- Source/cmIncludeCommand.cxx | 32 +++++++++++++++++++++++++++++++- 1 file changed, 31 insertions(+), 1 deletion(-) diff --git a/Source/cmIncludeCommand.cxx b/Source/cmIncludeCommand.cxx index 14264f4..019483e 100644 --- a/Source/cmIncludeCommand.cxx +++ b/Source/cmIncludeCommand.cxx @@ -2,7 +2,9 @@ file Copyright.txt or https://cmake.org/licensing for details. */ #include "cmIncludeCommand.h" +#include #include +#include #include "cmExecutionStatus.h" #include "cmGlobalGenerator.h" @@ -16,6 +18,8 @@ bool cmIncludeCommand(std::vector const& args, cmExecutionStatus& status) { + static std::map DeprecatedModules; + if (args.empty() || args.size() > 4) { status.SetError("called with wrong number of arguments. " "include() only takes one file."); @@ -65,9 +69,35 @@ bool cmIncludeCommand(std::vector const& args, } if (!cmSystemTools::FileIsFullPath(fname)) { + bool system = false; // Not a path. Maybe module. std::string module = cmStrCat(fname, ".cmake"); - std::string mfile = status.GetMakefile().GetModulesFile(module); + std::string mfile = status.GetMakefile().GetModulesFile(module, system); + + if (system) { + auto ModulePolicy = DeprecatedModules.find(fname); + if (ModulePolicy != DeprecatedModules.end()) { + cmPolicies::PolicyStatus PolicyStatus = + status.GetMakefile().GetPolicyStatus(ModulePolicy->second); + switch (PolicyStatus) { + case cmPolicies::WARN: { + status.GetMakefile().IssueMessage( + MessageType::AUTHOR_WARNING, + cmStrCat(cmPolicies::GetPolicyWarning(ModulePolicy->second), + "\n")); + CM_FALLTHROUGH; + } + case cmPolicies::OLD: + break; + case cmPolicies::REQUIRED_IF_USED: + case cmPolicies::REQUIRED_ALWAYS: + case cmPolicies::NEW: + mfile = ""; + break; + } + } + } + if (!mfile.empty()) { fname = mfile; } -- cgit v0.12