CMake: Create Qt6HostInfo package

This package is supposed to be loaded when cross-building Qt from the
host Qt installation prefix. It provides information about the host Qt
by setting various variables. The information reflects what "qmake
-query" of the host Qt would return.

All provided variable names begin with "QT6_HOST_INFO_".

Change-Id: Id568923a318d6e3b48c450663519a3727f615a8f
Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io>
This commit is contained in:
Joerg Bornemann 2020-06-23 15:12:27 +02:00
parent 040a7cfa93
commit a4f11fa99d
2 changed files with 34 additions and 0 deletions

View File

@ -0,0 +1,18 @@
@PACKAGE_INIT@
set(@var_prefix@BINDIR "@INSTALL_BINDIR@")
set(@var_prefix@INCLUDEDIR "@INSTALL_INCLUDEDIR@")
set(@var_prefix@LIBDIR "@INSTALL_LIBDIR@")
set(@var_prefix@MKSPECSDIR "@INSTALL_MKSPECSDIR@")
set(@var_prefix@ARCHDATADIR "@INSTALL_ARCHDATADIR@")
set(@var_prefix@PLUGINSDIR "@INSTALL_PLUGINSDIR@")
set(@var_prefix@LIBEXECDIR "@INSTALL_LIBEXECDIR@")
set(@var_prefix@QMLDIR "@INSTALL_QMLDIR@")
set(@var_prefix@DATADIR "@INSTALL_DATADIR@")
set(@var_prefix@DOCDIR "@INSTALL_DOCDIR@")
set(@var_prefix@TRANSLATIONSDIR "@INSTALL_TRANSLATIONSDIR@")
set(@var_prefix@SYSCONFDIR "@INSTALL_SYSCONFDIR@")
set(@var_prefix@EXAMPLESDIR "@INSTALL_EXAMPLESDIR@")
set(@var_prefix@TESTSDIR "@INSTALL_TESTSDIR@")
set(@var_prefix@DESCRIPTIONSDIR "@INSTALL_DESCRIPTIONSDIR@")
set(@var_prefix@QMAKE_MKSPEC "@QT_QMAKE_TARGET_MKSPEC@")

View File

@ -335,8 +335,24 @@ function(qt_wrap_string_in_if_ninja_multi_config content out_var)
${content}endif()\n" PARENT_SCOPE)
endfunction()
function(qt_create_hostinfo_package)
set(package "${INSTALL_CMAKE_NAMESPACE}HostInfo")
qt_path_join(config_file_path "${QT_CONFIG_BUILD_DIR}/${package}/${package}Config.cmake")
qt_path_join(install_destination ${QT_CONFIG_INSTALL_DIR} ${package})
set(var_prefix "QT${PROJECT_VERSION_MAJOR}_HOST_INFO_")
configure_package_config_file(
"${CMAKE_CURRENT_LIST_DIR}/QtHostInfoConfig.cmake.in"
"${config_file_path}"
INSTALL_DESTINATION "${install_destination}"
NO_SET_AND_CHECK_MACRO
NO_CHECK_REQUIRED_COMPONENTS_MACRO)
qt_install(FILES "${config_file_path}" DESTINATION "${install_destination}")
endfunction()
function(qt_generate_build_internals_extra_cmake_code)
if(PROJECT_NAME STREQUAL "QtBase")
qt_create_hostinfo_package()
foreach(var IN LISTS QT_BASE_CONFIGURE_TESTS_VARS_TO_EXPORT)
string(APPEND QT_EXTRA_BUILD_INTERNALS_VARS "set(${var} \"${${var}}\" CACHE INTERNAL \"\")\n")
endforeach()