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. Fixes: QTBUG-103497 Change-Id: I91152247651ecd35e8110b8874399cb1b8b394bd Reviewed-by: Alexey Edelev <alexey.edelev@qt.io> (cherry picked from commit 91fd8bdb116f461eec67bf8b17d41011039a63d9) Reviewed-by: Qt Cherry-pick Bot <cherrypick_bot@qt-project.org>
This commit is contained in:
parent
0d60b9d0af
commit
2fb89b330b
@ -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()
|
||||
|
@ -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.
|
||||
|
Loading…
x
Reference in New Issue
Block a user