[cmake-developers] CMake 3.13 - Generated moc files not added to VStudio solution
Sebastian Holtermann
seblist at xwmw.org
Thu Jan 31 12:10:40 EST 2019
> Any luck? I can try helping ya trace it if you need it.
>
I traced this down to some degree.
The problem arises from the handling of file path for GENERATED vs non
GENERATED files.
When the full path for a file is computed in cmSourceFile and the file doesn't
exist (mocs_compilation.cpp doesn't, yet), a path error flag is set.
The flag won't be raised when the file has the property GENERATED set, which
mocs_compilation.cpp hasn't at that point.
A quick solution in your CMakeLists.txt is to mark mocs_compilation.cpp
GENERATED first like this
```
set_property(SOURCE "${MOC_COMPILATION}" APPEND_STRING PROPERTY GENERATED "1")
set_property(SOURCE "${MOC_COMPILATION}" APPEND_STRING PROPERTY COMPILE_FLAGS
" /FI\"${PrecompiledHeader}\"")
```
This works here for a small example project.
I'm too busy right now to address this in the CMake sources but I'll try to
look at it next week.
-Sebastian
More information about the cmake-developers
mailing list