\badcode
cmake_minimum_required(VERSION 3.16...3.22)
project(MyThings)

find_package(Qt6 REQUIRED COMPONENTS Quick)
qt_standard_project_setup()

qt_add_executable(MyApp main.cpp)
qt_add_qml_module(MyApp
    URI myapp
    QML_FILES main.qml
)

set(deploy_script "${CMAKE_CURRENT_BINARY_DIR}/deploy_MyApp.cmake")
file(GENERATE OUTPUT ${deploy_script} CONTENT "

set(QT_DEPLOY_QML_DIR \"myqmldir\")

include(\"${QT_DEPLOY_SUPPORT}\")

qt_deploy_qml_imports(
    TARGET MyApp
    PLUGINS_FOUND plugins_found
)
qt_deploy_runtime_dependencies(
    EXECUTABLE \"\${QT_DEPLOY_BIN_DIR}/$<TARGET_FILE_NAME:MyApp>\"
    ADDITIONAL_MODULES \${plugins_found}
)")

install(SCRIPT ${deploy_script})
\endcode
