Какие замечания по улучшению этого cmake скрипта ты можешь сделать:
# static builds: link qml import plugins into the target.
function(add_qml_static_imports target qml_DIRS)

    get_filename_component(targetName ${target} NAME)
    set(_qml_imports_file ${CMAKE_CURRENT_BINARY_DIR}/${target}_qml_plugin_import.cpp)

    set(bin_DIRS ${QT_INSTALL_PREFIX}/bin)
    if (DEFINED QT_HOST_PATH)
        list(APPEND bin_DIRS "${QT_HOST_PATH}/bin" "${QT_HOST_PATH}/libexec")
    endif()
    find_program(QMLIMPORTSCANNER_COMMAND qmlimportscanner PATHS ${bin_DIRS} 
        DOC "The Qt qmlimportscanner executable"
        NO_DEFAULT_PATH CMAKE_FIND_ROOT_PATH_BOTH)

    list(LENGTH qml_DIRS qml_DIRS_LENGTH)

    if (QMLIMPORTSCANNER_COMMAND AND qml_DIRS_LENGTH GREATER 0)

        set(_qml_imports)
        set(_link_directories)
        set(_link_libraries)

        foreach (_gml_SOURCE_DIR ${qml_DIRS})

            set(QMLIMPORTSCANNER_ARGS "${_gml_SOURCE_DIR}" -importPath "${QT_INSTALL_PREFIX}/qml")
            execute_process(
                COMMAND "${QMLIMPORTSCANNER_COMMAND}" ${QMLIMPORTSCANNER_ARGS}
                WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}
                OUTPUT_VARIABLE _imports
            )

            string(REGEX REPLACE "[\r\n \[{]" "" _imports "${_imports}")
            string(REGEX REPLACE "}," ";" _imports "${_imports}")
            string(REGEX REPLACE "[}\]]" ";" _imports "${_imports}")

            foreach(_line ${_imports})
                if(${_line} MATCHES "plugin" AND ${_line} MATCHES "path" AND ${_line} MATCHES "classname")
                    string(REGEX MATCH "\"[ ]*path[ ]*\"[ ]*:[ ]*\"[^,]*[ ]*\"" _path ${_line})
                    string(REGEX REPLACE "^\"[ ]*path[ ]*\"[ ]*:" "" _path "${_path}")
                    if (_path)
                        list(APPEND _link_directories "${CMAKE_LIBRARY_PATH_FLAG}${_path}")
                    endif()

                    string(REGEX MATCH "\"[ ]*plugin[ ]*\"[ ]*:[ ]*\"[^,]*[ ]*\"" _plugin ${_line})
                    string(REGEX REPLACE "^\"[ ]*plugin[ ]*\"[ ]*:" "" _plugin "${_plugin}")
                    string(REGEX REPLACE "\"" "" _plugin "${_plugin}")

                    if (_plugin)
                        if (IOS)
                            list(APPEND _link_libraries ${_plugin}$<$<CONFIG:Debug>:_debug>)
                        elseif (WIN32)
                            list(APPEND _link_libraries ${_plugin}$<$<CONFIG:Debug>:d>)
                        else ()
                            list(APPEND _link_libraries ${_plugin})
                        endif ()
                    endif()

                    string(REGEX MATCH "\"[ ]*classname[ ]*\"[ ]*:[ ]*\"[^,]*[ ]*\"" _classname ${_line})
                    string(REGEX REPLACE "^\"[ ]*classname[ ]*\"[ ]*:" "" _classname "${_classname}")
                    string(REGEX REPLACE "\"" "" _classname "${_classname}")

                    if (_classname)
                        list(APPEND _qml_imports "Q_IMPORT_PLUGIN(${_classname})")
                    endif()
                endif ()
            endforeach()
        endforeach()

        list(REMOVE_DUPLICATES _link_directories)
        list(REMOVE_DUPLICATES _link_libraries)
        list(REMOVE_DUPLICATES _qml_imports)

        target_link_libraries(${target} PRIVATE ${_link_directories} ${_link_libraries})

        set(_import_header "// This file is autogenerated by cmake toolchain."
            " //It imports static plugin classes for plugins used by QML imports."
            "#include <QtPlugin>")

        string(REPLACE ";" "\n" _import_header "${_import_header}")
        string(REPLACE ";" "\n" _qml_imports "${_qml_imports}")

        file(GENERATE OUTPUT "${_qml_imports_file}" CONTENT "${_import_header}\n${_qml_imports}\n")
        set_source_files_properties(${_qml_imports_file} PROPERTIES GENERATED 1  SKIP_AUTOMOC ON)
        get_property(_sources TARGET ${target} PROPERTY SOURCES)
        list(APPEND _sources ${_qml_imports_file})
        set_target_properties(${target} PROPERTIES SOURCES "${_sources}")

    endif()

endfunction(add_qml_static_imports)