diff --git a/cmake/ModuleDescription.json.in b/cmake/ModuleDescription.json.in new file mode 100644 index 0000000000..e29f3f176d --- /dev/null +++ b/cmake/ModuleDescription.json.in @@ -0,0 +1,11 @@ +{ + "module_name": "${target}", + "version": "${CMAKE_PROJECT_VERSION}", + "built_with": { + "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}" + } +} diff --git a/cmake/QtBaseGlobalTargets.cmake b/cmake/QtBaseGlobalTargets.cmake index df3ceb88c0..691c56dfdb 100644 --- a/cmake/QtBaseGlobalTargets.cmake +++ b/cmake/QtBaseGlobalTargets.cmake @@ -174,6 +174,7 @@ qt_internal_export_modern_cmake_config_targets_file(TARGETS ${__export_targets} ## Install some QtBase specific CMake files: qt_copy_or_install(FILES + cmake/ModuleDescription.json.in cmake/QtBuild.cmake cmake/QtCompilerFlags.cmake cmake/QtCompilerOptimization.cmake diff --git a/cmake/QtBuild.cmake b/cmake/QtBuild.cmake index 3b9e912edb..1e00677cbe 100644 --- a/cmake/QtBuild.cmake +++ b/cmake/QtBuild.cmake @@ -35,6 +35,7 @@ set(INSTALL_SYSCONFDIR "etc/xdg" CACHE PATH "Settings used by Qt programs [PREFIX/etc/xdg]") set(INSTALL_EXAMPLESDIR "examples" CACHE PATH "Examples [PREFIX/examples]") set(INSTALL_TESTSDIR "tests" CACHE PATH "Tests [PREFIX/tests]") +set(INSTALL_DESCRIPTIONSDIR "${INSTALL_DATADIR}/modules" CACHE PATH "Module description files directory") # The variables might have already been set in QtBuildInternalsExtra.cmake if the file is included # while building a new module and not QtBase. In that case, stop overriding the value. @@ -63,6 +64,23 @@ SET(CMAKE_INSTALL_RPATH "${_default_install_rpath}" CACHE PATH "RPATH for instal # which point to directories outside the build tree to the install RPATH SET(CMAKE_INSTALL_RPATH_USE_LINK_PATH TRUE) +# Generate a module description file based on the template in ModuleDescription.json.in +function(qt_describe_module target) + set(path_suffix "${INSTALL_DESCRIPTIONSDIR}") + qt_path_join(build_dir ${QT_BUILD_DIR} ${path_suffix}) + qt_path_join(install_dir ${QT_INSTALL_DIR} ${path_suffix}) + + set(descfile_in "${QT_CMAKE_DIR}/ModuleDescription.json.in") + set(descfile_out "${build_dir}/${target}.json") + set(cross_compilation "false") + if(CMAKE_CROSSCOMPILE) + set(cross_compilation "true") + endif() + configure_file("${descfile_in}" "${descfile_out}") + + qt_install(FILES "${descfile_out}" DESTINATION "${install_dir}") +endfunction() + function(qt_setup_tool_path_command) if(NOT WIN32) return() @@ -1632,6 +1650,8 @@ set(QT_CMAKE_EXPORT_NAMESPACE ${QT_CMAKE_EXPORT_NAMESPACE})") if(NOT ${arg_NO_PRIVATE_MODULE}) target_include_directories("${target_private}" INTERFACE ${interface_includes}) endif() + + qt_describe_module(${target}) endfunction() function(qt_export_tools module_name)