QT.protobuf.VERSION = @QT_PROTOBUF_VERSION@
QT.protobuf.name = Qt@target@
QT.protobuf.module = @QT_PROTOBUF_LIBRARY_OUTPUT_NAME@
QT.protobuf.includes = @CMAKE_INSTALL_PREFIX@/@CMAKE_INSTALL_INCLUDEDIR@/@QT_PROTOBUF_NAMESPACE@@target@
QT.protobuf.private_includes =
QT.protobuf.libs = @CMAKE_INSTALL_PREFIX@/@CMAKE_INSTALL_LIBDIR@
QT.protobuf.depends = core qml
QT.protobuf.module_config = @QT_PROTOBUF_EXTRA_CONFIG@

CONFIG += c++17
DEFINES += @QT_PROTOBUF_EXTRA_COMPILE_DIFINITIONS@

defineTest(qt6_protobuf_generate) {
    OK = false

    QML_ENABLED = $$1
    $$QML_ENABLED:GENERATOR_OPTIONS="$$GENERATOR_OPTIONS:QML"

    for (PROTO_FILE_REL, PROTO_FILES) {
        PROTO_FILE_ABS = $$absolute_path($$PROTO_FILE_REL)
        PROTO_FILES_PRIV *= $$PROTO_FILE_ABS
        PROTO_INCLUDES_PRIV = "$$PROTO_INCLUDES_PRIV -I$$dirname(PROTO_FILE_ABS)"
    }

    GENERATED_OUT_DIR = $$OUT_PWD/generated
    system("mkdir $$GENERATED_OUT_DIR")
    protoc_command_line = "QT_PROTOBUF_OPTIONS=$$GENERATOR_OPTIONS protoc --plugin=protoc-gen-qtprotobufgen=@CMAKE_INSTALL_PREFIX@/@CMAKE_INSTALL_BINDIR@/qtprotobufgen --qtprotobufgen_out=$$GENERATED_OUT_DIR $$PROTO_INCLUDES_PRIV $$PROTO_FILES_PRIV"
    message("$$protoc_command_line")
    system("$$protoc_command_line"):OK=true
    SOURCES += $$files($$GENERATED_OUT_DIR/*.cpp)
    HEADERS += $$files($$GENERATED_OUT_DIR/*.h)
    INCLUDEPATH += $$GENERATED_OUT_DIR

    export(SOURCES)
    export(HEADERS)
    export(INCLUDEPATH)

    return($$OK)
}
