diff options
author | Leander Beernaert <leander.beernaert@qt.io> | 2020-04-21 13:28:57 +0200 |
---|---|---|
committer | Leander Beernaert <leander.beernaert@qt.io> | 2020-04-22 09:51:12 +0200 |
commit | 6fbeef4c6b2323fc4b7856520c0f38f8139c9c54 (patch) | |
tree | 9457cdde24cfd8beeddbcf71d294a7af22457dc3 /src/corelib/Qt6CoreMacros.cmake | |
parent | 26a0a8942135fed725ec3067ba05bae31bb4e645 (diff) |
CMake: Add qt6_add_plugin public API
This patch adds a publicly callable qt6_add_plugin() API to create
plugins. This API is meant to cover cases such as the plugandpaint
example.
This patch also renames qt_add_plugin to qt_internal_add_plugin in order
to avoid clashes with the public API. To avoid breaking the existing
projects, a compatibility wrapper function is enabled by default unless
QT_DISABLE_QT_ADD_PLUGIN_COMPATIBILITY is specified.
Fixes: QTBUG-82961
Change-Id: If5b564a8406c90434f1bdad0b8df76d3e6626b5f
Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io>
Diffstat (limited to 'src/corelib/Qt6CoreMacros.cmake')
-rw-r--r-- | src/corelib/Qt6CoreMacros.cmake | 54 |
1 files changed, 54 insertions, 0 deletions
diff --git a/src/corelib/Qt6CoreMacros.cmake b/src/corelib/Qt6CoreMacros.cmake index 29b3239215..2e7022c116 100644 --- a/src/corelib/Qt6CoreMacros.cmake +++ b/src/corelib/Qt6CoreMacros.cmake @@ -1135,3 +1135,57 @@ function(QT6_PROCESS_RESOURCE target resourceName) set(${rcc_OUTPUT_TARGETS} "${output_targets}" PARENT_SCOPE) endif() endfunction() + +function(qt6_add_plugin target) + cmake_parse_arguments(arg + "STATIC" + "OUTPUT_NAME" + "" + ${ARGN} + ) + if (arg_STATIC) + add_library(${target} STATIC) + else() + add_library(${target} MODULE) + if(APPLE) + # CMake defaults to using .so extensions for loadable modules, aka plugins, + # but Qt plugins are actually suffixed with .dylib. + set_property(TARGET "${target}" PROPERTY SUFFIX ".dylib") + endif() + endif() + + set(output_name ${target}) + if (arg_OUTPUT_NAME) + set(output_name ${arg_OUTPUT_NAME}) + endif() + set_property(TARGET "${target}" PROPERTY OUTPUT_NAME "${output_name}") + + if (ANDROID) + qt_android_apply_arch_suffix("${target}") + set_target_properties(${target} + PROPERTIES + LIBRARY_OUTPUT_NAME "plugins_${arg_TYPE}_${output_name}" + ) + endif() + + set(static_plugin_define "") + if (arg_STATIC) + set(static_plugin_define "QT_STATICPLUGIN") + endif() + target_compile_definitions(${target} PRIVATE + QT_PLUGIN + QT_DEPRECATED_WARNINGS + ${static_plugin_define} + ) +endfunction() + +if(NOT QT_NO_CREATE_VERSIONLESS_FUNCTIONS) + function(qt_add_plugin) + if (NOT DEFINED QT_DISABLE_QT_ADD_PLUGIN_COMPATIBILITY + OR NOT QT_DISABLE_QT_ADD_PLUGIN_COMPATIBILITY) + qt_internal_add_plugin(${ARGV}) + else() + qt6_add_plugin(${ARGV}) + endif() + endfunction() +endif() |