[CMake] Problem with AUTOMOC on WIN32
Michael Wild
themiwi at gmail.com
Tue Jun 18 05:45:29 EDT 2019
Dear all
It's a very long time I last posted here, so please be kind :-)
I currently am having a very hard time to get AUTOMOC to work properly
on WIN32 for the case where I have some Qt classes in a DLL that I
link to an executable. In this case, the header gets included by both,
the corresponding *.cpp file in the DLL and the importing *.cpp file
in the executable. The problem is now that the AUTOMOC feature runs
moc twice on the same header, once for the DLL and once for the
executable, resulting in an inconsistent linkage because for the DLL
the moc'ed sources are dllexport but for the executable they are
dllimport.
I put together a minimal example exhibiting the problem:
https://github.com/themiwi/qt_cmake_automoc_test/
Is this a bug in CMake? IMHO moc should be only run on headers for
targets where the corresponding source file is compiled in. Or am I
just being incredibly stupid and completely miss an obvious point?
Of course I could revert to qt5_wrap_cpp() as demonstrated in the
develop branch of above example, but I'd rather not because that adds
considerable complexity and makes configuration much slower in a
real-world project.
Cheers
Michael
More information about the CMake
mailing list