Răsfoiți Sursa

Autogen: Avoid running multiple cmake_autogen command in Xcode

Since commit 7c39dabdbc (Autogen: AUTO*_EXECUTABLE: add support for
per-config values, 2023-10-18, v3.29.0-rc1~105^2~1) we were accidentally
running cmake_autogen multiple times for each config.

Fixes: #26282
Orkun Tokdemir 1 an în urmă
părinte
comite
32c8cb2960

+ 6 - 4
Source/cmQtAutoGenInitializer.cxx

@@ -1613,13 +1613,17 @@ void cmQtAutoGenInitializer::AddCMakeProcessToCommandLines(
   std::string const& infoFile, std::string const& processName,
   cmCustomCommandLines& commandLines)
 {
+  std::vector<std::string> autogenConfigs;
+  this->GlobalGen->GetQtAutoGenConfigs(autogenConfigs);
   if (this->CrossConfig && this->UseBetterGraph) {
     commandLines.push_back(cmMakeCommandLine(
       { cmSystemTools::GetCMakeCommand(), "-E", processName, infoFile,
         "$<CONFIG>", "$<COMMAND_CONFIG:$<CONFIG>>" }));
   } else if ((this->MultiConfig && this->GlobalGen->IsXcode()) ||
              this->CrossConfig) {
-    for (std::string const& config : this->ConfigsList) {
+    const auto& configs =
+      processName == "cmake_autorcc" ? this->ConfigsList : autogenConfigs;
+    for (std::string const& config : configs) {
       commandLines.push_back(
         cmMakeCommandLine({ cmSystemTools::GetCMakeCommand(), "-E",
                             processName, infoFile, config }));
@@ -1629,9 +1633,7 @@ void cmQtAutoGenInitializer::AddCMakeProcessToCommandLines(
     if (this->MultiConfig) {
       autoInfoFileConfig = "$<CONFIG>";
     } else {
-      std::vector<std::string> configs;
-      this->GlobalGen->GetQtAutoGenConfigs(configs);
-      autoInfoFileConfig = configs[0];
+      autoInfoFileConfig = autogenConfigs[0];
     }
     commandLines.push_back(
       cmMakeCommandLine({ cmSystemTools::GetCMakeCommand(), "-E", processName,

+ 16 - 7
Tests/RunCMake/Autogen_common/utils.cmake

@@ -232,24 +232,33 @@ function(autogen_executable_test exe)
       set(RunCMake_MAKE_PROGRAM ${CMAKE_COMMAND})
       run_make_program(${RunCMake_TEST_BINARY_DIR}  --build . --config Debug)
       if (exe STREQUAL "Moc")
-        set(expected_count 16)
-      elseif (exe STREQUAL "Uic")
         set(expected_count 4)
+      elseif (exe STREQUAL "Uic")
+        set(expected_count 1)
       else()
         set(expected_count 12)
       endif()
       expect_n_times("${make_program_stdout}" "Auto${exe}:" ${expected_count} "${exe}Example-build-Auto${exe}")
-      expect_n_times("${make_program_stdout}" "Auto${exe}:" ${expected_count} "${exe}Example-build-Auto${exe}")
 
       if (exe STREQUAL "Moc" OR exe STREQUAL "Uic")
-        expect_n_times("${make_program_stdout}" "AutoGen:" 20 "${exe}Example-build-AutoGen:")
+        expect_n_times("${make_program_stdout}" "AutoGen:" 5 "${exe}Example-build-AutoGen:")
       endif()
 
-      foreach(config IN ITEMS Debug Release RelWithDebInfo)
+
+      foreach(config IN ITEMS Release RelWithDebInfo)
         block()
+          # Note: We expect to see Auto${exe} or AutoGen in the output for
+          # moc and uic because they should be triggered per configuration.
+          # For rcc, we don't expect to see Auto${exe} or AutoGen in the output
+          # because all configurations trigger with the first configuration.
           run_make_program(${RunCMake_TEST_BINARY_DIR} --build . --config ${config})
-          not_expect("${make_program_stdout}" "Auto${exe}" "${exe}Example-${config}_Auto${exe}")
-          not_expect("${make_program_stdout}" "AutoGen:" "${exe}Example-${config}_AutoGen")
+          if (exe STREQUAL "Moc" OR exe STREQUAL "Uic")
+            expect_n_times("${make_program_stdout}" "Auto${exe}:" ${expected_count} "${exe}Example-build-${config}-Auto${exe}")
+            expect_n_times("${make_program_stdout}" "AutoGen" 5 "${exe}Example-build-${config}-AutoGen:")
+          else()
+            not_expect("${make_program_stdout}" "Auto${exe}" "${exe}Example-build-${config}_Auto${exe}")
+            not_expect("${make_program_stdout}" "AutoGen" "${exe}Example-build-${config}_AutoGen")
+          endif()
         endblock()
       endforeach()
     endblock()