summaryrefslogtreecommitdiffstats
path: root/cmake
diff options
context:
space:
mode:
authorJoerg Bornemann <joerg.bornemann@qt.io>2020-10-15 17:11:16 +0200
committerJoerg Bornemann <joerg.bornemann@qt.io>2020-10-20 20:59:21 +0200
commit80a2878e201f294697d69b7606571a036c36a19d (patch)
tree76ff83df8567975cf5cc9ef6a1f8dd78d4e890a4 /cmake
parentf1af51fd81dbdf3ada208398c517c76bab9a9489 (diff)
CMake: Fix additional target info files
...for QT_BUILD_TOOLS_WHEN_CROSSCOMPILING. qt_internal_export_additional_targets_file now gets two lists of target names when run from qt_export_tools: - TARGETS containing actually existing targets, and - TARGET_EXPORT_NAMES containing the target names as they appear in the additional target info file. Operations that require actual targets are run on the TARGETS, in the additional target info file only TARGET_EXPORT_NAMES are written. This distinction is required for the case where the host Qt lacks a tool that is built in the target Qt. Example: host Qt is built with DEVELOPER_BUILD=OFF, target Qt is built with DEVELOPER_BUILD=ON. Then the host Qt lacks qmljs, but it is built in the target Qt. TARGETS contains qmljs_native, and TARGET_EXPORT_NAMES contains qmljs. Fixes: QTBUG-87693 Change-Id: I615aed996bfcbe654274defcda8c1cb2cc4b7b4e Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io> Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
Diffstat (limited to 'cmake')
-rw-r--r--cmake/QtTargetHelpers.cmake41
-rw-r--r--cmake/QtToolHelpers.cmake3
2 files changed, 40 insertions, 4 deletions
diff --git a/cmake/QtTargetHelpers.cmake b/cmake/QtTargetHelpers.cmake
index bbcd768495..fcbb3ab1f2 100644
--- a/cmake/QtTargetHelpers.cmake
+++ b/cmake/QtTargetHelpers.cmake
@@ -313,8 +313,40 @@ function(qt_internal_strip_target_directory_scope_token target out_var)
set("${out_var}" "${target}" PARENT_SCOPE)
endfunction()
+# Create a Qt*AdditionalTargetInfo.cmake file that is included by Qt*Config.cmake
+# and sets IMPORTED_*_<CONFIG> properties on the exported targets.
+#
+# EXPORT_NAME_PREFIX:
+# The portion of the file name before AdditionalTargetInfo.cmake
+# CONFIG_INSTALL_DIR:
+# Installation location for the target info file
+# TARGETS:
+# The internal target names. Those must be actual targets.
+# TARGET_EXPORT_NAMES:
+# The target names how they appear in the QtXXXTargets.cmake files.
+# The names get prefixed by ${QT_CMAKE_EXPORT_NAMESPACE}:: unless they already are.
+# This argument may be empty, then the target export names are the same as the internal ones.
+#
+# TARGETS and TARGET_EXPORT_NAMES must contain exactly the same number of elements.
+# Example: TARGETS = qmljs_native
+# TARGET_EXPORT_NAMES = Qt6::qmljs
+#
function(qt_internal_export_additional_targets_file)
- cmake_parse_arguments(arg "" "EXPORT_NAME_PREFIX;CONFIG_INSTALL_DIR" "TARGETS" ${ARGN})
+ cmake_parse_arguments(arg "" "EXPORT_NAME_PREFIX;CONFIG_INSTALL_DIR"
+ "TARGETS;TARGET_EXPORT_NAMES" ${ARGN})
+
+ list(LENGTH arg_TARGETS num_TARGETS)
+ list(LENGTH arg_TARGET_EXPORT_NAMES num_TARGET_EXPORT_NAMES)
+ if(num_TARGET_EXPORT_NAMES GREATER 0)
+ if(NOT num_TARGETS EQUAL num_TARGET_EXPORT_NAMES)
+ message(FATAL_ERROR "qt_internal_export_additional_targets_file: "
+ "TARGET_EXPORT_NAMES is set but has ${num_TARGET_EXPORT_NAMES} elements while "
+ "TARGETS has ${num_TARGETS} elements. "
+ "They must contain the same number of elements.")
+ endif()
+ else()
+ set(arg_TARGET_EXPORT_NAMES ${arg_TARGETS})
+ endif()
# Determine the release configurations we're currently building
if(QT_GENERATOR_IS_MULTI_CONFIG)
@@ -354,12 +386,15 @@ if(NOT DEFINED QT_DEFAULT_IMPORT_CONFIGURATION)
set(QT_DEFAULT_IMPORT_CONFIGURATION ${uc_default_cfg})
endif()
")
- foreach(target ${arg_TARGETS})
+ math(EXPR n "${num_TARGETS} - 1")
+ foreach(i RANGE ${n})
+ list(GET arg_TARGETS ${i} target)
+ list(GET arg_TARGET_EXPORT_NAMES ${i} target_export_name)
get_target_property(target_type ${target} TYPE)
if(target_type STREQUAL "INTERFACE_LIBRARY")
continue()
endif()
- set(full_target ${target})
+ set(full_target ${target_export_name})
if(NOT full_target MATCHES "^${QT_CMAKE_EXPORT_NAMESPACE}::")
string(PREPEND full_target "${QT_CMAKE_EXPORT_NAMESPACE}::")
endif()
diff --git a/cmake/QtToolHelpers.cmake b/cmake/QtToolHelpers.cmake
index 821b421241..106dc8720d 100644
--- a/cmake/QtToolHelpers.cmake
+++ b/cmake/QtToolHelpers.cmake
@@ -310,7 +310,8 @@ endif()
DESTINATION "${config_install_dir}")
qt_internal_export_additional_targets_file(
- TARGETS ${tool_targets}
+ TARGETS ${QT_KNOWN_MODULE_${module_name}_TOOLS}
+ TARGET_EXPORT_NAMES ${tool_targets}
EXPORT_NAME_PREFIX ${INSTALL_CMAKE_NAMESPACE}${target}
CONFIG_INSTALL_DIR "${config_install_dir}")