From 9c9a47e551ee7116464d86a091d557e5400bfeca Mon Sep 17 00:00:00 2001 From: Martchus Date: Thu, 16 Sep 2021 18:36:35 +0200 Subject: [PATCH] Define `QT_STATICPLUGIN` when building static Qt plugins This requirement is documented here: https://doc.qt.io/qt-5/plugins-howto.html#creating-static-plugins --- cmake/modules/LibraryTarget.cmake | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/cmake/modules/LibraryTarget.cmake b/cmake/modules/LibraryTarget.cmake index 303811a..a6cb339 100644 --- a/cmake/modules/LibraryTarget.cmake +++ b/cmake/modules/LibraryTarget.cmake @@ -101,7 +101,7 @@ else () set(TARGET_INCLUDE_DIRECTORY_BUILD_INTERFACE "${CMAKE_CURRENT_SOURCE_DIR}/..") endif () -# add target for building the library +# configure target type for building the library if (BUILD_SHARED_LIBS) if (META_IS_PLUGIN) set(META_LIBRARY_TYPE MODULE) @@ -110,8 +110,14 @@ if (BUILD_SHARED_LIBS) endif () else () set(META_LIBRARY_TYPE STATIC) + + # define QT_STATICPLUGIN when building static Qt plugins + if ("${META_PROJECT_TYPE}" STREQUAL "qtplugin") + list(APPEND META_PRIVATE_COMPILE_DEFINITIONS QT_STATICPLUGIN) + endif () endif () + # add custom libraries append_user_defined_additional_libraries()