Update public CMake macros' version

Update all public Qt macros to use qt6/QT6 instead of qt5/QT6.

Change-Id: Ib178f4fa21f37dfb8da7d4d8c097aa0e96c9d9f9
Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io>
This commit is contained in:
Leander Beernaert 2019-08-23 11:39:30 +02:00
parent acdc5dfaee
commit bf298499a0
7 changed files with 51 additions and 51 deletions

View File

@ -16,11 +16,11 @@ find_package(Qt6 COMPONENTS Widgets)
# special case begin
set(chat_SRCS)
qt5_add_dbus_interface(chat_SRCS
qt6_add_dbus_interface(chat_SRCS
org.example.chat.xml
chat_interface
)
qt5_add_dbus_adaptor(chat_SRCS
qt6_add_dbus_adaptor(chat_SRCS
org.example.chat.xml
qobject.h
QObject

View File

@ -16,7 +16,7 @@ find_package(Qt6 COMPONENTS Widgets)
# special case begin
set(car_SRCS)
qt5_add_dbus_adaptor(car_SRCS
qt6_add_dbus_adaptor(car_SRCS
car.xml
car.h
Car

View File

@ -16,7 +16,7 @@ find_package(Qt6 COMPONENTS Widgets)
# special case begin
set(controller_SRCS)
qt5_add_dbus_interface(controller_SRCS
qt6_add_dbus_interface(controller_SRCS
car.xml
car_interface
)

View File

@ -2,7 +2,7 @@
# special case:
add_library(painting_shared OBJECT)
qt5_wrap_cpp(moc_files arthurwidgets.h hoverpoints.h) # no automoc for OBJECT libs:-/
qt6_wrap_cpp(moc_files arthurwidgets.h hoverpoints.h) # no automoc for OBJECT libs:-/
target_sources(painting_shared PRIVATE
arthurstyle.cpp arthurstyle.h
arthurwidgets.cpp arthurwidgets.h
@ -12,7 +12,7 @@ target_sources(painting_shared PRIVATE
target_link_libraries(painting_shared PUBLIC Qt::Widgets)
target_include_directories(painting_shared PUBLIC "${CMAKE_CURRENT_SOURCE_DIR}")
qt5_add_resources(res_files shared.qrc)
qt6_add_resources(res_files shared.qrc)
target_sources(painting_shared PRIVATE ${res_files})
## Scopes:

View File

@ -39,7 +39,7 @@
include(CMakeParseArguments)
# macro used to create the names of output files preserving relative dirs
macro(QT5_MAKE_OUTPUT_FILE infile prefix ext outfile )
macro(QT6_MAKE_OUTPUT_FILE infile prefix ext outfile )
string(LENGTH ${CMAKE_CURRENT_BINARY_DIR} _binlength)
string(LENGTH ${infile} _infileLength)
set(_checkinfile ${CMAKE_CURRENT_SOURCE_DIR})
@ -65,7 +65,7 @@ macro(QT5_MAKE_OUTPUT_FILE infile prefix ext outfile )
endmacro()
macro(QT5_GET_MOC_FLAGS _moc_flags)
macro(QT6_GET_MOC_FLAGS _moc_flags)
set(${_moc_flags})
get_directory_property(_inc_DIRS INCLUDE_DIRECTORIES)
@ -97,7 +97,7 @@ endmacro()
# helper macro to set up a moc rule
function(QT5_CREATE_MOC_COMMAND infile outfile moc_flags moc_options moc_target moc_depends)
function(QT6_CREATE_MOC_COMMAND infile outfile moc_flags moc_options moc_target moc_depends)
# Pass the parameters in a file. Set the working directory to
# be that containing the parameters file and reference it by
# just the file name. This is necessary because the moc tool on
@ -143,9 +143,9 @@ function(QT5_CREATE_MOC_COMMAND infile outfile moc_flags moc_options moc_target
endfunction()
function(QT5_GENERATE_MOC infile outfile )
function(QT6_GENERATE_MOC infile outfile )
# get include dirs and flags
qt5_get_moc_flags(moc_flags)
qt6_get_moc_flags(moc_flags)
get_filename_component(abs_infile ${infile} ABSOLUTE)
set(_outfile "${outfile}")
if(NOT IS_ABSOLUTE "${outfile}")
@ -154,15 +154,15 @@ function(QT5_GENERATE_MOC infile outfile )
if ("x${ARGV2}" STREQUAL "xTARGET")
set(moc_target ${ARGV3})
endif()
qt5_create_moc_command(${abs_infile} ${_outfile} "${moc_flags}" "" "${moc_target}" "")
qt6_create_moc_command(${abs_infile} ${_outfile} "${moc_flags}" "" "${moc_target}" "")
endfunction()
# qt5_wrap_cpp(outfiles inputfile ... )
# qt6_wrap_cpp(outfiles inputfile ... )
function(QT5_WRAP_CPP outfiles )
function(QT6_WRAP_CPP outfiles )
# get include dirs
qt5_get_moc_flags(moc_flags)
qt6_get_moc_flags(moc_flags)
set(options)
set(oneValueArgs TARGET)
@ -177,8 +177,8 @@ function(QT5_WRAP_CPP outfiles )
foreach(it ${moc_files})
get_filename_component(it ${it} ABSOLUTE)
qt5_make_output_file(${it} moc_ cpp outfile)
qt5_create_moc_command(${it} ${outfile} "${moc_flags}" "${moc_options}" "${moc_target}" "${moc_depends}")
qt6_make_output_file(${it} moc_ cpp outfile)
qt6_create_moc_command(${it} ${outfile} "${moc_flags}" "${moc_options}" "${moc_target}" "${moc_depends}")
list(APPEND ${outfiles} ${outfile})
endforeach()
set(${outfiles} ${${outfiles}} PARENT_SCOPE)
@ -186,10 +186,10 @@ endfunction()
# _qt5_parse_qrc_file(infile _out_depends _rc_depends)
# _qt6_parse_qrc_file(infile _out_depends _rc_depends)
# internal
function(_QT5_PARSE_QRC_FILE infile _out_depends _rc_depends)
function(_QT6_PARSE_QRC_FILE infile _out_depends _rc_depends)
get_filename_component(rc_path ${infile} PATH)
if(EXISTS "${infile}")
@ -207,7 +207,7 @@ function(_QT5_PARSE_QRC_FILE infile _out_depends _rc_depends)
# Since this cmake macro is doing the dependency scanning for these files,
# let's make a configured file and add it as a dependency so cmake is run
# again when dependencies need to be recomputed.
qt5_make_output_file("${infile}" "" "qrc.depends" out_depends)
qt6_make_output_file("${infile}" "" "qrc.depends" out_depends)
configure_file("${infile}" "${out_depends}" COPYONLY)
else()
# The .qrc file does not exist (yet). Let's add a dependency and hope
@ -220,9 +220,9 @@ function(_QT5_PARSE_QRC_FILE infile _out_depends _rc_depends)
endfunction()
# qt5_add_binary_resources(target inputfiles ... )
# qt6_add_binary_resources(target inputfiles ... )
function(QT5_ADD_BINARY_RESOURCES target )
function(QT6_ADD_BINARY_RESOURCES target )
set(options)
set(oneValueArgs DESTINATION)
@ -241,7 +241,7 @@ function(QT5_ADD_BINARY_RESOURCES target )
foreach(it ${rcc_files})
get_filename_component(infile ${it} ABSOLUTE)
_QT5_PARSE_QRC_FILE(${infile} _out_depends _rc_depends)
_QT6_PARSE_QRC_FILE(${infile} _out_depends _rc_depends)
set_source_files_properties(${infile} PROPERTIES SKIP_AUTORCC ON)
set(infiles ${infiles} ${infile})
set(out_depends ${out_depends} ${_out_depends})
@ -256,11 +256,11 @@ function(QT5_ADD_BINARY_RESOURCES target )
endfunction()
# qt5_add_resources(target resourcename ...
# qt6_add_resources(target resourcename ...
# or
# qt5_add_resources(outfiles inputfile ... )
# qt6_add_resources(outfiles inputfile ... )
function(QT5_ADD_RESOURCES outfiles )
function(QT6_ADD_RESOURCES outfiles )
if (TARGET ${outfiles})
QT6_PROCESS_RESOURCE(${ARGV})
else()
@ -274,7 +274,7 @@ function(QT5_ADD_RESOURCES outfiles )
set(rcc_options ${_RCC_OPTIONS})
if("${rcc_options}" MATCHES "-binary")
message(WARNING "Use qt5_add_binary_resources for binary option")
message(WARNING "Use qt6_add_binary_resources for binary option")
endif()
foreach(it ${rcc_files})
@ -282,7 +282,7 @@ function(QT5_ADD_RESOURCES outfiles )
get_filename_component(infile ${it} ABSOLUTE)
set(outfile ${CMAKE_CURRENT_BINARY_DIR}/qrc_${outfilename}.cpp)
_QT5_PARSE_QRC_FILE(${infile} _out_depends _rc_depends)
_QT6_PARSE_QRC_FILE(${infile} _out_depends _rc_depends)
set_source_files_properties(${infile} PROPERTIES SKIP_AUTORCC ON)
add_custom_command(OUTPUT ${outfile}
@ -298,11 +298,11 @@ function(QT5_ADD_RESOURCES outfiles )
endif()
endfunction()
# qt5_add_big_resources(outfiles inputfile ... )
# qt6_add_big_resources(outfiles inputfile ... )
function(QT5_ADD_BIG_RESOURCES outfiles )
function(QT6_ADD_BIG_RESOURCES outfiles )
if (CMAKE_VERSION VERSION_LESS 3.9)
message(FATAL_ERROR, "qt5_add_big_resources requires CMake 3.9 or newer")
message(FATAL_ERROR, "qt6_add_big_resources requires CMake 3.9 or newer")
endif()
set(options)
@ -315,7 +315,7 @@ function(QT5_ADD_BIG_RESOURCES outfiles )
set(rcc_options ${_RCC_OPTIONS})
if("${rcc_options}" MATCHES "-binary")
message(WARNING "Use qt5_add_binary_resources for binary option")
message(WARNING "Use qt6_add_binary_resources for binary option")
endif()
foreach(it ${rcc_files})
@ -324,7 +324,7 @@ function(QT5_ADD_BIG_RESOURCES outfiles )
set(tmpoutfile ${CMAKE_CURRENT_BINARY_DIR}/qrc_${outfilename}tmp.cpp)
set(outfile ${CMAKE_CURRENT_BINARY_DIR}/qrc_${outfilename}.o)
_QT5_PARSE_QRC_FILE(${infile} _out_depends _rc_depends)
_QT6_PARSE_QRC_FILE(${infile} _out_depends _rc_depends)
set_source_files_properties(${infile} PROPERTIES SKIP_AUTORCC ON)
add_custom_command(OUTPUT ${tmpoutfile}
COMMAND ${QT_CMAKE_EXPORT_NAMESPACE}::rcc ${rcc_options} --name ${outfilename} --pass 1 --output ${tmpoutfile} ${infile}
@ -349,7 +349,7 @@ endfunction()
set(_Qt5_COMPONENT_PATH "${CMAKE_CURRENT_LIST_DIR}/..")
if (NOT CMAKE_VERSION VERSION_LESS 2.8.9)
macro(qt5_use_modules _target _link_type)
macro(qt6_use_modules _target _link_type)
if(NOT CMAKE_MINIMUM_REQUIRED_VERSION VERSION_LESS 2.8.11)
if(CMAKE_WARN_DEPRECATED)
set(messageType WARNING)
@ -358,32 +358,32 @@ if (NOT CMAKE_VERSION VERSION_LESS 2.8.9)
set(messageType FATAL_ERROR)
endif()
if(messageType)
message(${messageType} "The qt5_use_modules macro is obsolete. Use target_link_libraries with IMPORTED targets instead.")
message(${messageType} "The qt6_use_modules macro is obsolete. Use target_link_libraries with IMPORTED targets instead.")
endif()
endif()
if (NOT TARGET ${_target})
message(FATAL_ERROR "The first argument to qt5_use_modules must be an existing target.")
message(FATAL_ERROR "The first argument to qt6_use_modules must be an existing target.")
endif()
if ("${_link_type}" STREQUAL "LINK_PUBLIC" OR "${_link_type}" STREQUAL "LINK_PRIVATE" )
set(_qt5_modules ${ARGN})
set(_qt5_link_type ${_link_type})
set(_qt6_modules ${ARGN})
set(_qt6_link_type ${_link_type})
else()
set(_qt5_modules ${_link_type} ${ARGN})
set(_qt6_modules ${_link_type} ${ARGN})
endif()
if ("${_qt5_modules}" STREQUAL "")
message(FATAL_ERROR "qt5_use_modules requires at least one Qt module to use.")
if ("${_qt6_modules}" STREQUAL "")
message(FATAL_ERROR "qt6_use_modules requires at least one Qt module to use.")
endif()
foreach(_module ${_qt5_modules})
foreach(_module ${_qt6_modules})
if (NOT Qt5${_module}_FOUND)
find_package(Qt5${_module} PATHS "${_Qt5_COMPONENT_PATH}" NO_DEFAULT_PATH)
if (NOT Qt5${_module}_FOUND)
message(FATAL_ERROR "Cannot use \"${_module}\" module which has not yet been found.")
endif()
endif()
target_link_libraries(${_target} ${_qt5_link_type} ${Qt5${_module}_LIBRARIES})
target_link_libraries(${_target} ${_qt6_link_type} ${Qt5${_module}_LIBRARIES})
set_property(TARGET ${_target} APPEND PROPERTY INCLUDE_DIRECTORIES ${Qt5${_module}_INCLUDE_DIRS})
set_property(TARGET ${_target} APPEND PROPERTY COMPILE_DEFINITIONS ${Qt5${_module}_COMPILE_DEFINITIONS})
set_property(TARGET ${_target} APPEND PROPERTY COMPILE_DEFINITIONS_RELEASE QT_NO_DEBUG)

View File

@ -34,7 +34,7 @@ include(MacroAddFileDependencies)
include(CMakeParseArguments)
function(QT5_ADD_DBUS_INTERFACE _sources _interface _basename)
function(QT6_ADD_DBUS_INTERFACE _sources _interface _basename)
get_filename_component(_infile ${_interface} ABSOLUTE)
set(_header "${CMAKE_CURRENT_BINARY_DIR}/${_basename}.h")
set(_impl "${CMAKE_CURRENT_BINARY_DIR}/${_basename}.cpp")
@ -63,7 +63,7 @@ function(QT5_ADD_DBUS_INTERFACE _sources _interface _basename)
set_source_files_properties("${_impl}" "${_header}" PROPERTIES SKIP_AUTOMOC TRUE)
qt5_generate_moc("${_header}" "${_moc}")
qt6_generate_moc("${_header}" "${_moc}")
list(APPEND ${_sources} "${_impl}" "${_header}" "${_moc}")
macro_add_file_dependencies("${_impl}" "${_moc}")
@ -71,20 +71,20 @@ function(QT5_ADD_DBUS_INTERFACE _sources _interface _basename)
endfunction()
function(QT5_ADD_DBUS_INTERFACES _sources)
function(QT6_ADD_DBUS_INTERFACES _sources)
foreach(_current_FILE ${ARGN})
get_filename_component(_infile ${_current_FILE} ABSOLUTE)
get_filename_component(_basename ${_current_FILE} NAME)
# get the part before the ".xml" suffix
string(TOLOWER ${_basename} _basename)
string(REGEX REPLACE "(.*\\.)?([^\\.]+)\\.xml" "\\2" _basename ${_basename})
qt5_add_dbus_interface(${_sources} ${_infile} ${_basename}interface)
qt6_add_dbus_interface(${_sources} ${_infile} ${_basename}interface)
endforeach()
set(${_sources} ${${_sources}} PARENT_SCOPE)
endfunction()
function(QT5_GENERATE_DBUS_INTERFACE _header) # _customName OPTIONS -some -options )
function(QT6_GENERATE_DBUS_INTERFACE _header) # _customName OPTIONS -some -options )
set(options)
set(oneValueArgs)
set(multiValueArgs OPTIONS)
@ -117,7 +117,7 @@ function(QT5_GENERATE_DBUS_INTERFACE _header) # _customName OPTIONS -some -optio
endfunction()
function(QT5_ADD_DBUS_ADAPTOR _sources _xml_file _include _parentClass) # _optionalBasename _optionalClassName)
function(QT6_ADD_DBUS_ADAPTOR _sources _xml_file _include _parentClass) # _optionalBasename _optionalClassName)
get_filename_component(_infile ${_xml_file} ABSOLUTE)
set(_optionalBasename "${ARGV4}")
@ -145,7 +145,7 @@ function(QT5_ADD_DBUS_ADAPTOR _sources _xml_file _include _parentClass) # _optio
)
endif()
qt5_generate_moc("${_header}" "${_moc}")
qt6_generate_moc("${_header}" "${_moc}")
set_source_files_properties("${_impl}" "${_header}" PROPERTIES SKIP_AUTOMOC TRUE)
macro_add_file_dependencies("${_impl}" "${_moc}")

View File

@ -214,7 +214,7 @@ def write_add_qt_resource_call(target: str, resource_name: str, prefix: typing.O
params += ' BASE\n "{}"\n'.format(base_dir)
add_resource_command = ''
if is_example:
add_resource_command = 'QT5_ADD_RESOURCES'
add_resource_command = 'QT6_ADD_RESOURCES'
else:
add_resource_command = 'add_qt_resource'
output += '{}({} "{}"\n{} FILES\n {}\n)\n'.format(add_resource_command,