Răsfoiți Sursa

Fix get_filename_component() registry view

Some find-modules use get_filename_component() to expand registry
values.  We need to look in both the 32-bit and 64-bit registry views
when expanding values.  We prefer the one that the target application
would see.  See issue #8792.
Brad King 16 ani în urmă
părinte
comite
c63e3bd13c
1 a modificat fișierele cu 21 adăugiri și 1 ștergeri
  1. 21 1
      Source/cmGetFilenameComponentCommand.cxx

+ 21 - 1
Source/cmGetFilenameComponentCommand.cxx

@@ -35,7 +35,27 @@ bool cmGetFilenameComponentCommand
   
   std::string result;
   std::string filename = args[1];
-  cmSystemTools::ExpandRegistryValues(filename);
+  if(filename.find("[HKEY") != filename.npos)
+    {
+    // Check the registry as the target application would view it.
+    cmSystemTools::KeyWOW64 view = cmSystemTools::KeyWOW64_32;
+    cmSystemTools::KeyWOW64 other_view = cmSystemTools::KeyWOW64_64;
+    if(this->Makefile->PlatformIs64Bit())
+      {
+      view = cmSystemTools::KeyWOW64_64;
+      other_view = cmSystemTools::KeyWOW64_32;
+      }
+    cmSystemTools::ExpandRegistryValues(filename, view);
+    if(filename.find("/registry") != filename.npos)
+      {
+      std::string other = args[1];
+      cmSystemTools::ExpandRegistryValues(other, other_view);
+      if(other.find("/registry") == other.npos)
+        {
+        filename = other;
+        }
+      }
+    }
   std::string storeArgs;
   std::string programArgs;
   if (args[2] == "PATH")