[Interest] [Qt6] QML automatic type registration in a (shared) library

Alexandru Croitor alexandru.croitor at qt.io
Wed Jan 19 09:44:30 CET 2022



> On 19. Jan 2022, at 09:30, Konstantin Shegunov <kshegunov at gmail.com> wrote:
> 
> 
> Oh, I just took the easy (perhaps wrong) approach. I pushed from the backing target to the consumer a cpp file, which is a dummy containing the pointer thing. It just contains (Tsc.Ui is my module's URI):

I assume you mean you did target_sources(tsc_ui_target INTERFACE dummy.cpp)
target_link_libraries(your_shared_lib PRIVATE tsc_ui_target)

It does work if the direct consumer is a shared lib.

That doesn't quite work if the consuming target is a static lib, that is then linked into an executable/shared lib.
 dummy.o will be archived into the static lib and then discarded when linked into a shared lib because nothing is referencing symbols from that object file.

Hence the need for object libraries instead of target_sources.. Hence the need for CMake 3.21.







More information about the Interest mailing list