summaryrefslogtreecommitdiffstats
path: root/mkspecs/features/data
diff options
context:
space:
mode:
authorAlexandru Croitor <alexandru.croitor@qt.io>2019-12-02 18:03:47 +0100
committerAlexandru Croitor <alexandru.croitor@qt.io>2020-01-25 18:10:26 +0100
commite9a797799ee7e81d1cd113ba56f62705ae150e5c (patch)
treeaabaedcfed424ff6d81960db479160dd51b07d5e /mkspecs/features/data
parentf3d3c095a6bda505384ef56acab57b985d94fac5 (diff)
CMake: Add Qt6 forward compatible CMake API and targets
Create Qt:: versionless targets for libraries and tools. So Qt::Core will link to Qt5::Core. Add additional feature properties to targets, with the same name they have in Qt6: QT_ENABLED_PUBLIC_FEATURES, QT_DISABLED_PUBLIC_FEATURES, QT_ENABLED_PRIVATE_FEATURES, QT_DISABLED_PRIVATE_FEATURES, to be forward-compatible with Qt6. Prefix properties with INTERFACE_ for interface libraries. Create functions with no major version in their prefix, so qt_foo instead of qt5_foo. The non-versioned functions will call the versioned functions, depending on the value of QT_DEFAULT_MAJOR_VERSION, which can be set by an application developer before finding the Qt package. Set QT_DEFAULT_MAJOR_VERSION to 5 if the value has not been defined in the current scope. Application developers can set QT_NO_CREATE_VERSIONLESS_FUNCTIONS to TRUE before calling find_package(Qt5) to suppress creation of the non-versioned functions. Application developers can set QT_NO_CREATE_VERSIONLESS_TARGETS to TRUE before calling find_package(Qt5) to suppress creation of the non-versioned targets. Setting these can be useful when both find_package(Qt5) and find_package(Qt6) are in the same project. If none of these are set by the user, then the first find_package(Qt5) will create versionless targets with the major version being "5", which means the second find_package(Qt6) will not create versionless targets. Handle versionless plugin names in qt_import_plugins, so both Qt::QCocoaIntegrationPlugin and Qt5/6::QCocoaIntegrationPlugin are recognized by the function. Allow specifying multiple types in EXCLUDE_BY_TYPE in qt_import_plugins, to be consitent with the Qt 6 version. Make sure to set the QT_PLUGIN_CLASS_NAME property to compatible with Qt 6. Task-number: QTBUG-74137 Task-number: QTBUG-80477 Change-Id: Ib89d090ea6f7794d7debd64f03f29da963a17ca7 Reviewed-by: Joerg Bornemann <joerg.bornemann@qt.io>
Diffstat (limited to 'mkspecs/features/data')
-rw-r--r--mkspecs/features/data/cmake/Qt5BasicConfig.cmake.in31
-rw-r--r--mkspecs/features/data/cmake/Qt5PluginTarget.cmake.in22
2 files changed, 48 insertions, 5 deletions
diff --git a/mkspecs/features/data/cmake/Qt5BasicConfig.cmake.in b/mkspecs/features/data/cmake/Qt5BasicConfig.cmake.in
index 26d4c17e6c..01dda9b0c3 100644
--- a/mkspecs/features/data/cmake/Qt5BasicConfig.cmake.in
+++ b/mkspecs/features/data/cmake/Qt5BasicConfig.cmake.in
@@ -406,6 +406,15 @@ if (NOT TARGET Qt5::$${CMAKE_MODULE_NAME})
add_library(Qt5::$${CMAKE_MODULE_NAME} SHARED IMPORTED)
!!ENDIF
!!ENDIF
+
+ # Add a versionless target, for compatibility with Qt6.
+ if(NOT \"${QT_NO_CREATE_VERSIONLESS_TARGETS}\" AND NOT TARGET Qt::$${CMAKE_MODULE_NAME})
+ add_library(Qt::$${CMAKE_MODULE_NAME} INTERFACE IMPORTED)
+ set_target_properties(Qt::$${CMAKE_MODULE_NAME} PROPERTIES
+ INTERFACE_LINK_LIBRARIES \"Qt5::$${CMAKE_MODULE_NAME}\"
+ )
+ endif()
+
!!IF !equals(TEMPLATE, aux)
!!IF !isEmpty(CMAKE_BUILD_IS_FRAMEWORK)
set_property(TARGET Qt5::$${CMAKE_MODULE_NAME} PROPERTY FRAMEWORK 1)
@@ -420,6 +429,20 @@ if (NOT TARGET Qt5::$${CMAKE_MODULE_NAME})
set_property(TARGET Qt5::$${CMAKE_MODULE_NAME} PROPERTY INTERFACE_QT_ENABLED_FEATURES $$join(QT.$${MODULE}.enabled_features, ";"))
set_property(TARGET Qt5::$${CMAKE_MODULE_NAME} PROPERTY INTERFACE_QT_DISABLED_FEATURES $$join(QT.$${MODULE}.disabled_features, ";"))
+ # Qt 6 forward compatible properties.
+ set_property(TARGET Qt5::$${CMAKE_MODULE_NAME}
+ PROPERTY $${CMAKE_FEATURE_PROPERTY_PREFIX}QT_ENABLED_PUBLIC_FEATURES
+ $$join(QT.$${MODULE}.enabled_features, ";"))
+ set_property(TARGET Qt5::$${CMAKE_MODULE_NAME}
+ PROPERTY $${CMAKE_FEATURE_PROPERTY_PREFIX}QT_DISABLED_PUBLIC_FEATURES
+ $$join(QT.$${MODULE}.disabled_features, ";"))
+ set_property(TARGET Qt5::$${CMAKE_MODULE_NAME}
+ PROPERTY $${CMAKE_FEATURE_PROPERTY_PREFIX}QT_ENABLED_PRIVATE_FEATURES
+ $$join(QT.$${MODULE}_private.enabled_features, ";"))
+ set_property(TARGET Qt5::$${CMAKE_MODULE_NAME}
+ PROPERTY $${CMAKE_FEATURE_PROPERTY_PREFIX}QT_DISABLED_PRIVATE_FEATURES
+ $$join(QT.$${MODULE}_private.disabled_features, ";"))
+
set_property(TARGET Qt5::$${CMAKE_MODULE_NAME} PROPERTY INTERFACE_QT_PLUGIN_TYPES \"$${CMAKE_MODULE_PLUGIN_TYPES}\")
set(_Qt5$${CMAKE_MODULE_NAME}_PRIVATE_DIRS_EXIST TRUE)
@@ -443,6 +466,14 @@ if (NOT TARGET Qt5::$${CMAKE_MODULE_NAME})
set_property(TARGET Qt5::$${CMAKE_MODULE_NAME}Private PROPERTY
INTERFACE_LINK_LIBRARIES Qt5::$${CMAKE_MODULE_NAME} ${_Qt5$${CMAKE_MODULE_NAME}_PRIVATEDEPS}
)
+
+ # Add a versionless target, for compatibility with Qt6.
+ if(NOT \"${QT_NO_CREATE_VERSIONLESS_TARGETS}\" AND NOT TARGET Qt::$${CMAKE_MODULE_NAME}Private)
+ add_library(Qt::$${CMAKE_MODULE_NAME}Private INTERFACE IMPORTED)
+ set_target_properties(Qt::$${CMAKE_MODULE_NAME}Private PROPERTIES
+ INTERFACE_LINK_LIBRARIES \"Qt5::$${CMAKE_MODULE_NAME}Private\"
+ )
+ endif()
endif()
!!IF !equals(TEMPLATE, aux)
diff --git a/mkspecs/features/data/cmake/Qt5PluginTarget.cmake.in b/mkspecs/features/data/cmake/Qt5PluginTarget.cmake.in
index 7b70cfed09..b550a52c60 100644
--- a/mkspecs/features/data/cmake/Qt5PluginTarget.cmake.in
+++ b/mkspecs/features/data/cmake/Qt5PluginTarget.cmake.in
@@ -75,19 +75,30 @@ endif()
set(_user_specified_genex
\"$<IN_LIST:Qt5::$$CMAKE_PLUGIN_NAME,${_manual_plugins_genex};${_plugin_type_genex}>\"
)
+set(_user_specified_genex_versionless
+ \"$<IN_LIST:Qt::$$CMAKE_PLUGIN_NAME,${_manual_plugins_genex};${_plugin_type_genex}>\"
+)
string(CONCAT _plugin_genex
\"$<$<OR:\"
- # Add this plugin if it\'s in the list of manual plugins or plugins for the type
+ # Add this plugin if it\'s in the list of manually specified plugins or in the list of
+ # explicitly included plugin types.
\"${_user_specified_genex},\"
- # Add this plugin if the list of plugins for the type is empty, the PLUGIN_EXTENDS
- # is either empty or equal to the module name, and the user hasn\'t blacklisted it
+ \"${_user_specified_genex_versionless},\"
+ # Add this plugin if all of the following are true:
+ # 1) the list of explicitly included plugin types is empty
+ # 2) the QT_PLUGIN_EXTENDS property for the plugin is empty or equal to the current
+ # module name
+ # 3) the user hasn\'t explicitly excluded the plugin.
\"$<AND:\"
\"$<STREQUAL:${_plugin_type_genex},>,\"
\"$<OR:\"
- \"$<STREQUAL:$<TARGET_PROPERTY:Qt5::$${CMAKE_PLUGIN_NAME},QT_PLUGIN_EXTENDS>,Qt5::$${CMAKE_MODULE_NAME}>,\"
+ # FIXME: The value of CMAKE_MODULE_NAME seems to be wrong (e.g for Svg plugin
+ # it should be Qt::Svg instead of Qt::Gui).
+ \"$<STREQUAL:$<TARGET_PROPERTY:Qt5::$${CMAKE_PLUGIN_NAME},QT_PLUGIN_EXTENDS>,Qt::$${CMAKE_MODULE_NAME}>,\"
\"$<STREQUAL:$<TARGET_PROPERTY:Qt5::$${CMAKE_PLUGIN_NAME},QT_PLUGIN_EXTENDS>,>\"
\">,\"
- \"$<NOT:$<IN_LIST:Qt5::$${CMAKE_PLUGIN_NAME},${_no_plugins_genex}>>\"
+ \"$<NOT:$<IN_LIST:Qt5::$${CMAKE_PLUGIN_NAME},${_no_plugins_genex}>>,\"
+ \"$<NOT:$<IN_LIST:Qt::$${CMAKE_PLUGIN_NAME},${_no_plugins_genex}>>\"
\">\"
\">:Qt5::$$CMAKE_PLUGIN_NAME>\"
)
@@ -100,3 +111,4 @@ set_property(TARGET Qt5::$${CMAKE_PLUGIN_NAME} APPEND PROPERTY INTERFACE_LINK_LI
!!ENDIF
set_property(TARGET Qt5::$${CMAKE_PLUGIN_NAME} PROPERTY QT_PLUGIN_TYPE \"$$CMAKE_PLUGIN_TYPE\")
set_property(TARGET Qt5::$${CMAKE_PLUGIN_NAME} PROPERTY QT_PLUGIN_EXTENDS \"$$CMAKE_PLUGIN_EXTENDS\")
+set_property(TARGET Qt5::$${CMAKE_PLUGIN_NAME} PROPERTY QT_PLUGIN_CLASS_NAME \"$$CMAKE_PLUGIN_NAME\")