From 8a9d72bee90854e856e25e31dad230e49e0dc894 Mon Sep 17 00:00:00 2001 From: Martchus Date: Sun, 20 Dec 2020 17:53:37 +0100 Subject: [PATCH] Disable linking against default Qt plugins This change would obviously better go into qtutilities. However, it is easier done here and doesn't pull in any dependency on Qt anyways. --- cmake/modules/AppTarget.cmake | 3 ++- cmake/modules/BasicConfig.cmake | 8 ++++++++ cmake/modules/LibraryTarget.cmake | 3 ++- 3 files changed, 12 insertions(+), 2 deletions(-) diff --git a/cmake/modules/AppTarget.cmake b/cmake/modules/AppTarget.cmake index 9ce7daa..1403445 100644 --- a/cmake/modules/AppTarget.cmake +++ b/cmake/modules/AppTarget.cmake @@ -61,7 +61,8 @@ set_target_properties( CXX_VISIBILITY_PRESET hidden LINK_SEARCH_START_STATIC ${STATIC_LINKAGE} LINK_SEARCH_END_STATIC ${STATIC_LINKAGE} - AUTOGEN_TARGET_DEPENDS "${AUTOGEN_DEPS}") + AUTOGEN_TARGET_DEPENDS "${AUTOGEN_DEPS}" + QT_DEFAULT_PLUGINS "${META_QT_DEFAULT_PLUGINS}") # set properties for macOS bundle and generate icon for macOS bundle if (GUI_TYPE STREQUAL "MACOSX_BUNDLE") diff --git a/cmake/modules/BasicConfig.cmake b/cmake/modules/BasicConfig.cmake index 0b8182b..919038c 100644 --- a/cmake/modules/BasicConfig.cmake +++ b/cmake/modules/BasicConfig.cmake @@ -76,6 +76,14 @@ elseif (CONFIGURATION_TARGET_SUFFIX) set(TARGET_SUFFIX "-${CONFIGURATION_TARGET_SUFFIX}") endif () +# disable linking against default Qt plugins by default +if (NOT DEFINED META_QT_DEFAULT_PLUGINS) + # note: The CMake modules in qtutilities take care of linking against static plugins on their own because old Qt versions + # did not provide any support and one had to do it manually. Considering that with Qt's default my projects end up + # pulling in needlessly many plugins I prefer to keep my current approach and disable Qt's defaults. + set(META_QT_DEFAULT_PLUGINS 0) # needs to be exactly 0, Qt's code uses STREQUAL 0 +endif () + # find standard installation directories - note: Allow overriding CMAKE_INSTALL_LIBDIR and LIB_INSTALL_DIR but don't use the # default from GNUInstallDirs (as an Arch Linux user this feels odd and I also want to avoid breaking existing build # scripts). diff --git a/cmake/modules/LibraryTarget.cmake b/cmake/modules/LibraryTarget.cmake index decd4e9..cf773a4 100644 --- a/cmake/modules/LibraryTarget.cmake +++ b/cmake/modules/LibraryTarget.cmake @@ -157,7 +157,8 @@ else () CXX_VISIBILITY_PRESET hidden LINK_SEARCH_START_STATIC ${STATIC_LINKAGE} LINK_SEARCH_END_STATIC ${STATIC_LINKAGE} - AUTOGEN_TARGET_DEPENDS "${AUTOGEN_DEPS}") + AUTOGEN_TARGET_DEPENDS "${AUTOGEN_DEPS}" + QT_DEFAULT_PLUGINS "${META_QT_DEFAULT_PLUGINS}") if (META_PLUGIN_CATEGORY) set_target_properties(${META_TARGET_NAME} PROPERTIES LIBRARY_OUTPUT_DIRECTORY "${META_PLUGIN_CATEGORY}") endif ()