summaryrefslogtreecommitdiffstats
path: root/cmake/QtResource.cmake.in
diff options
context:
space:
mode:
authorAlexandru Croitor <alexandru.croitor@qt.io>2019-08-30 15:06:34 +0200
committerAlexandru Croitor <alexandru.croitor@qt.io>2019-08-30 19:02:52 +0000
commit659d8cf3e5d906d41af6a36d95618de726a9b248 (patch)
tree099788ca2149925103c3b495f1a952d201ddbdee /cmake/QtResource.cmake.in
parent2e3e42587b821a15a5b0d50025f18a5b82727452 (diff)
Fix add_qt_resource to handle resources in static builds properly
Whenever the qml compiler is used to process qml files from a resource, and there are no resources left after all qml files have been processed, make sure to propagate the created resource target to add_qt_resource, so that the target is associated properly with an export name. Additionally the generated qml cache loader file uses private Qml headers. Thus the object library that contains the cpp file should have qml as a dependency (and not the target that will link to the object library). Change-Id: Ib385a900823df3e015492cdd06acd8a0cb9f8e9a Reviewed-by: Leander Beernaert <leander.beernaert@qt.io> Reviewed-by: Qt CMake Build Bot Reviewed-by: Simon Hausmann <simon.hausmann@qt.io>
Diffstat (limited to 'cmake/QtResource.cmake.in')
-rw-r--r--cmake/QtResource.cmake.in16
1 files changed, 14 insertions, 2 deletions
diff --git a/cmake/QtResource.cmake.in b/cmake/QtResource.cmake.in
index 88a642a331..8474183882 100644
--- a/cmake/QtResource.cmake.in
+++ b/cmake/QtResource.cmake.in
@@ -30,7 +30,7 @@ endfunction()
# Inspect all files passed to a call to add_qt_resource. If there are any
# files present, invoke the quick compiler and return the remaining resource
-# files that have not been prossed in REMAING_RESOURCES as well as the new
+# files that have not been processed in OUTPUT_REMAINING_RESOURCES as well as the new
# name for the resource in OUTPUT_RESOURCE_NAME.
function(__qt_quick_compiler_process_resources target resource_name)
@@ -150,7 +150,16 @@ function(__qt_quick_compiler_process_resources target resource_name)
if (resource_files)
set(resource_name ${chained_resource_name})
endif()
- target_link_libraries(${target} PRIVATE @QT_CMAKE_EXPORT_NAMESPACE@::Qml)
+
+ # The generated qmlcache_loader source file uses private headers of Qml, so make sure
+ # if the object library was created, it depends on the Qml target. If there's no target,
+ # that means the target is a shared library and the sources are directly added to the target
+ # via target_sources, so add dependency in that case as well.
+ set(chosen_target "target") # shared library case
+ if(output_target)
+ set(chosen_target "output_target") # static library case.
+ endif()
+ target_link_libraries(${${chosen_target}} PRIVATE @QT_CMAKE_EXPORT_NAMESPACE@::Qml)
else()
set(resource_files ${arg_FILES})
endif()
@@ -216,6 +225,9 @@ function(QT@PROJECT_VERSION_MAJOR@_PROCESS_RESOURCE target resourceName)
)
if (NOT resources)
+ if (rcc_OUTPUT_TARGET)
+ set(${rcc_OUTPUT_TARGET} "${output_target}" PARENT_SCOPE)
+ endif()
return()
endif()
set(generatedResourceFile "${CMAKE_CURRENT_BINARY_DIR}/generated_${newResourceName}.qrc")