Proper way to allow static build for kimageformats qt plugins?
When trying to build kimageformats, it will always produce as dynamic library instead of static library:
function(kimageformats_add_plugin plugin)
...
add_library(${plugin} MODULE ${KIF_ADD_PLUGIN_SOURCES})
...
endfunction()
https://invent.kde.org/frameworks/kimageformats/-/blob/master/src/imageformats/CMakeLists.txt#L14
MSYS2 do provide the ability to build Qt applications staticly (by providing qt{5,6}-static
), KDE's other Qt plugins (most of them are QML plugin tho) also produce static library so it can be used too, but kimageformats is not one of them.
Since Qt6, Qt added a new CMake function qt_add_plugin()
(or the internal one qt_internal_add_plugin()
) to create Qt plugin. It has an option argument to tell CMake what type of plugin ([SHARED | STATIC]
) is preferred, and it will use the same type as Qt by checking QT6_IS_SHARED_LIBS_BUILD
if the type argument is not provided.
I'd like to add the ability to build static version of kimageformats. I know adding an option to let user choose the preferred type and checking this option to decide use MODULE or STATIC could be a solution, but I think it's probably not the proper way to do it. Is there a similar variable in ECM to check if Qt is static (similar to QT6_IS_SHARED_LIBS_BUILD
)? Or maybe a similar wrapper like qt_add_plugin()
in Qt5?
Thanks!