diff options
-rw-r--r-- | src/corelib/Qt6CoreConfigExtras.cmake.in | 3 | ||||
-rw-r--r-- | src/corelib/Qt6CoreMacros.cmake | 102 | ||||
-rw-r--r-- | src/dbus/Qt6DBusMacros.cmake | 43 | ||||
-rw-r--r-- | src/widgets/Qt6WidgetsMacros.cmake | 16 |
4 files changed, 131 insertions, 33 deletions
diff --git a/src/corelib/Qt6CoreConfigExtras.cmake.in b/src/corelib/Qt6CoreConfigExtras.cmake.in index 21bf788c89..cb1dc9689c 100644 --- a/src/corelib/Qt6CoreConfigExtras.cmake.in +++ b/src/corelib/Qt6CoreConfigExtras.cmake.in @@ -1,3 +1,6 @@ +if(NOT DEFINED QT_DEFAULT_MAJOR_VERSION) + set(QT_DEFAULT_MAJOR_VERSION 6) +endif() # include(\"${CMAKE_CURRENT_LIST_DIR}/Qt5CoreConfigExtrasMkspecDir.cmake\") # diff --git a/src/corelib/Qt6CoreMacros.cmake b/src/corelib/Qt6CoreMacros.cmake index cf860cd9ad..ff1e1d1910 100644 --- a/src/corelib/Qt6CoreMacros.cmake +++ b/src/corelib/Qt6CoreMacros.cmake @@ -157,6 +157,16 @@ function(qt6_generate_moc infile outfile ) qt6_create_moc_command(${abs_infile} ${_outfile} "${moc_flags}" "" "${moc_target}" "") endfunction() +if(NOT QT_NO_CREATE_VERSIONLESS_FUNCTIONS) + function(qt_generate_moc) + if(QT_DEFAULT_MAJOR_VERSION EQUAL 5) + qt5_generate_moc(${ARGV}) + elseif(QT_DEFAULT_MAJOR_VERSION EQUAL 6) + qt6_generate_moc(${ARGV}) + endif() + endfunction() +endif() + # qt6_wrap_cpp(outfiles inputfile ... ) @@ -184,6 +194,17 @@ function(qt6_wrap_cpp outfiles ) set(${outfiles} ${${outfiles}} PARENT_SCOPE) endfunction() +# This will override the CMake upstream command, because that one is for Qt 3. +if(NOT QT_NO_CREATE_VERSIONLESS_FUNCTIONS) + function(qt_wrap_cpp outfiles) + if(QT_DEFAULT_MAJOR_VERSION EQUAL 5) + qt5_wrap_cpp("${outfiles}" ${ARGN}) + elseif(QT_DEFAULT_MAJOR_VERSION EQUAL 6) + qt6_wrap_cpp("${outfiles}" ${ARGN}) + endif() + set("${outfiles}" "${${outfiles}}" PARENT_SCOPE) + endfunction() +endif() # _qt6_parse_qrc_file(infile _out_depends _rc_depends) @@ -255,6 +276,16 @@ function(qt6_add_binary_resources target ) add_custom_target(${target} ALL DEPENDS ${rcc_destination}) endfunction() +if(NOT QT_NO_CREATE_VERSIONLESS_FUNCTIONS) + function(qt_add_binary_resources) + if(QT_DEFAULT_MAJOR_VERSION EQUAL 5) + qt5_add_binary_resources(${ARGV}) + elseif(QT_DEFAULT_MAJOR_VERSION EQUAL 6) + qt6_add_binary_resources(${ARGV}) + endif() + endfunction() +endif() + # qt6_add_resources(target resourcename ... # or @@ -302,6 +333,20 @@ function(qt6_add_resources outfiles ) endif() endfunction() +if(NOT QT_NO_CREATE_VERSIONLESS_FUNCTIONS) + function(qt_add_resources outfiles) + if(QT_DEFAULT_MAJOR_VERSION EQUAL 5) + qt5_add_resources("${outfiles}" ${ARGN}) + elseif(QT_DEFAULT_MAJOR_VERSION EQUAL 6) + qt6_add_resources("${outfiles}" ${ARGN}) + endif() + if(NOT TARGET ${outfiles}) + set("${outfiles}" "${${outfiles}}" PARENT_SCOPE) + endif() + endfunction() +endif() + + # qt6_add_big_resources(outfiles inputfile ... ) function(qt6_add_big_resources outfiles ) @@ -350,6 +395,17 @@ function(qt6_add_big_resources outfiles ) set(${outfiles} ${${outfiles}} PARENT_SCOPE) endfunction() +if(NOT QT_NO_CREATE_VERSIONLESS_FUNCTIONS) + function(qt_add_big_resources outfiles) + if(QT_DEFAULT_MAJOR_VERSION EQUAL 5) + qt5_add_big_resources(${outfiles} ${ARGN}) + elseif(QT_DEFAULT_MAJOR_VERSION EQUAL 6) + qt6_add_big_resources(${outfiles} ${ARGN}) + endif() + set("${outfiles}" "${${outfiles}}" PARENT_SCOPE) + endfunction() +endif() + set(_Qt6_COMPONENT_PATH "${CMAKE_CURRENT_LIST_DIR}/..") macro(qt6_use_modules _target _link_type) @@ -448,7 +504,7 @@ endmacro() # ) # TODO : support qml plug-ins. -function(qt_import_plugins target) +function(qt6_import_plugins target) cmake_parse_arguments(arg "NO_DEFAULT" "" "INCLUDE;EXCLUDE;INCLUDE_BY_TYPE;EXCLUDE_BY_TYPE" ${ARGN}) # Handle NO_DEFAULT @@ -494,37 +550,15 @@ function(qt_import_plugins target) endforeach() endfunction() -function(qt6_import_plugins TARGET_NAME) - set(_doing "") - foreach(_arg ${ARGN}) - if(_arg STREQUAL "INCLUDE") - set(_doing "INCLUDE") - elseif(_arg STREQUAL "EXCLUDE") - set(_doing "EXCLUDE") - elseif(_arg STREQUAL "INCLUDE_BY_TYPE") - set(_doing "INCLUDE_BY_TYPE") - elseif(_arg STREQUAL "EXCLUDE_BY_TYPE") - set(_doing "EXCLUDE_BY_TYPE") - else() - if(_doing STREQUAL "INCLUDE") - set_property(TARGET ${TARGET_NAME} APPEND PROPERTY QT_PLUGINS "${_arg}") - elseif(_doing STREQUAL "EXCLUDE") - set_property(TARGET ${TARGET_NAME} APPEND PROPERTY QT_NO_PLUGINS "${_arg}") - elseif(_doing STREQUAL "INCLUDE_BY_TYPE") - string(REGEX REPLACE "[-/]" "_" _plugin_type "${_arg}") - set(_doing "INCLUDE_BY_TYPE_PLUGINS") - elseif(_doing STREQUAL "INCLUDE_BY_TYPE_PLUGINS") - set_property(TARGET ${TARGET_NAME} APPEND PROPERTY "QT_PLUGINS_${_plugin_type}" "${_arg}") - elseif(_doing STREQUAL "EXCLUDE_BY_TYPE") - string(REGEX REPLACE "[-/]" "_" _plugin_type "${_arg}") - set_property(TARGET ${TARGET_NAME} PROPERTY "QT_PLUGINS_${_plugin_type}" -) - set(_doing "") - else() - message(FATAL_ERROR "Unexpected extra argument: \"${_arg}\"") - endif() +if(NOT QT_NO_CREATE_VERSIONLESS_FUNCTIONS) + function(qt_import_plugins) + if(QT_DEFAULT_MAJOR_VERSION EQUAL 5) + qt5_import_plugins(${ARGV}) + elseif(QT_DEFAULT_MAJOR_VERSION EQUAL 6) + qt6_import_plugins(${ARGV}) endif() - endforeach() -endfunction() + endfunction() +endif() function(qt6_generate_meta_types_json_file target) @@ -596,3 +630,9 @@ function(qt6_generate_meta_types_json_file target) QT_MODULE_META_TYPES_FILE ${metatypes_file} ) endfunction() + +if(NOT QT_NO_CREATE_VERSIONLESS_FUNCTIONS) + function(qt_generate_meta_types_json_file) + qt6_generate_meta_types_json_file(${ARGV}) + endfunction() +endif() diff --git a/src/dbus/Qt6DBusMacros.cmake b/src/dbus/Qt6DBusMacros.cmake index edbadab3d1..85de817a0b 100644 --- a/src/dbus/Qt6DBusMacros.cmake +++ b/src/dbus/Qt6DBusMacros.cmake @@ -70,6 +70,17 @@ function(qt6_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(qt6_add_dbus_interfaces _sources) foreach(_current_FILE ${ARGN}) @@ -83,6 +94,17 @@ function(qt6_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(qt6_generate_dbus_interface _header) # _customName OPTIONS -some -options ) set(options) @@ -116,6 +138,16 @@ function(qt6_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(qt6_add_dbus_adaptor _sources _xml_file _include _parentClass) # _optionalBasename _optionalClassName) get_filename_component(_infile ${_xml_file} ABSOLUTE) @@ -152,3 +184,14 @@ function(qt6_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() diff --git a/src/widgets/Qt6WidgetsMacros.cmake b/src/widgets/Qt6WidgetsMacros.cmake index f996b66519..5b0f2e700f 100644 --- a/src/widgets/Qt6WidgetsMacros.cmake +++ b/src/widgets/Qt6WidgetsMacros.cmake @@ -39,9 +39,9 @@ include(CMakeParseArguments) -# qt5_wrap_ui(outfiles inputfile ... ) +# qt6_wrap_ui(outfiles inputfile ... ) -function(qt5_wrap_ui outfiles ) +function(qt6_wrap_ui outfiles ) set(options) set(oneValueArgs) set(multiValueArgs OPTIONS) @@ -66,3 +66,15 @@ function(qt5_wrap_ui outfiles ) endforeach() set(${outfiles} ${${outfiles}} PARENT_SCOPE) endfunction() + +# This will override the CMake upstream command, because that one is for Qt 3. +if(NOT QT_NO_CREATE_VERSIONLESS_FUNCTIONS) + function(qt_wrap_ui outfiles) + if(QT_DEFAULT_MAJOR_VERSION EQUAL 5) + qt5_wrap_ui("${outfiles}" ${ARGN}) + elseif(QT_DEFAULT_MAJOR_VERSION EQUAL 6) + qt6_wrap_ui("${outfiles}" ${ARGN}) + endif() + set("${outfiles}" "${${outfiles}}" PARENT_SCOPE) + endfunction() +endif() |