summaryrefslogtreecommitdiffstats
path: root/src/dbus
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 /src/dbus
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 'src/dbus')
-rw-r--r--src/dbus/Qt5DBusConfigExtras.cmake.in11
-rw-r--r--src/dbus/Qt5DBusMacros.cmake43
2 files changed, 54 insertions, 0 deletions
diff --git a/src/dbus/Qt5DBusConfigExtras.cmake.in b/src/dbus/Qt5DBusConfigExtras.cmake.in
index 1d947159e2..a814678f7b 100644
--- a/src/dbus/Qt5DBusConfigExtras.cmake.in
+++ b/src/dbus/Qt5DBusConfigExtras.cmake.in
@@ -31,3 +31,14 @@ endif()
set(Qt5DBus_QDBUSCPP2XML_EXECUTABLE Qt5::qdbuscpp2xml)
set(Qt5DBus_QDBUSXML2CPP_EXECUTABLE Qt5::qdbusxml2cpp)
+
+# Create versionless tool targets.
+foreach(__qt_tool qdbuscpp2xml qdbusxml2cpp)
+ if(NOT \"${QT_NO_CREATE_VERSIONLESS_TARGETS}\" AND NOT TARGET Qt::${__qt_tool}
+ AND TARGET Qt5::${__qt_tool})
+ add_executable(Qt::${__qt_tool} IMPORTED)
+ get_target_property(__qt_imported_location Qt5::${__qt_tool} IMPORTED_LOCATION)
+ set_target_properties(Qt::${__qt_tool}
+ PROPERTIES IMPORTED_LOCATION \"${__qt_imported_location}\")
+ endif()
+endforeach()
diff --git a/src/dbus/Qt5DBusMacros.cmake b/src/dbus/Qt5DBusMacros.cmake
index 9b69e77dc7..1cacccdddd 100644
--- a/src/dbus/Qt5DBusMacros.cmake
+++ b/src/dbus/Qt5DBusMacros.cmake
@@ -70,6 +70,17 @@ function(qt5_add_dbus_interface _sources _interface _basename)
set(${_sources} ${${_sources}} PARENT_SCOPE)
endfunction()
+if(NOT QT_NO_CREATE_VERSIONLESS_FUNCTIONS)
+ function(qt_add_dbus_interface sources)
+ if(QT_DEFAULT_MAJOR_VERSION EQUAL 5)
+ qt5_add_dbus_interface("${sources}" ${ARGN})
+ elseif(QT_DEFAULT_MAJOR_VERSION EQUAL 6)
+ qt6_add_dbus_interface("${sources}" ${ARGN})
+ endif()
+ set("${sources}" "${${sources}}" PARENT_SCOPE)
+ endfunction()
+endif()
+
function(qt5_add_dbus_interfaces _sources)
foreach(_current_FILE ${ARGN})
@@ -83,6 +94,17 @@ function(qt5_add_dbus_interfaces _sources)
set(${_sources} ${${_sources}} PARENT_SCOPE)
endfunction()
+if(NOT QT_NO_CREATE_VERSIONLESS_FUNCTIONS)
+ function(qt_add_dbus_interfaces sources)
+ if(QT_DEFAULT_MAJOR_VERSION EQUAL 5)
+ qt5_add_dbus_interfaces("${sources}" ${ARGN})
+ elseif(QT_DEFAULT_MAJOR_VERSION EQUAL 6)
+ qt6_add_dbus_interfaces("${sources}" ${ARGN})
+ endif()
+ set("${sources}" "${${sources}}" PARENT_SCOPE)
+ endfunction()
+endif()
+
function(qt5_generate_dbus_interface _header) # _customName OPTIONS -some -options )
set(options)
@@ -116,6 +138,16 @@ function(qt5_generate_dbus_interface _header) # _customName OPTIONS -some -optio
)
endfunction()
+if(NOT QT_NO_CREATE_VERSIONLESS_FUNCTIONS)
+ function(qt_generate_dbus_interface)
+ if(QT_DEFAULT_MAJOR_VERSION EQUAL 5)
+ qt5_generate_dbus_interface(${ARGV})
+ elseif(QT_DEFAULT_MAJOR_VERSION EQUAL 6)
+ qt6_generate_dbus_interface(${ARGV})
+ endif()
+ endfunction()
+endif()
+
function(qt5_add_dbus_adaptor _sources _xml_file _include _parentClass) # _optionalBasename _optionalClassName)
get_filename_component(_infile ${_xml_file} ABSOLUTE)
@@ -152,3 +184,14 @@ function(qt5_add_dbus_adaptor _sources _xml_file _include _parentClass) # _optio
list(APPEND ${_sources} "${_impl}" "${_header}" "${_moc}")
set(${_sources} ${${_sources}} PARENT_SCOPE)
endfunction()
+
+if(NOT QT_NO_CREATE_VERSIONLESS_FUNCTIONS)
+ function(qt_add_dbus_adaptor sources)
+ if(QT_DEFAULT_MAJOR_VERSION EQUAL 5)
+ qt5_add_dbus_adaptor("${sources}" ${ARGN})
+ elseif(QT_DEFAULT_MAJOR_VERSION EQUAL 6)
+ qt6_add_dbus_adaptor("${sources}" ${ARGN})
+ endif()
+ set("${sources}" "${${sources}}" PARENT_SCOPE)
+ endfunction()
+endif()