summaryrefslogtreecommitdiffstats
path: root/cmake
diff options
context:
space:
mode:
authorJoerg Bornemann <joerg.bornemann@qt.io>2020-10-08 12:19:09 +0200
committerJoerg Bornemann <joerg.bornemann@qt.io>2020-10-09 07:28:10 +0200
commit13c4dfb274d1ebc8916bafac5a26eb5e1d001e93 (patch)
tree5b4e779f0a309d9ef9262be5ec916f81e91bf01c /cmake
parent92f0f99c23f981a551fde0d0242d414fac4dacbd (diff)
CMake: Fix tool targets for top-level cross-builds
When loading the tool packages from the host Qt we must ignore QT_NO_CREATE_TARGETS. Otherwise tool targets like Qt6::moc are not available. Task-number: QTBUG-85080 Change-Id: I2c8c8e68863f28a4f1d9cd2f70090455c49d8df2 Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io>
Diffstat (limited to 'cmake')
-rw-r--r--cmake/QtToolHelpers.cmake6
1 files changed, 6 insertions, 0 deletions
diff --git a/cmake/QtToolHelpers.cmake b/cmake/QtToolHelpers.cmake
index c6914e2d23..821b421241 100644
--- a/cmake/QtToolHelpers.cmake
+++ b/cmake/QtToolHelpers.cmake
@@ -42,6 +42,11 @@ function(qt_internal_add_tool target_name)
set(tools_package_name "Qt6${arg_TOOLS_TARGET}Tools")
message(STATUS "Searching for tool '${full_name}' in package ${tools_package_name}.")
+ # Create the tool targets, even if QT_NO_CREATE_TARGETS is set.
+ # Otherwise targets like Qt6::moc are not available in a top-level cross-build.
+ set(BACKUP_QT_NO_CREATE_TARGETS ${QT_NO_CREATE_TARGETS})
+ set(QT_NO_CREATE_TARGETS OFF)
+
# Only search in path provided by QT_HOST_PATH. We need to do it with CMAKE_PREFIX_PATH
# instead of PATHS option, because any find_dependency call inside a Tools package would
# not get the proper prefix when using PATHS.
@@ -64,6 +69,7 @@ function(qt_internal_add_tool target_name)
NO_CMAKE_SYSTEM_PACKAGE_REGISTRY)
set(CMAKE_FIND_ROOT_PATH_MODE_PACKAGE "${BACKUP_CMAKE_FIND_ROOT_PATH_MODE_PACKAGE}")
set(CMAKE_PREFIX_PATH "${BACKUP_CMAKE_PREFIX_PATH}")
+ set(QT_NO_CREATE_TARGETS ${BACKUP_QT_NO_CREATE_TARGETS})
if(${${tools_package_name}_FOUND} AND TARGET ${full_name})
# Even if the tool is already visible, make sure that our modules remain associated