summaryrefslogtreecommitdiffstats
path: root/Source
diff options
context:
space:
mode:
authorKyle Edwards <kyle.edwards@kitware.com>2018-10-31 17:26:04 (GMT)
committerBrad King <brad.king@kitware.com>2018-11-14 20:05:06 (GMT)
commit0f5c1b404b0f9cbe652cf306e9dca0c25c70876f (patch)
tree3040a94e2f7f8f9e0de4a8bd13debbe665ea997a /Source
parentddb967cca1a37501dcf3fbd6f64c2d3be1c0c82b (diff)
downloadCMake-0f5c1b404b0f9cbe652cf306e9dca0c25c70876f.zip
CMake-0f5c1b404b0f9cbe652cf306e9dca0c25c70876f.tar.gz
CMake-0f5c1b404b0f9cbe652cf306e9dca0c25c70876f.tar.bz2
find_package(): Add policy to remove the FindQt module
Removing FindQt.cmake gives Qt upstream a path forward to export its own QtConfig.cmake files which can be found by find_package() without having to explicitly specify CONFIG. Projects that still want to use Qt3/4 can call find_package(Qt[34]), include(FindQt), or add FindQt.cmake to their CMAKE_MODULE_PATH.
Diffstat (limited to 'Source')
-rw-r--r--Source/cmFindPackageCommand.cxx27
-rw-r--r--Source/cmFindPackageCommand.h3
-rw-r--r--Source/cmMakefile.cxx7
-rw-r--r--Source/cmMakefile.h8
-rw-r--r--Source/cmPolicies.h5
5 files changed, 46 insertions, 4 deletions
diff --git a/Source/cmFindPackageCommand.cxx b/Source/cmFindPackageCommand.cxx
index 97c1d7d..bf928fc 100644
--- a/Source/cmFindPackageCommand.cxx
+++ b/Source/cmFindPackageCommand.cxx
@@ -111,6 +111,8 @@ cmFindPackageCommand::cmFindPackageCommand()
this->SortOrder = None;
this->SortDirection = Asc;
this->AppendSearchPathGroups();
+
+ this->DeprecatedFindModules["Qt"] = cmPolicies::CMP0084;
}
void cmFindPackageCommand::AppendSearchPathGroups()
@@ -653,8 +655,31 @@ bool cmFindPackageCommand::FindModule(bool& found)
std::string module = "Find";
module += this->Name;
module += ".cmake";
- std::string mfile = this->Makefile->GetModulesFile(module.c_str());
+ bool system = false;
+ std::string mfile = this->Makefile->GetModulesFile(module.c_str(), system);
if (!mfile.empty()) {
+ if (system) {
+ auto it = this->DeprecatedFindModules.find(this->Name);
+ if (it != this->DeprecatedFindModules.end()) {
+ cmPolicies::PolicyStatus status =
+ this->Makefile->GetPolicyStatus(it->second);
+ switch (status) {
+ case cmPolicies::WARN: {
+ std::ostringstream e;
+ e << cmPolicies::GetPolicyWarning(it->second) << "\n";
+ this->Makefile->IssueMessage(cmake::AUTHOR_WARNING, e.str());
+ CM_FALLTHROUGH;
+ }
+ case cmPolicies::OLD:
+ break;
+ case cmPolicies::REQUIRED_IF_USED:
+ case cmPolicies::REQUIRED_ALWAYS:
+ case cmPolicies::NEW:
+ return true;
+ }
+ }
+ }
+
// Load the module we found, and set "<name>_FIND_MODULE" to true
// while inside it.
found = true;
diff --git a/Source/cmFindPackageCommand.h b/Source/cmFindPackageCommand.h
index 48f17ef..05bad49 100644
--- a/Source/cmFindPackageCommand.h
+++ b/Source/cmFindPackageCommand.h
@@ -4,6 +4,7 @@
#define cmFindPackageCommand_h
#include "cmConfigure.h" // IWYU pragma: keep
+#include "cmPolicies.h"
#include "cm_kwiml.h"
#include <cstddef>
@@ -148,6 +149,8 @@ private:
};
std::map<std::string, OriginalDef> OriginalDefs;
+ std::map<std::string, cmPolicies::PolicyID> DeprecatedFindModules;
+
std::string Name;
std::string Variable;
std::string Version;
diff --git a/Source/cmMakefile.cxx b/Source/cmMakefile.cxx
index 0d42fb0..790f6e0 100644
--- a/Source/cmMakefile.cxx
+++ b/Source/cmMakefile.cxx
@@ -3500,7 +3500,8 @@ void cmMakefile::DisplayStatus(const char* message, float s) const
cm->UpdateProgress(message, s);
}
-std::string cmMakefile::GetModulesFile(const char* filename) const
+std::string cmMakefile::GetModulesFile(const char* filename,
+ bool& system) const
{
std::string result;
@@ -3547,8 +3548,10 @@ std::string cmMakefile::GetModulesFile(const char* filename) const
// Normally, prefer the files found in CMAKE_MODULE_PATH. Only when the file
// from which we are being called is located itself in CMAKE_ROOT, then
// prefer results from CMAKE_ROOT depending on the policy setting.
+ system = false;
result = moduleInCMakeModulePath;
if (result.empty()) {
+ system = true;
result = moduleInCMakeRoot;
}
@@ -3571,11 +3574,13 @@ std::string cmMakefile::GetModulesFile(const char* filename) const
CM_FALLTHROUGH;
}
case cmPolicies::OLD:
+ system = false;
result = moduleInCMakeModulePath;
break;
case cmPolicies::REQUIRED_IF_USED:
case cmPolicies::REQUIRED_ALWAYS:
case cmPolicies::NEW:
+ system = true;
result = moduleInCMakeRoot;
break;
}
diff --git a/Source/cmMakefile.h b/Source/cmMakefile.h
index d8176d9..aa94054 100644
--- a/Source/cmMakefile.h
+++ b/Source/cmMakefile.h
@@ -689,7 +689,13 @@ public:
/**
* Return a location of a file in cmake or custom modules directory
*/
- std::string GetModulesFile(const char* name) const;
+ std::string GetModulesFile(const char* name) const
+ {
+ bool system;
+ return this->GetModulesFile(name, system);
+ }
+
+ std::string GetModulesFile(const char* name, bool& system) const;
///! Set/Get a property of this directory
void SetProperty(const std::string& prop, const char* value);
diff --git a/Source/cmPolicies.h b/Source/cmPolicies.h
index 52ef470..6b1314f 100644
--- a/Source/cmPolicies.h
+++ b/Source/cmPolicies.h
@@ -246,7 +246,10 @@ class cmMakefile;
"in caller.", \
3, 14, 0, cmPolicies::WARN) \
SELECT(POLICY, CMP0083, "Add PIE options when linking executable.", 3, 14, \
- 0, cmPolicies::WARN)
+ 0, cmPolicies::WARN) \
+ SELECT(POLICY, CMP0084, \
+ "The FindQt module does not exist for find_package().", 3, 14, 0, \
+ cmPolicies::WARN)
#define CM_SELECT_ID(F, A1, A2, A3, A4, A5, A6) F(A1)
#define CM_FOR_EACH_POLICY_ID(POLICY) \