Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. General and Desktop
  4. How qmake extra compilers work?
QtWS25 Last Chance

How qmake extra compilers work?

Scheduled Pinned Locked Moved General and Desktop
2 Posts 2 Posters 2.2k Views
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • N Offline
    N Offline
    nikitablack
    wrote on last edited by
    #1

    Greetings.

    I'm trying to use protobuf compiler, but I can't fully understand how it work. As example I took a code from here "Example of adding protobuf build as a part of .pro file":http://qt-project.org/doc/note_revisions/423/693/view. I'll put slightly modified code here:
    @protobuf_decl.name = protobuf header
    protobuf_decl.input = PROTOS
    protobuf_decl.output = ${QMAKE_FILE_BASE}.pb.h
    protobuf_decl.commands = $$PWD/../Protobuf/protoc.exe --cpp_out=$$PWD --proto_path=$$PWD/protos $$PWD/protos/${QMAKE_FILE_BASE}.proto
    protobuf_decl.variable_out = HEADERS
    QMAKE_EXTRA_COMPILERS += protobuf_decl

    protobuf_impl.name = protobuf implementation
    protobuf_impl.input = PROTOS
    protobuf_impl.output = ${QMAKE_FILE_BASE}.pb.cc
    protobuf_impl.depends = ${QMAKE_FILE_BASE}.pb.h
    protobuf_impl.commands = $$escape_expand(\n)
    protobuf_impl.variable_out = SOURCES
    QMAKE_EXTRA_COMPILERS += protobuf_impl@

    Now questions:

    in protobuf_decl.commands I specified the command to run protobuf compiler. That compiler generates *.pb..h and *.pb..cc files. But why protobuf_decl.output have only *.pb.h? Anyway, this command generates correct files, so why do I need to specify this output?

    if I remove protobuf_decl.output and protobuf_decl.variable_out I can't build a project - it says me about missing headers and protobuf compiler doesn't run at all. Is there any way to force it to run always first?

    protobuf_impl.commands = $$escape_expand(\n). What is this? What this command do and why I need this?

    1 Reply Last reply
    0
    • J Offline
      J Offline
      jaskij
      wrote on last edited by
      #2

      Not, that Im so sure about this myself, but:

      This looks like it's there mostly for the dependencies in the makefile. Simply put: qmake must know that something.pb.h is made by calling protobuf on something.proto to write it down properly in the makefile.

      As above: if you include something.pb.h and qmake doesn't know how to make that header so doesn't make so it isn't created -> you get a missing header.

      Probably it's basically "do nothing" said in elaborate way, but I'm not sure

      1 Reply Last reply
      0

      • Login

      • Login or register to search.
      • First post
        Last post
      0
      • Categories
      • Recent
      • Tags
      • Popular
      • Users
      • Groups
      • Search
      • Get Qt Extensions
      • Unsolved