diff options
Diffstat (limited to 'src/corelib/Qt6CoreMacros.cmake')
-rw-r--r-- | src/corelib/Qt6CoreMacros.cmake | 443 |
1 files changed, 359 insertions, 84 deletions
diff --git a/src/corelib/Qt6CoreMacros.cmake b/src/corelib/Qt6CoreMacros.cmake index d1001ad2af..847b4ca7a1 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) @@ -249,12 +270,29 @@ function(qt6_add_binary_resources target ) endforeach() add_custom_command(OUTPUT ${rcc_destination} + DEPENDS ${QT_CMAKE_EXPORT_NAMESPACE}::rcc COMMAND ${QT_CMAKE_EXPORT_NAMESPACE}::rcc ARGS ${rcc_options} --binary --name ${target} --output ${rcc_destination} ${infiles} - DEPENDS ${rc_depends} ${out_depends} ${infiles} VERBATIM) + DEPENDS + ${QT_CMAKE_EXPORT_NAMESPACE}::rcc + ${rc_depends} + ${out_depends} + ${infiles} + VERBATIM) + 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 @@ -293,7 +331,8 @@ function(qt6_add_resources outfiles ) COMMAND ${QT_CMAKE_EXPORT_NAMESPACE}::rcc ARGS ${rcc_options} --name ${outfilename} --output ${outfile} ${infile} MAIN_DEPENDENCY ${infile} - DEPENDS ${_rc_depends} "${_out_depends}" VERBATIM) + DEPENDS ${_rc_depends} "${_out_depends}" ${QT_CMAKE_EXPORT_NAMESPACE}::rcc + VERBATIM) set_source_files_properties(${outfile} PROPERTIES SKIP_AUTOMOC ON) set_source_files_properties(${outfile} PROPERTIES SKIP_AUTOUIC ON) list(APPEND ${outfiles} ${outfile}) @@ -302,6 +341,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 ) @@ -332,7 +385,8 @@ function(qt6_add_big_resources outfiles ) 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} - DEPENDS ${infile} ${_rc_depends} "${out_depends}" VERBATIM) + DEPENDS ${infile} ${_rc_depends} "${out_depends}" ${QT_CMAKE_EXPORT_NAMESPACE}::rcc + VERBATIM) add_custom_target(big_resources_${outfilename} ALL DEPENDS ${tmpoutfile}) add_library(rcc_object_${outfilename} OBJECT ${tmpoutfile}) set_target_properties(rcc_object_${outfilename} PROPERTIES AUTOMOC OFF) @@ -343,65 +397,71 @@ function(qt6_add_big_resources outfiles ) add_custom_command(OUTPUT ${outfile} COMMAND ${QT_CMAKE_EXPORT_NAMESPACE}::rcc ARGS ${rcc_options} --name ${outfilename} --pass 2 --temp $<TARGET_OBJECTS:rcc_object_${outfilename}> --output ${outfile} ${infile} - DEPENDS rcc_object_${outfilename} + DEPENDS rcc_object_${outfilename} ${QT_CMAKE_EXPORT_NAMESPACE}::rcc VERBATIM) list(APPEND ${outfiles} ${outfile}) endforeach() set(${outfiles} ${${outfiles}} PARENT_SCOPE) endfunction() -set(_Qt5_COMPONENT_PATH "${CMAKE_CURRENT_LIST_DIR}/..") - -if (NOT CMAKE_VERSION VERSION_LESS 2.8.9) - 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) - endif() - if(CMAKE_ERROR_DEPRECATED) - set(messageType FATAL_ERROR) - endif() - if(messageType) - message(${messageType} "The qt6_use_modules macro is obsolete. Use target_link_libraries with IMPORTED targets instead.") - endif() +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() - if (NOT TARGET ${_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(_qt6_modules ${ARGN}) - set(_qt6_link_type ${_link_type}) - else() - set(_qt6_modules ${_link_type} ${ARGN}) - endif() +set(_Qt6_COMPONENT_PATH "${CMAKE_CURRENT_LIST_DIR}/..") - if ("${_qt6_modules}" STREQUAL "") - message(FATAL_ERROR "qt6_use_modules requires at least one Qt module to use.") - endif() +macro(qt6_use_modules _target _link_type) + if(CMAKE_WARN_DEPRECATED) + set(messageType WARNING) + endif() + if(CMAKE_ERROR_DEPRECATED) + set(messageType FATAL_ERROR) + endif() + if(messageType) + message(${messageType} "The qt6_use_modules macro is obsolete. Use target_link_libraries with IMPORTED targets instead.") + endif() - 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} ${_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) - set_property(TARGET ${_target} APPEND PROPERTY COMPILE_DEFINITIONS_RELWITHDEBINFO QT_NO_DEBUG) - set_property(TARGET ${_target} APPEND PROPERTY COMPILE_DEFINITIONS_MINSIZEREL QT_NO_DEBUG) - if (Qt5_POSITION_INDEPENDENT_CODE - AND (CMAKE_VERSION VERSION_LESS 2.8.12 - AND (NOT CMAKE_CXX_COMPILER_ID STREQUAL "GNU" - OR CMAKE_CXX_COMPILER_VERSION VERSION_LESS 5.0))) - set_property(TARGET ${_target} PROPERTY POSITION_INDEPENDENT_CODE ${Qt5_POSITION_INDEPENDENT_CODE}) + if (NOT TARGET ${_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(_qt6_modules ${ARGN}) + set(_qt6_link_type ${_link_type}) + else() + set(_qt6_modules ${_link_type} ${ARGN}) + endif() + + if ("${_qt6_modules}" STREQUAL "") + message(FATAL_ERROR "qt6_use_modules requires at least one Qt module to use.") + endif() + + foreach(_module ${_qt6_modules}) + if (NOT Qt6${_module}_FOUND) + find_package(Qt6${_module} PATHS "${_Qt6_COMPONENT_PATH}" NO_DEFAULT_PATH) + if (NOT Qt6${_module}_FOUND) + message(FATAL_ERROR "Cannot use \"${_module}\" module which has not yet been found.") endif() - endforeach() - endmacro() -endif() + endif() + target_link_libraries(${_target} ${_qt6_link_type} ${Qt6${_module}_LIBRARIES}) + set_property(TARGET ${_target} APPEND PROPERTY INCLUDE_DIRECTORIES ${Qt6${_module}_INCLUDE_DIRS}) + set_property(TARGET ${_target} APPEND PROPERTY COMPILE_DEFINITIONS ${Qt6${_module}_COMPILE_DEFINITIONS}) + set_property(TARGET ${_target} APPEND PROPERTY COMPILE_DEFINITIONS_RELEASE QT_NO_DEBUG) + set_property(TARGET ${_target} APPEND PROPERTY COMPILE_DEFINITIONS_RELWITHDEBINFO QT_NO_DEBUG) + set_property(TARGET ${_target} APPEND PROPERTY COMPILE_DEFINITIONS_MINSIZEREL QT_NO_DEBUG) + if (Qt6_POSITION_INDEPENDENT_CODE + AND (NOT CMAKE_CXX_COMPILER_ID STREQUAL "GNU" + OR CMAKE_CXX_COMPILER_VERSION VERSION_LESS 5.0)) + set_property(TARGET ${_target} PROPERTY POSITION_INDEPENDENT_CODE ${Qt6_POSITION_INDEPENDENT_CODE}) + endif() + endforeach() +endmacro() function(add_qt_gui_executable target) if(ANDROID) @@ -423,13 +483,37 @@ function(add_qt_gui_executable target) if(ANDROID) qt_android_generate_deployment_settings("${target}") + qt_android_add_apk_target("${target}") + endif() +endfunction() + +function(_qt_get_plugin_name_with_version target out_var) + string(REGEX REPLACE "^Qt::(.+)" "Qt${QT_DEFAULT_MAJOR_VERSION}::\\1" + qt_plugin_with_version "${target}") + if(TARGET "${qt_plugin_with_version}") + set("${out_var}" "${qt_plugin_with_version}" PARENT_SCOPE) + else() + set("${out_var}" "" PARENT_SCOPE) endif() endfunction() macro(_qt_import_plugin target plugin) - get_target_property(plugin_class_name "${plugin}" QT_PLUGIN_CLASS_NAME) - if(plugin_class_name) - set_property(TARGET "${target}" APPEND PROPERTY QT_PLUGINS "${plugin}") + set(_final_plugin_name "${plugin}") + if(NOT TARGET "${plugin}") + _qt_get_plugin_name_with_version("${plugin}" _qt_plugin_with_version_name) + if(TARGET "${_qt_plugin_with_version_name}") + set(_final_plugin_name "${_qt_plugin_with_version_name}") + endif() + endif() + + if(NOT TARGET "${_final_plugin_name}") + message( + "Warning: plug-in ${_final_plugin_name} is not known to the current Qt installation.") + else() + get_target_property(_plugin_class_name "${_final_plugin_name}" QT_PLUGIN_CLASS_NAME) + if(_plugin_class_name) + set_property(TARGET "${target}" APPEND PROPERTY QT_PLUGINS "${plugin}") + endif() endif() endmacro() @@ -452,7 +536,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 @@ -483,7 +567,10 @@ function(qt_import_plugins target) message(FATAL_ERROR "qt_import_plugins: invalid syntax for INCLUDE_BY_TYPE") endif() - if(TARGET "${_arg}") + # Check if passed plugin target name is a version-less one, and make a version-full + # one. + _qt_get_plugin_name_with_version("${_arg}" qt_plugin_with_version) + if(TARGET "${_arg}" OR TARGET "${qt_plugin_with_version}") set_property(TARGET "${target}" APPEND PROPERTY "QT_PLUGINS_${_current_type}" "${_arg}") else() message("Warning: plug-in ${_arg} is not known to the current Qt installation.") @@ -498,34 +585,222 @@ 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") +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() + endfunction() +endif() + + +# Generate Qt metatypes.json for a target. By default we check whether AUTOMOC +# has been enabled and we extract the information from that target. Should you +# not wish to use automoc you need to pass in all the generated json files via the +# MANUAL_MOC_JSON_FILES parameter. The latter can be obtained by running moc with +# the --output-json parameter. +# Params: +# INSTALL_DIR: Location where to install the metatypes file (Optional) +# COPY_OVER_INSTALL: When present will install the file via a post build step +# copy rather than using install +function(qt6_generate_meta_types_json_file target) + + get_target_property(existing_meta_types_file ${target} INTERFACE_QT_META_TYPES_BUILD_FILE) + if (existing_meta_types_file) + return() + endif() + + cmake_parse_arguments(arg "COPY_OVER_INSTALL" "INSTALL_DIR" "MANUAL_MOC_JSON_FILES" ${ARGN}) + + if (NOT QT_BUILDING_QT) + if (NOT arg_INSTALL_DIR) + message(FATAL_ERROR "Please specify an install directory using INSTALL_DIR") + endif() + else() + # Automatically fill install args when building qt + set(metatypes_install_dir ${INSTALL_LIBDIR}/metatypes) + set(args) + if (NOT QT_WILL_INSTALL) + set(arg_COPY_OVER_INSTALL TRUE) + endif() + if (NOT arg_INSTALL_DIR) + set(arg_INSTALL_DIR "${metatypes_install_dir}") + endif() + endif() + + get_target_property(target_type ${target} TYPE) + if (target_type STREQUAL "INTERFACE_LIBRARY") + message(FATAL_ERROR "Meta types generation does not work on interface libraries") + return() + endif() + + if (CMAKE_VERSION VERSION_LESS "3.16.0") + message(FATAL_ERROR "Meta types generation requires CMake >= 3.16") + return() + endif() + + get_target_property(target_binary_dir ${target} BINARY_DIR) + set(type_list_file "${target_binary_dir}/meta_types/${target}_json_file_list.txt") + set(type_list_file_manual "${target_binary_dir}/meta_types/${target}_json_file_list_manual.txt") + + get_target_property(uses_automoc ${target} AUTOMOC) + set(automoc_args) + set(automoc_dependencies) + #Handle automoc generated data + if (uses_automoc) + # Tell automoc to output json files) + set_property(TARGET "${target}" APPEND PROPERTY + AUTOMOC_MOC_OPTIONS "--output-json" + ) + + if(CMAKE_BUILD_TYPE) + set(cmake_autogen_cache_file + "${target_binary_dir}/CMakeFiles/${target}_autogen.dir/ParseCache.txt") + set(mutli_config_args + --cmake-autogen-include-dir-path "${target_binary_dir}/${target}_autogen/include" + ) 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() + set(cmake_autogen_cache_file + "${target_binary_dir}/CMakeFiles/${target}_autogen.dir/ParseCache_$<CONFIG>.txt") + set(mutli_config_args + --cmake-autogen-include-dir-path "${target_binary_dir}/${target}_autogen/include_$<CONFIG>" + "--cmake-multi-config") endif() - endforeach() + + set(cmake_autogen_info_file + "${target_binary_dir}/CMakeFiles/${target}_autogen.dir/AutogenInfo.json") + + add_custom_target(${target}_automoc_json_extraction + DEPENDS ${QT_CMAKE_EXPORT_NAMESPACE}::cmake_automoc_parser + BYPRODUCTS ${type_list_file} + COMMAND + ${QT_CMAKE_EXPORT_NAMESPACE}::cmake_automoc_parser + --cmake-autogen-cache-file "${cmake_autogen_cache_file}" + --cmake-autogen-info-file "${cmake_autogen_info_file}" + --output-file-path "${type_list_file}" + ${mutli_config_args} + COMMENT "Running Automoc file extraction" + COMMAND_EXPAND_LISTS + ) + add_dependencies(${target}_automoc_json_extraction ${target}_autogen) + set(automoc_args "@${type_list_file}") + set(automoc_dependencies "${type_list_file}") + endif() + + set(manual_args) + set(manual_dependencies) + if(arg_MANUAL_MOC_JSON_FILES) + list(REMOVE_DUPLICATES arg_MANUAL_MOC_JSON_FILES) + file(GENERATE + OUTPUT ${type_list_file_manual} + CONTENT "$<JOIN:$<GENEX_EVAL:${arg_MANUAL_MOC_JSON_FILES}>,\n>" + ) + list(APPEND manual_dependencies ${arg_MANUAL_MOC_JSON_FILES} ${type_list_file_manual}) + set(manual_args "@${type_list_file_manual}") + endif() + + if (NOT manual_args AND NOT automoc_args) + message(FATAL_ERROR "Metatype generation requires either the use of AUTOMOC or a manual list of generated json files") + endif() + + if (CMAKE_BUILD_TYPE) + string(TOLOWER ${target}_${CMAKE_BUILD_TYPE} target_lowercase) + else() + string(TOLOWER ${target} target_lowercase) + endif() + + set(metatypes_file_name "qt6${target_lowercase}_metatypes.json") + set(metatypes_file "${target_binary_dir}/meta_types/${metatypes_file_name}") + set(metatypes_file_gen "${target_binary_dir}/meta_types/${metatypes_file_name}.gen") + + set(metatypes_dep_file_name "qt6${target_lowercase}_metatypes_dep.txt") + set(metatypes_dep_file "${target_binary_dir}/meta_types/${metatypes_dep_file_name}") + + # Due to generated source file dependency rules being tied to the directory + # scope in which they are created it is not possible for other targets which + # are defined in a separate scope to see these rules. This leads to failures + # in locating the generated source files. + # To work around this we write a dummy file to disk to make sure targets + # which link against the current target do not produce the error. This dummy + # file is then replaced with the contents of the generated file during + # build. + if (NOT EXISTS ${metatypes_file}) + file(MAKE_DIRECTORY "${target_binary_dir}/meta_types") + file(TOUCH ${metatypes_file}) + endif() + if (arg_COPY_OVER_INSTALL AND NOT EXISTS ${arg_INSTALL_DIR}/${metatypes_file_name}) + file(MAKE_DIRECTORY "${arg_INSTALL_DIR}") + file(TOUCH "${arg_INSTALL_DIR}/${metatypes_file_name}") + endif() + add_custom_command(OUTPUT ${metatypes_file_gen} ${metatypes_file} + DEPENDS ${QT_CMAKE_EXPORT_NAMESPACE}::moc ${automoc_dependencies} ${manual_dependencies} + COMMAND ${QT_CMAKE_EXPORT_NAMESPACE}::moc + -o ${metatypes_file_gen} + --collect-json ${automoc_args} ${manual_args} + COMMAND ${CMAKE_COMMAND} -E copy_if_different + ${metatypes_file_gen} + ${metatypes_file} + COMMENT "Runing automoc with --collect-json" + ) + + # We still need to add this file as a source of Core, otherwise the file + # rule above is not triggered. INTERFACE_SOURCES do not properly register + # as dependencies to build the current target. + target_sources(${target} PRIVATE ${metatypes_file_gen}) + set(metatypes_file_genex_build) + set(metatypes_file_genex_install) + if (arg_COPY_OVER_INSTALL) + set(metatypes_file_genex_build + "$<BUILD_INTERFACE:$<$<BOOL:$<TARGET_PROPERTY:QT_CONSUMES_METATYPES>>:${arg_INSTALL_DIR}/${metatypes_file_name}>>" + ) + else() + set(metatypes_file_genex_build + "$<BUILD_INTERFACE:$<$<BOOL:$<TARGET_PROPERTY:QT_CONSUMES_METATYPES>>:${metatypes_file}>>" + ) + set(metatypes_file_genex_install + "$<INSTALL_INTERFACE:$<$<BOOL:$<TARGET_PROPERTY:QT_CONSUMES_METATYPES>>:$<INSTALL_PREFIX>/${arg_INSTALL_DIR}/${metatypes_file_name}>>" + ) + endif() + set_source_files_properties(${metatypes_file} PROPERTIES HEADER_FILE_ONLY TRUE) + + set_target_properties(${target} PROPERTIES + INTERFACE_QT_MODULE_HAS_META_TYPES YES + INTERFACE_QT_MODULE_META_TYPES_FROM_BUILD YES + INTERFACE_QT_META_TYPES_BUILD_FILE ${metatypes_file} + QT_MODULE_META_TYPES_FILE_GENEX_BUILD "${metatypes_file_genex_build}" + QT_MODULE_META_TYPES_FILE_GENEX_INSTALL "${metatypes_file_genex_install}" + ) + target_sources(${target} INTERFACE ${metatypes_file_genex_build} ${metatypes_file_genex_install}) + + if (arg_COPY_OVER_INSTALL) + get_target_property(target_type ${target} TYPE) + set(command_args + COMMAND ${CMAKE_COMMAND} -E copy_if_different + "${metatypes_file}" + "${arg_INSTALL_DIR}/${metatypes_file_name}" + ) + if (target_type STREQUAL "OBJECT_LIBRARY") + add_custom_target(${target}_metatypes_copy + DEPENDS "${metatypes_file}" + ${command_args} + ) + add_dependencies(${target} ${target}_metatypes_copy) + else() + add_custom_command(TARGET ${target} POST_BUILD + ${command_args} + ) + endif() + else() + install(FILES "${metatypes_file}" + DESTINATION "${arg_INSTALL_DIR}" + ) + endif() endfunction() + +if(NOT QT_NO_CREATE_VERSIONLESS_FUNCTIONS) + function(qt_generate_meta_types_json_file) + qt6_generate_meta_types_json_file(${ARGV}) + endfunction() +endif() |