浏览代码

QtAutogen: Fix rcc invocation for Qt 5.0 and 5.1 (#15644)

In commit v3.2.0-rc1~480^2 (QtAutogen: Regenerate qrc files if their
input changes, 2014-09-17) we added use of the rcc `--list` option.
Prior to Qt 5.2 this option was called just `-list`.  Run `rcc --help`
to check for support for `--list` before using it and otherwise fall
back to the `-list` option for compatibility with older versions.
Brad King 10 年之前
父节点
当前提交
e78fcc6329
共有 1 个文件被更改,包括 20 次插入1 次删除
  1. 20 1
      Source/cmQtAutoGeneratorInitializer.cxx

+ 20 - 1
Source/cmQtAutoGeneratorInitializer.cxx

@@ -490,11 +490,30 @@ static std::string ListQt5RccInputs(cmSourceFile* sf,
 {
   std::string rccCommand
       = GetRccExecutable(target);
+
+  bool hasDashDashList = false;
+  {
+  std::vector<std::string> command;
+  command.push_back(rccCommand);
+  command.push_back("--help");
+  std::string rccStdOut;
+  std::string rccStdErr;
+  int retVal = 0;
+  bool result = cmSystemTools::RunSingleCommand(
+    command, &rccStdOut, &rccStdErr,
+    &retVal, 0, cmSystemTools::OUTPUT_NONE);
+  if (result && retVal == 0 &&
+      rccStdOut.find("--list") != std::string::npos)
+    {
+    hasDashDashList = true;
+    }
+  }
+
   std::vector<std::string> qrcEntries;
 
   std::vector<std::string> command;
   command.push_back(rccCommand);
-  command.push_back("--list");
+  command.push_back(hasDashDashList? "--list" : "-list");
 
   std::string absFile = cmsys::SystemTools::GetRealPath(
                                               sf->GetFullPath());