diff options
author | Alexandru Croitor <alexandru.croitor@qt.io> | 2022-06-20 11:36:04 +0200 |
---|---|---|
committer | Alexandru Croitor <alexandru.croitor@qt.io> | 2022-06-20 20:56:59 +0200 |
commit | 91fd8bdb116f461eec67bf8b17d41011039a63d9 (patch) | |
tree | 9bb5ade92dfe887f40dea7503d05a3a215af6de2 /src | |
parent | 2e12479e06d6869f568f0a7ee939453cda9afdbf (diff) |
CMake: Warn when using qt6_add_big_resources on iOS
qt6_add_big_resources works by calling rcc to generate a resource
.cpp file, compiling it into an object file, then passing the
compiled object file to rcc again for further manipulation.
The path to the object file is passed to rcc using the
$<TARGET_OBJECTS> generator expression.
This generator expression does not work when used in
add_custom_command / file(GENERATE) when targeting iOS, because
CMake claims it does not know where the object file will be on-disk
(presumably because the location is controlled by Xcode itself and it
can vary based on the active architecture and sysroot).
The following error is shown at generation time:
Error evaluating generator expression:
$<TARGET_OBJECTS:rcc_object_foo>
The evaluation of the TARGET_OBJECTS generator expression is only
suitable for consumption by CMake (limited under Xcode with multiple
architectures). It is not suitable for writing out elsewhere.
More details about the issue can be found at
https://gitlab.kitware.com/cmake/cmake/-/issues/20516
Trying to work around the issue by manually invoking the compiler
instead of using a genex so we know the location of the object file
hits similar issues in that we don't know the active arch and sysroot
for which to compile the object file.
Until the CMake limitation is lifted or we find a different fix, warn
that qt6_add_big_resources can't be used when targeting iOS and
fall back to using qt6_add_resources instead.
Note that qmake CONFIG+=big_resources also falls back to non-big
resources mode when targeting Xcode (mac-xcode) and doesn't even show
a warning.
Another note is that using CMake + Xcode + qt6_add_big_resources does
work when targeting macOS, although it generates some warnings
warning same member name (qrc_assets.o) in output file used for input
files: qrc_assets.o qrc_assets.o
(due to use of basename, truncation, blank padding or duplicate input
files)
So there is some hope this could be fixed for iOS in the future.
Pick-to: 6.2 6.3 6.4
Fixes: QTBUG-103497
Change-Id: I91152247651ecd35e8110b8874399cb1b8b394bd
Reviewed-by: Alexey Edelev <alexey.edelev@qt.io>
Diffstat (limited to 'src')
-rw-r--r-- | src/corelib/Qt6CoreMacros.cmake | 12 | ||||
-rw-r--r-- | src/corelib/doc/src/cmake/qt_add_big_resources.qdoc | 4 |
2 files changed, 16 insertions, 0 deletions
diff --git a/src/corelib/Qt6CoreMacros.cmake b/src/corelib/Qt6CoreMacros.cmake index 620d893abd..e58ebd5d2b 100644 --- a/src/corelib/Qt6CoreMacros.cmake +++ b/src/corelib/Qt6CoreMacros.cmake @@ -410,6 +410,18 @@ endif() # qt6_add_big_resources(outfiles inputfile ... ) function(qt6_add_big_resources outfiles ) + if(CMAKE_GENERATOR STREQUAL "Xcode" AND IOS) + message(WARNING + "Due to CMake limitations, qt6_add_big_resources can't be used when building for iOS. " + "See https://bugreports.qt.io/browse/QTBUG-103497 for details. " + "Falling back to using qt6_add_resources. " + "Consider using qt6_add_resources directly to silence this warning." + ) + qt6_add_resources(${ARGV}) + set(${outfiles} ${${outfiles}} PARENT_SCOPE) + return() + endif() + if (CMAKE_VERSION VERSION_LESS 3.9) message(FATAL_ERROR, "qt6_add_big_resources requires CMake 3.9 or newer") endif() diff --git a/src/corelib/doc/src/cmake/qt_add_big_resources.qdoc b/src/corelib/doc/src/cmake/qt_add_big_resources.qdoc index 8cb78cf9c1..5ae7b9728b 100644 --- a/src/corelib/doc/src/cmake/qt_add_big_resources.qdoc +++ b/src/corelib/doc/src/cmake/qt_add_big_resources.qdoc @@ -38,6 +38,10 @@ to binaries would be too time consuming or memory intensive. needs to be added as a source file to a CMake target and have the property \c{SKIP_AUTORCC} set to \c{ON}. +\warning This command is not supported when building for iOS, use +\l qt_add_resources instead. +See \l{https://bugreports.qt.io/browse/QTBUG-103497}{QTBUG-103497} for details. + \section1 Arguments You can set additional \c{OPTIONS} that should be added to the \c{rcc} calls. |