CMake: Store the plugin types in the module json files

This will be read by windeployqt.

Change-Id: I8dfebae755ef61967e924db3c5631af5cc4e2440
Reviewed-by: Alexey Edelev <alexey.edelev@qt.io>
(cherry picked from commit 0b92502de28f5ecfd9622a222c92211b6325ae84)
This commit is contained in:
Joerg Bornemann 2022-12-08 15:47:27 +01:00
parent 6fc1214133
commit facf9f9a34
2 changed files with 25 additions and 1 deletions

View File

@ -1,6 +1,7 @@
{
"name": "${target}",
"version": "${PROJECT_VERSION}",
"repository": "${lower_case_project_name}",
"version": "${PROJECT_VERSION}",${extra_module_information}
"built_with": {${extra_build_information}
"compiler_id": "${CMAKE_CXX_COMPILER_ID}",
"compiler_target": "${CMAKE_CXX_COMPILER_TARGET}",

View File

@ -1030,6 +1030,17 @@ the different base name for the module info variables.")
"${${result}_install_interface_qpa_include_dir}" PARENT_SCOPE)
endfunction()
function(qt_internal_list_to_json_array out_var list_var)
set(result "")
foreach(item IN LISTS ${list_var})
if(NOT "${result}" STREQUAL "")
string(APPEND result ", ")
endif()
string(APPEND result "\"${item}\"")
endforeach()
set("${out_var}" "[${result}]" PARENT_SCOPE)
endfunction()
# Generate a module description file based on the template in ModuleDescription.json.in
function(qt_describe_module target)
set(path_suffix "${INSTALL_DESCRIPTIONSDIR}")
@ -1038,10 +1049,22 @@ function(qt_describe_module target)
set(descfile_in "${QT_CMAKE_DIR}/ModuleDescription.json.in")
set(descfile_out "${build_dir}/${target}.json")
string(TOLOWER "${PROJECT_NAME}" lower_case_project_name)
set(cross_compilation "false")
if(CMAKE_CROSSCOMPILING)
set(cross_compilation "true")
endif()
set(extra_module_information "")
get_target_property(target_type ${target} TYPE)
if(NOT target_type STREQUAL "INTERFACE_LIBRARY")
get_target_property(plugin_types ${target} MODULE_PLUGIN_TYPES)
if(plugin_types)
qt_internal_list_to_json_array(plugin_types plugin_types)
string(APPEND extra_module_information "\n \"plugin_types\": ${plugin_types},")
endif()
endif()
set(extra_build_information "")
if(ANDROID)
string(APPEND extra_build_information "