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
This commit is contained in:
Joerg Bornemann
2026-02-16 14:22:36 +01:00
committed by Brad King
parent c0a05022b6
commit 2256eb36fb
2 changed files with 15 additions and 7 deletions

View File

@@ -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.

View File

@@ -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.")