diff options
author | Alexandru Croitor <alexandru.croitor@qt.io> | 2019-12-05 13:52:33 +0100 |
---|---|---|
committer | Alexandru Croitor <alexandru.croitor@qt.io> | 2020-01-27 11:49:44 +0000 |
commit | f53ca8a4fc1e82d1c4802e387abe759b53f74b62 (patch) | |
tree | cf23ff3170fd753b46e39f2a5e497353da7bc1a9 /src/corelib/Qt6CoreMacros.cmake | |
parent | b10d8eab047c387409716ae87422d2efffee3159 (diff) |
CMake: Add Qt 5 backward compatible CMake API
Create versionless function names, that coincide with the Qt 5 CMake
API.
Task-number: QTBUG-74137
Task-number: QTBUG-80477
Change-Id: I8559b2c8a49b23e5a89ec81603aaec54ea634d70
Reviewed-by: Qt CMake Build Bot
Reviewed-by: Simon Hausmann <simon.hausmann@qt.io>
Diffstat (limited to 'src/corelib/Qt6CoreMacros.cmake')
-rw-r--r-- | src/corelib/Qt6CoreMacros.cmake | 102 |
1 files changed, 71 insertions, 31 deletions
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() |