Important: Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

qmake question



  • I have the following .pro file

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

    with the follwing .pri file

    message("Generating protocol buffer classes from .proto files.")
    
    protobuf_decl.name = 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_impl.name = protobuf sources
    protobuf_impl.input = PROTOS
    protobuf_impl.output = ${QMAKE_FILE_IN_PATH}/${QMAKE_FILE_BASE}.pb.cc
    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 .pb.cc files in a different directory (in ../). How can I achieve this?


  • Lifetime Qt Champion

    Hi,

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


Log in to reply