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

Alexandru Croitor alexandru.croitor at qt.io
Mon Jan 23 13:50:03 CET 2023


Indeed, /wholearchive exists on windows and can be used with the referenced cmake version, but unfortunately:

- ensuring certain symbols are not discarded
- others are (-gc-sections), 
- it works reliably
- for all platforms that qt supports

is more involved.

See QTBUG-97816 , the comments there, and also linked issues and their comments.

At some point we'll have to revisit if it's perhaps more feasible to do now, or limit it to specific platforms and newer cmake versions.

> On 23. Jan 2023, at 12:11, Cristian Adam via Interest <interest at qt-project.org> wrote:
> 
>  >> 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 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
> 
> Cheers,
> Cristian.
> _______________________________________________
> Interest mailing list
> Interest at qt-project.org
> https://lists.qt-project.org/listinfo/interest




More information about the Interest mailing list