From 1072a8f579ab9412d2f7deac3504088a707543b0 Mon Sep 17 00:00:00 2001 From: Leander Beernaert Date: Tue, 23 Jul 2019 09:13:47 +0200 Subject: [PATCH] Add missing QT_INSTALL_DIR paths to qml files and test data Make sure that paths passed to qt_copy_or_install are prefixed with QT_INSTALL_DIR so that they behave correctly with prefix and non-prefix builds. Make sure that plugin.qmltypes and qmldir are also copied to binary dir when doing prefix builds to match qmake's behavior. Change-Id: I6f87ed478e797c9f66dbf85264904ad29a60ad95 Reviewed-by: Alexandru Croitor Reviewed-by: Qt CMake Build Bot --- cmake/QtBuild.cmake | 27 ++++++++++++++++++++++----- 1 file changed, 22 insertions(+), 5 deletions(-) diff --git a/cmake/QtBuild.cmake b/cmake/QtBuild.cmake index e6384ceb5cd..05728d7e562 100644 --- a/cmake/QtBuild.cmake +++ b/cmake/QtBuild.cmake @@ -1831,19 +1831,35 @@ function(add_qml_module target) IMPORT_NAME "${arg_IMPORT_NAME}" QML_PLUGINDUMP_DEPENDENCIES "${arg_QML_PLUGINDUMP_DEPENDENCIES}") + qt_path_join(qml_module_install_dir ${QT_INSTALL_DIR} "${INSTALL_QMLDIR}/${target_path}") set(plugin_types "${CMAKE_CURRENT_SOURCE_DIR}/plugins.qmltypes") if (EXISTS ${plugin_types}) qt_copy_or_install(FILES ${plugin_types} - DESTINATION "${INSTALL_QMLDIR}/${target_path}" + DESTINATION "${qml_module_install_dir}" ) + + if(QT_WILL_INSTALL) + # plugin.qmltypes when present should also be copied to the + # cmake binary dir when doing prefix builds + file(COPY ${plugin_types} + DESTINATION "${QT_BUILD_DIR}/${INSTALL_QMLDIR}/${target_path}" + ) + endif() endif() qt_copy_or_install( FILES "${CMAKE_CURRENT_SOURCE_DIR}/qmldir" DESTINATION - "${INSTALL_QMLDIR}/${target_path}" + "${qml_module_install_dir}" ) + if(QT_WILL_INSTALL) + # qmldir should also be copied to the cmake binary dir when doing + # prefix builds + file(COPY "${CMAKE_CURRENT_SOURCE_DIR}/qmldir" + DESTINATION "${QT_BUILD_DIR}/${INSTALL_QMLDIR}/${target_path}" + ) + endif() if(NOT QT_BUILD_SHARED_LIBS) string(REPLACE "/" "." uri ${arg_TARGET_PATH}) @@ -1854,7 +1870,7 @@ function(add_qml_module target) else() if(arg_QML_FILES) qt_copy_or_install(FILES ${arg_QML_FILES} - DESTINATION "${INSTALL_QMLDIR}/${target_path}" + DESTINATION "${qml_module_install_dir}" ) endif() endif() @@ -1994,16 +2010,17 @@ function(add_qt_test name) endif() else() # Install test data + qt_path_join(testdata_install_dir ${QT_INSTALL_DIR} "${INSTALL_TESTDIR}/${name}") foreach(testdata IN LISTS arg_TESTDATA) set(testdata "${CMAKE_CURRENT_SOURCE_DIR}/${testdata}") if (IS_DIRECTORY "${testdata}") qt_copy_or_install( DIRECTORY "${testdata}" - DESTINATION "${INSTALL_TESTSDIR}/${name}") + DESTINATION "${testdata_install_dir}") else() qt_copy_or_install( FILES "${testdata}" - DESTINATION "${INSTALL_TESTSDIR}/${name}") + DESTINATION "${testdata_install_dir}") endif() endforeach() endif()