A Qt-consuming target with all its sources skipping usage of precompile headers breaks AUTOMOC
Project can be built with either Qt 5.15 or Qt 6.
```cmake
cmake_minimum_required(VERSION 3.16)
project(issue LANGUAGES CXX)
find_package(QT NAMES Qt5 Qt6 REQUIRED COMPONENTS Core)
find_package(Qt${QT_VERSION_MAJOR} REQUIRED COMPONENTS Widgets)
set(CMAKE_AUTOMOC ON)
file(GENERATE OUTPUT "widget.h" CONTENT "
#ifndef WIDGET_H
#define WIDGET_H
#include <QWidget>
class Widget : public QWidget {
Q_OBJECT
public:
Widget(QWidget *parent = nullptr);
};
#endif
")
file(GENERATE OUTPUT "widget.cpp" CONTENT "
#include \"widget.h\"
Widget::Widget(QWidget *parent) : QWidget(parent) {}
")
add_library(mylib STATIC ${CMAKE_BINARY_DIR}/widget.cpp ${CMAKE_BINARY_DIR}/widget.h)
target_link_libraries(mylib PRIVATE Qt::Widgets)
set_source_files_properties(${CMAKE_BINARY_DIR}/widget.cpp ${CMAKE_BINARY_DIR}/widget.h
PROPERTIES SKIP_PRECOMPILE_HEADERS ON)
target_precompile_headers(mylib PRIVATE [["QWidget"]])
```
```
$ mkdir build && cd build && cmake -DCMAKE_PREFIX_PATH=/path/to/Qt .. && ninja
```
Build output
```
makeobj[0]: Entering directory `~/Dev/automoc_no_dep_on_pch/build'
ninja: error: 'CMakeFiles/mylib.dir/cmake_pch.hxx.pch', needed by 'CMakeFiles/mylib.dir/mylib_autogen/mocs_compilation.cpp.o', missing and no known rule to make it
makeobj[0]: Leaving directory `~/Dev/automoc_no_dep_on_pch/build'
```
Enabling precompiled headers on the target, but excluding all the target sources from using the precompiled header file seemingly causes the generation of the `.pch` file not to happen.
And yet AUTOMOC relies on the `.pch` file to exist implicitly, which sounds like a bug. Either it shouldn't depend on the `.pch` file, or it should ensure it is generated.
issue