diff --git a/cmake/ModuleDescription.json.in b/cmake/ModuleDescription.json.in index 93f9a5ed257..e8b58387d9e 100644 --- a/cmake/ModuleDescription.json.in +++ b/cmake/ModuleDescription.json.in @@ -1,13 +1,8 @@ { + "schema_version": 2, "name": "${target}", "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}", - "compiler_version": "${CMAKE_CXX_COMPILER_VERSION}", - "cross_compiled": ${cross_compilation}, - "target_system": "${CMAKE_SYSTEM_NAME}", - "architecture": "${TEST_architecture_arch}" - } + "platforms": [${platforms_information} + ] } diff --git a/cmake/QtModuleHelpers.cmake b/cmake/QtModuleHelpers.cmake index 4b59b670313..21419a7947c 100644 --- a/cmake/QtModuleHelpers.cmake +++ b/cmake/QtModuleHelpers.cmake @@ -1233,11 +1233,8 @@ 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 "") + set(platforms_information "") get_target_property(target_type ${target} TYPE) if(NOT target_type STREQUAL "INTERFACE_LIBRARY") @@ -1248,27 +1245,103 @@ function(qt_describe_module target) endif() endif() + # Generate extra module information get_target_property(is_internal ${target} _qt_is_internal_module) if(is_internal) string(APPEND extra_module_information "\n \"internal\": true,") endif() - - set(extra_build_information "") + if(APPLE) + set(bundle_type "none") + if(QT_FEATURE_framework) + set(bundle_type "framework") + endif() + string(APPEND extra_module_information "\n \"bundle_type\": \"framework\",") + endif() if(NOT QT_NAMESPACE STREQUAL "") - string(APPEND extra_build_information " - \"namespace\": \"${QT_NAMESPACE}\",") + string(APPEND extra_module_information "\n \"namespace\": \"${QT_NAMESPACE}\",") endif() - if(ANDROID) - string(APPEND extra_build_information " - \"android\": { - \"api_version\": \"${QT_ANDROID_API_USED_FOR_JAVA}\", - \"ndk\": { - \"version\": \"${ANDROID_NDK_REVISION}\" - } - },") - endif() - configure_file("${descfile_in}" "${descfile_out}") + # Set up indentation helper variables. + set(indent1 " ") + set(k 1) + foreach(i RANGE 2 5) + set(indent${i} "${indent${k}}${indent1}") + set(k ${i}) + endforeach() + + # Set up the platforms to write. + set(nr_of_platforms 1) + set(platform_0_name "${CMAKE_SYSTEM_NAME}") + set(platform_0_variant "") + set(platform_0_architectures "${TEST_architecture_architectures}") + + # Handle iOS builds specially. + if(platform_0_name STREQUAL "iOS") + if(QT_FEATURE_simulator_and_device) + # This must match the setup done in qt_auto_detect_apple. + set(nr_of_platforms 2) + set(platform_0_name "iOS") + set(platform_0_variant "iphoneos") + set(platform_0_architectures "arm64") + set(platform_1_name "iOS") + set(platform_1_variant "iphonesimulator") + set(platform_1_architectures "x86_64") + elseif(NOT "${QT_APPLE_SDK}" STREQUAL "") + # Explicit SDK requested. + set(platform_0_variant "${QT_APPLE_SDK}") + endif() + endif() + + # Write platform information. At the moment, we write exactly one platform. With xcframeworks + # for example, we'd support multiple platforms. + math(EXPR last_platform_idx "${nr_of_platforms} - 1") + foreach(i RANGE 0 ${last_platform_idx}) + # Write target architecture information. + set(platform_name "${platform_${i}_name}") + set(platform_variant "${platform_${i}_variant}") + set(platform_architectures "${platform_${i}_architectures}") + set(targets_information "") + foreach(architecture IN LISTS platform_architectures) + if(NOT targets_information STREQUAL "") + string(APPEND targets_information ",") + endif() + string(APPEND targets_information "\n${indent4}{\n") + if(NOT QT_FEATURE_shared) + string(APPEND targets_information "${indent5}\"static\": true,\n") + endif() + if(ANDROID) + string(APPEND targets_information + "${indent5}\"api_version\": \"${QT_ANDROID_API_USED_FOR_JAVA}\", +${indent5}\"ndk_version\": \"${ANDROID_NDK_REVISION}\",\n") + endif() + string(APPEND targets_information "${indent5}\"architecture\": \"${architecture}\",\n") + string(APPEND targets_information "${indent5}\"abi\": \"${TEST_arch_${architecture}_abi}\"\n") + string(APPEND targets_information "${indent4}}") + endforeach() + + if(i GREATER 0) + string(APPEND platforms_information ",") + endif() + string(APPEND platforms_information " +${indent2}{ +${indent3}\"name\": \"${platform_name}\",") + if(NOT platform_variant STREQUAL "") + string(APPEND platforms_information " +${indent3}\"variant\": \"${platform_variant}\",") + endif() + if(NOT "${CMAKE_SYSTEM_VERSION}" STREQUAL "") + string(APPEND platforms_information " +${indent3}\"version\": \"${CMAKE_SYSTEM_VERSION}\",") + endif() + string(APPEND platforms_information " +${indent3}\"compiler_id\": \"${CMAKE_CXX_COMPILER_ID}\", +${indent3}\"compiler_version\": \"${CMAKE_CXX_COMPILER_VERSION}\", +${indent3}\"targets\": [${targets_information} +${indent3}] +${indent2}}") + endforeach() + + configure_file("${descfile_in}" "${descfile_out}") qt_install(FILES "${descfile_out}" DESTINATION "${install_dir}") endfunction()