From 2256eb36fb04287de49830a2634a6b851ecbd1a9 Mon Sep 17 00:00:00 2001 From: Joerg Bornemann Date: Mon, 16 Feb 2026 14:22:36 +0100 Subject: [PATCH] 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 --- .gitlab/ci/ctest_exclusions.cmake | 7 ------- Tests/QtAutogen/RerunMocOnAddFile/CMakeLists.txt | 15 +++++++++++++++ 2 files changed, 15 insertions(+), 7 deletions(-) diff --git a/.gitlab/ci/ctest_exclusions.cmake b/.gitlab/ci/ctest_exclusions.cmake index 34aa164f63..e04dea3d1c 100644 --- a/.gitlab/ci/ctest_exclusions.cmake +++ b/.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. diff --git a/Tests/QtAutogen/RerunMocOnAddFile/CMakeLists.txt b/Tests/QtAutogen/RerunMocOnAddFile/CMakeLists.txt index 3a9244d2f8..1184fb3f83 100644 --- a/Tests/QtAutogen/RerunMocOnAddFile/CMakeLists.txt +++ b/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.")