Просмотр исходного кода

Tests: Work around Xcode ZERO_CHECK limitation in RerunMocOnAddFile test

The Xcode build system creates its build plan at the start of a build
and does not re-read the project file when ZERO_CHECK regenerates it
mid-build. New source files added to CMakeLists.txt are silently
skipped, causing linker errors with Qt6 (whose moc generates metatype
code that references the class constructor).

Work around that issue by explicitly re-running CMake before building
when using the Xcode generator so the project file includes the new
sources before xcodebuild starts.

Fixes: #27358
Issue: #27611
Joerg Bornemann 4 дней назад
Родитель
Сommit
2256eb36fb

+ 0 - 7
.gitlab/ci/ctest_exclusions.cmake

@@ -42,13 +42,6 @@ if ("$ENV{CMAKE_CONFIGURATION}" MATCHES "_valgrind")
     )
 endif()
 
-if ("$ENV{CMAKE_CONFIGURATION}" MATCHES "_xcode")
-  list(APPEND test_exclusions
-    # FIXME(#27358): Qt6Autogen.RerunMocOnAddFile fails in Xcode.
-    "^Qt6Autogen.RerunMocOnAddFile$"
-    )
-endif()
-
 if ("$ENV{CMAKE_CONFIGURATION}" MATCHES "^macos_x86_64_")
   list(APPEND test_exclusions
     # FIXME(#27376): CMakeGUI's simpleConfigure:fail case hangs.

+ 15 - 0
Tests/QtAutogen/RerunMocOnAddFile/CMakeLists.txt

@@ -27,6 +27,21 @@ endmacro()
 
 macro(rebuild buildName)
   message(STATUS "Starting build ${buildName}.")
+  # Work around CMake issue #27611: The Xcode build system creates its build
+  # plan at the start of a build and does not pick up project file changes
+  # made by ZERO_CHECK during the build. Explicitly re-run CMake to ensure
+  # the project file includes new sources before the native build tool starts.
+  if(CMAKE_GENERATOR MATCHES "Xcode")
+    execute_process(
+      COMMAND "${CMAKE_COMMAND}" -S "${testProjectSrc}" -B "${testProjectBinDir}"
+      RESULT_VARIABLE result
+      OUTPUT_VARIABLE output
+      ERROR_VARIABLE output
+    )
+    if (result)
+      message(FATAL_ERROR "CMake reconfigure for build ${buildName} failed. Output: ${output}")
+    endif()
+  endif()
   execute_process(COMMAND "${CMAKE_COMMAND}" --build . WORKING_DIRECTORY "${testProjectBinDir}" RESULT_VARIABLE result)
   if (result)
     message(FATAL_ERROR "Build ${buildName} failed.")