Important: Please read the Qt Code of Conduct -

qmake question

  • I have the following .pro file

    QT -= gui
    TEMPLATE = lib
    CONFIG += c++11
    DEFINES += QT_DISABLE_DEPRECATED_BEFORE=0x060000    # disables all the APIs deprecated before Qt 6.0.0
    PROTOS += \
            protos/api.proto \

    with the follwing .pri file

    message("Generating protocol buffer classes from .proto files.") = protobuf headers
    protobuf_decl.input = PROTOS
    protobuf_decl.output = ${QMAKE_FILE_IN_PATH}/${QMAKE_FILE_BASE}.pb.h
    protobuf_decl.commands = protoc --cpp_out=${QMAKE_FILE_IN_PATH} --proto_path=${QMAKE_FILE_IN_PATH} ${QMAKE_FILE_NAME}
    protobuf_decl.variable_out = HEADERS
    QMAKE_EXTRA_COMPILERS += protobuf_decl = protobuf sources
    protobuf_impl.input = PROTOS
    protobuf_impl.output = ${QMAKE_FILE_IN_PATH}/${QMAKE_FILE_BASE}
    protobuf_impl.depends = ${QMAKE_FILE_IN_PATH}/${QMAKE_FILE_BASE}.pb.h
    protobuf_impl.commands = $$escape_expand(\n)
    protobuf_impl.variable_out = SOURCES
    QMAKE_EXTRA_COMPILERS += protobuf_impl

    Everything is working fine, but I would like to have the .pb.h and the files in a different directory (in ../). How can I achieve this?

  • Lifetime Qt Champion


    Modify the protobuf_decl.output, protobuf_impl.output and protobuf_impl.depends paths to point to where you want.

Log in to reply