Merge branch 'fix-automoc-warnings' into release-3.11

Merge-request: !2066
diff --git a/Source/cmCustomCommandGenerator.cxx b/Source/cmCustomCommandGenerator.cxx
index 136cf39..6c9f9d6 100644
--- a/Source/cmCustomCommandGenerator.cxx
+++ b/Source/cmCustomCommandGenerator.cxx
@@ -40,6 +40,14 @@
         argv.push_back(std::move(parsed_arg));
       }
     }
+
+    // Later code assumes at least one entry exists, but expanding
+    // lists on an empty command may have left this empty.
+    // FIXME: Should we define behavior for removing empty commands?
+    if (argv.empty()) {
+      argv.push_back(std::string());
+    }
+
     this->CommandLines.push_back(std::move(argv));
   }
 
diff --git a/Source/cmQtAutoGenInitializer.cxx b/Source/cmQtAutoGenInitializer.cxx
index 93c78b5..566a2a9 100644
--- a/Source/cmQtAutoGenInitializer.cxx
+++ b/Source/cmQtAutoGenInitializer.cxx
@@ -994,6 +994,9 @@
   // Generate auto RCC info files
   if (this->RccEnabled) {
     for (Qrc const& qrc : this->Qrcs) {
+      // Register rcc info file as generated
+      makefile->AddCMakeOutputFile(qrc.InfoFile);
+
       cmGeneratedFileStream ofs;
       ofs.SetCopyIfDifferent(true);
       ofs.Open(qrc.InfoFile.c_str(), false, true);
diff --git a/Tests/RunCMake/add_custom_target/CommandExpandsEmpty.cmake b/Tests/RunCMake/add_custom_target/CommandExpandsEmpty.cmake
new file mode 100644
index 0000000..bc899a4
--- /dev/null
+++ b/Tests/RunCMake/add_custom_target/CommandExpandsEmpty.cmake
@@ -0,0 +1 @@
+add_custom_target(EmptyCustom COMMAND "" COMMAND_EXPAND_LISTS)
diff --git a/Tests/RunCMake/add_custom_target/RunCMakeTest.cmake b/Tests/RunCMake/add_custom_target/RunCMakeTest.cmake
index 6c4e91b..2caed03 100644
--- a/Tests/RunCMake/add_custom_target/RunCMakeTest.cmake
+++ b/Tests/RunCMake/add_custom_target/RunCMakeTest.cmake
@@ -1,5 +1,6 @@
 include(RunCMake)
 
+run_cmake(CommandExpandsEmpty)
 run_cmake(NoArguments)
 run_cmake(BadTargetName)
 run_cmake(ByproductsNoCommand)