Xcode: Every add_custom_command rebuilt after CMake re-runs
With Xcode generator, regardless of passing UseModernBuildSystem=YES/NO to the buildsystem, xcode will re-execute every commands added with add_custom_command. A simple reproductible test can demonstrate the bug with the qt_wrap_cpp macro.
Hereafter a mini test project to reproduce the bug.
cmake -GXcode ..
cmake --build . --target CmakeBug -- -UseModernBuildSystem=YES
cmake -GXcode ..
# Observe now that moc_QObjectClass.cpp is regenerated and moc_QObjectClass.o recompiled
cmake --build . --target CmakeBug -- -UseModernBuildSystem=YES
In a big project, this is completely overwelming and forces a rebuild of hundreds of files everytimes cmake is run.
Rolling back to cmake 3.18.4 still with Xcode 12.3, I can confirm it works as expected (with the legacy build system)
Or, using cmake .. -GXcode -T buildsystem=1
to switch to the legacy build system with CMake 3.19 works.
Edited by Brad King