mirror of
https://github.com/Kitware/CMake.git
synced 2026-11-06 05:16:58 +00:00
The aggregated translation unit includes the moc output of the target's
headers, and through that the headers themselves, so it may import a C++
module even though nothing autogen writes declares one. Since commit
e5dce1a37e (cmQtAutoGenInitializer: disable C++ module scanning for
autogen sources, 2023-12-11) it has been compiled without a module map,
so such an import fails with "module not found". A project therefore
cannot use an import in any header that moc processes, and cannot work
around it either: the CXX_SCAN_FOR_MODULES source property is set during
generation, after the project has been read, so setting it has no
effect.
Leave that source property of the moc compilation file unset, so that
it is scanned under the same conditions as the target's own sources:
the target property, policy CMP0155, and whether the compiler and the
generator support scanning decide. Setting it to ON instead would
override a target that opts out, and fail generation outright with a
compiler or generator that cannot scan. The remaining autogen sources
keep their current behavior; unlike this one, they do not include
anything the project wrote.