فهرست منبع

cmMakefile: Simplify GetModulesFile decision logic

After removing CMP0017, the logic can be simpler.
Brad King 11 ماه پیش
والد
کامیت
b6930d24f8
1فایلهای تغییر یافته به همراه9 افزوده شده و 7 حذف شده
  1. 9 7
      Source/cmMakefile.cxx

+ 9 - 7
Source/cmMakefile.cxx

@@ -3774,20 +3774,22 @@ std::string cmMakefile::GetModulesFile(cm::string_view filename, bool& system,
   // 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;
-  }
-
   if (!moduleInCMakeModulePath.empty() && !moduleInCMakeRoot.empty()) {
     cmValue currentFile = this->GetDefinition("CMAKE_CURRENT_LIST_FILE");
     std::string mods = cmStrCat(cmSystemTools::GetCMakeRoot(), "/Modules/");
     if (currentFile && cmSystemTools::IsSubDirectory(*currentFile, mods)) {
       system = true;
       result = moduleInCMakeRoot;
+    } else {
+      system = false;
+      result = moduleInCMakeModulePath;
     }
+  } else if (!moduleInCMakeModulePath.empty()) {
+    system = false;
+    result = moduleInCMakeModulePath;
+  } else {
+    system = true;
+    result = moduleInCMakeRoot;
   }
 
   return result;