[Interest] What is the right way of creating a static lib that has qml resources with cmake?

Cristian Adam cristian.adam at qt.io
Mon Jan 23 12:11:25 CET 2023

 >> Yes, there is. There's -Wl,--whole-archive for the Unix linkers. This should
>> solve the problem for everyone except MSVC users.

> That option is not very attractive because:

> a, as you state yourself, it doesn't work on MSVC.

MSVC also has a /wholearchive<https://learn.microsoft.com/en-us/cpp/build/reference/wholearchive-include-all-library-object-files?view=msvc-170> parameter to the linker.

Starting with CMake 3.24 you can use it generically as:

target_link_libraries(my_exe PRIVATE "$<LINK_LIBRARY:WHOLE_ARCHIVE,my_static_lib>")

Fore more details see:

  *   https://cmake.org/cmake/help/latest/variable/CMAKE_LINK_LIBRARY_USING_FEATURE.html
  *   https://cmake.org/cmake/help/latest/manual/cmake-generator-expressions.7.html#genex:LINK_LIBRARY

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.qt-project.org/pipermail/interest/attachments/20230123/8acb780a/attachment.htm>

More information about the Interest mailing list