qt5base-lts/cmake/QtResourceHelpers.cmake
Alexandru Croitor 44cce1a2ea CMake: Split QtBuild.cmake into smaller files
QtBuild.cmake is huge. Split it.

Move module, plugin, tools, executables and test related functions out
of QtBuild.cmake into separate files.
Do the same for many other things too.

An additional requirement is that all the new Helpers files only
define functions and macros.
No global variable definitions are allowed, nor execution of commands
with side effects.

Some notes:
qt_install_qml_files is removed because it's dead code.

Some functions still need to be figured out, because they are
interspersed and depend on various global state assignments.

Task-number: QTBUG-86035
Change-Id: I21d79ff02eef923c202eb1000422888727cb0e2c
Reviewed-by: Joerg Bornemann <joerg.bornemann@qt.io>
2020-08-14 13:17:11 +02:00

49 lines
2.0 KiB
CMake

function(qt_add_resource target resourceName)
# Don't try to add resources when cross compiling, and the target is actually a host target
# (like a tool).
qt_is_imported_target("${target}" is_imported)
if(is_imported)
return()
endif()
qt_parse_all_arguments(arg "qt_add_resource" "" "PREFIX;LANG;BASE" "FILES" ${ARGN})
QT6_PROCESS_RESOURCE(${target} ${resourceName}
PREFIX "${arg_PREFIX}"
LANG "${arg_LANG}"
BASE "${arg_BASE}"
FILES ${arg_FILES}
OUTPUT_TARGETS out_targets
)
if (out_targets)
qt_install(TARGETS ${out_targets}
EXPORT "${INSTALL_CMAKE_NAMESPACE}${target}Targets"
DESTINATION ${INSTALL_LIBDIR}
)
foreach(out_target ${out_targets})
get_target_property(resource_name ${out_target} QT_RESOURCE_NAME)
if(NOT resource_name)
continue()
endif()
if(QT_WILL_INSTALL)
# Compute the install location of the rcc object file.
# This is the relative path below the install destination (install_prefix/lib).
# See CMake's computeInstallObjectDir function.
set(object_file_name "qrc_${resource_name}.cpp${CMAKE_CXX_OUTPUT_EXTENSION}")
qt_path_join(rcc_object_file_path
"objects-$<CONFIG>" ${out_target} .rcc "${object_file_name}")
else()
# In a non-prefix build we use the object file paths right away.
set(rcc_object_file_path $<TARGET_OBJECTS:$<TARGET_NAME:${out_target}>>)
endif()
set_property(TARGET ${target} APPEND PROPERTY QT_RCC_OBJECTS "${rcc_object_file_path}")
# Make sure that the target cpp files are compiled with the regular Qt internal compile
# flags, needed for building iOS apps with qmake where bitcode is involved.
target_link_libraries("${out_target}" PRIVATE Qt::PlatformModuleInternal)
endforeach()
endif()
endfunction()