From a0e56294c1e80f34147c5a992b314776e1b6c757 Mon Sep 17 00:00:00 2001 From: Joerg Bornemann Date: Tue, 14 Sep 2021 21:02:14 +0200 Subject: Skip unnecessary commands when cross-building tools Introduce a new macro qt_internal_return_unless_building_tools which simply calls return() if tools are not built. This macro is supposed to be called after qt_internal_add_tool(). Using this macro avoids having to special-case code for when qt_internal_add_tool() creates imported targets in cross-builds. Adjust pro2cmake accordingly. Task-number: QTBUG-85084 Change-Id: I9e1c455c29535dd8c318efa890ebd739c42effc1 Reviewed-by: Alexandru Croitor --- cmake/QtToolHelpers.cmake | 8 ++++++++ 1 file changed, 8 insertions(+) (limited to 'cmake') diff --git a/cmake/QtToolHelpers.cmake b/cmake/QtToolHelpers.cmake index 77dae50027..f28b2d27a4 100644 --- a/cmake/QtToolHelpers.cmake +++ b/cmake/QtToolHelpers.cmake @@ -441,6 +441,14 @@ function(qt_check_if_tools_will_be_built) set(QT_WILL_BUILD_TOOLS ${will_build_tools} CACHE INTERNAL "Are tools going to be built" FORCE) endfunction() +# Use this macro to exit a file or function scope unless we're building tools. This is supposed to +# be called after qt_internal_add_tools() to avoid special-casing operations on imported targets. +macro(qt_internal_return_unless_building_tools) + if(NOT QT_WILL_BUILD_TOOLS) + return() + endif() +endmacro() + # Equivalent of qmake's qtNomakeTools(directory1 directory2). # If QT_BUILD_TOOLS_BY_DEFAULT is true, then targets within the given directories will be excluded # from the default 'all' target, as well as from install phase. The private variable is checked by -- cgit v1.2.3