summaryrefslogtreecommitdiffstats
path: root/cmake/QtResourceHelpers.cmake
diff options
context:
space:
mode:
Diffstat (limited to 'cmake/QtResourceHelpers.cmake')
-rw-r--r--cmake/QtResourceHelpers.cmake52
1 files changed, 45 insertions, 7 deletions
diff --git a/cmake/QtResourceHelpers.cmake b/cmake/QtResourceHelpers.cmake
index ff4f234306..9715873d9c 100644
--- a/cmake/QtResourceHelpers.cmake
+++ b/cmake/QtResourceHelpers.cmake
@@ -19,26 +19,64 @@ function(qt_internal_add_resource target resourceName)
if (out_targets)
qt_install(TARGETS ${out_targets}
EXPORT "${INSTALL_CMAKE_NAMESPACE}${target}Targets"
- DESTINATION ${INSTALL_LIBDIR}
+ DESTINATION "${INSTALL_LIBDIR}"
)
- qt_internal_record_rcc_object_files("${target}" "${out_targets}")
+ qt_internal_record_rcc_object_files("${target}" "${out_targets}"
+ INSTALL_LOCATION "${INSTALL_LIBDIR}")
endif()
endfunction()
function(qt_internal_record_rcc_object_files target resource_targets)
+ set(args_optional "")
+ set(args_single INSTALL_LOCATION)
+ set(args_multi "")
+
+ cmake_parse_arguments(arg
+ "${args_optional}"
+ "${args_single}"
+ "${args_multi}"
+ ${ARGN}
+ )
+
foreach(out_target ${resource_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}")
+ # Compute the install location of a resource object file in a prefix build.
+ # It's comprised of thee following path parts:
+ #
+ # part (1) INSTALL_LOCATION.
+ # 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}")
qt_path_join(rcc_object_file_path
- "objects-$<CONFIG>" ${out_target} .rcc "${object_file_name}")
+ "objects-$<CONFIG>" ${out_target} "${object_file_name}")
+ if(arg_INSTALL_LOCATION)
+ qt_path_join(rcc_object_file_path
+ "${arg_INSTALL_LOCATION}" "${rcc_object_file_path}")
+ else()
+ message(FATAL_ERROR "No install location given for object files to be installed"
+ " for the following resource target: '${out_target}'")
+ endif()
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}>>)