2020-09-22 08:02:27 +00:00
|
|
|
function(qt_internal_add_resource target resourceName)
|
2020-08-13 15:37:47 +00:00
|
|
|
# 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})
|
|
|
|
|
2020-10-01 08:58:02 +00:00
|
|
|
_qt_internal_process_resource(${target} ${resourceName}
|
2020-08-13 15:37:47 +00:00
|
|
|
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"
|
2020-11-25 16:54:53 +00:00
|
|
|
DESTINATION "${INSTALL_LIBDIR}"
|
2020-08-13 15:37:47 +00:00
|
|
|
)
|
2021-05-20 11:38:30 +00:00
|
|
|
qt_internal_add_targets_to_additional_targets_export_file(
|
|
|
|
TARGETS ${out_targets}
|
|
|
|
EXPORT_NAME_PREFIX "${INSTALL_CMAKE_NAMESPACE}${target}"
|
|
|
|
)
|
2020-08-13 15:37:47 +00:00
|
|
|
|
2020-11-25 16:54:53 +00:00
|
|
|
qt_internal_record_rcc_object_files("${target}" "${out_targets}"
|
2021-03-01 06:24:16 +00:00
|
|
|
INSTALL_DIRECTORY "${INSTALL_LIBDIR}")
|
2020-08-13 15:37:47 +00:00
|
|
|
endif()
|
2020-11-17 16:43:48 +00:00
|
|
|
endfunction()
|
|
|
|
|
|
|
|
function(qt_internal_record_rcc_object_files target resource_targets)
|
2020-11-25 16:54:53 +00:00
|
|
|
set(args_optional "")
|
2021-03-01 06:24:16 +00:00
|
|
|
set(args_single INSTALL_DIRECTORY)
|
2020-11-25 16:54:53 +00:00
|
|
|
set(args_multi "")
|
|
|
|
|
|
|
|
cmake_parse_arguments(arg
|
|
|
|
"${args_optional}"
|
|
|
|
"${args_single}"
|
|
|
|
"${args_multi}"
|
|
|
|
${ARGN}
|
|
|
|
)
|
|
|
|
|
2020-11-17 16:43:48 +00:00
|
|
|
foreach(out_target ${resource_targets})
|
2020-11-17 16:51:42 +00:00
|
|
|
get_target_property(resource_name ${out_target} _qt_resource_name)
|
2020-11-17 16:43:48 +00:00
|
|
|
if(NOT resource_name)
|
|
|
|
continue()
|
|
|
|
endif()
|
|
|
|
if(QT_WILL_INSTALL)
|
2020-11-25 16:54:53 +00:00
|
|
|
# Compute the install location of a resource object file in a prefix build.
|
|
|
|
# It's comprised of thee following path parts:
|
|
|
|
#
|
2021-03-01 06:24:16 +00:00
|
|
|
# part (1) INSTALL_DIRECTORY.
|
2020-11-25 16:54:53 +00:00
|
|
|
# A usual value is '${INSTALL_LIBDIR}/' for libraries
|
|
|
|
# and '${INSTALL_QMLDIR}/foo/bar/' for qml plugin resources.
|
|
|
|
#
|
|
|
|
# part (2) the value computed by CMake's computeInstallObjectDir comprised of an
|
|
|
|
# objects-<CONFIG> dir and the target name of the object library.
|
|
|
|
# Example: objects-$<CONFIG>/Gui_resources_qpdf
|
|
|
|
#
|
|
|
|
# part (3) path to the object file, relative to it's build directory.
|
|
|
|
# Example: .rcc/qrc_qpdf.cpp.o
|
|
|
|
#
|
|
|
|
# The final path is relative to CMAKE_INSTALL_PREFIX aka $qt_install_prefix.
|
|
|
|
#
|
|
|
|
# The relative path will be transformed into an absolute path when generating .prl
|
|
|
|
# files, by prepending $$[QT_INSTALL_PREFIX]/.
|
|
|
|
get_target_property(generated_cpp_file_relative_path
|
|
|
|
${out_target}
|
|
|
|
_qt_resource_generated_cpp_relative_path)
|
|
|
|
|
|
|
|
set(object_file_name "${generated_cpp_file_relative_path}${CMAKE_CXX_OUTPUT_EXTENSION}")
|
2020-11-17 16:43:48 +00:00
|
|
|
qt_path_join(rcc_object_file_path
|
2020-11-25 16:54:53 +00:00
|
|
|
"objects-$<CONFIG>" ${out_target} "${object_file_name}")
|
2021-03-01 06:24:16 +00:00
|
|
|
if(arg_INSTALL_DIRECTORY)
|
2020-11-25 16:54:53 +00:00
|
|
|
qt_path_join(rcc_object_file_path
|
2021-03-01 06:24:16 +00:00
|
|
|
"${arg_INSTALL_DIRECTORY}" "${rcc_object_file_path}")
|
2020-11-25 16:54:53 +00:00
|
|
|
else()
|
|
|
|
message(FATAL_ERROR "No install location given for object files to be installed"
|
|
|
|
" for the following resource target: '${out_target}'")
|
|
|
|
endif()
|
2020-11-17 16:43:48 +00:00
|
|
|
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()
|
2020-11-17 16:51:42 +00:00
|
|
|
set_property(TARGET ${target} APPEND PROPERTY _qt_rcc_objects "${rcc_object_file_path}")
|
2020-08-13 15:37:47 +00:00
|
|
|
|
2021-07-15 11:41:15 +00:00
|
|
|
qt_internal_link_internal_platform_for_object_library("${out_target}")
|
2020-11-17 16:43:48 +00:00
|
|
|
endforeach()
|
2020-08-13 15:37:47 +00:00
|
|
|
endfunction()
|