Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. Qt Creator and other tools
  4. Using QMAKE_EXTRA_COMPILERS for header generation
Forum Updated to NodeBB v4.3 + New Features

Using QMAKE_EXTRA_COMPILERS for header generation

Scheduled Pinned Locked Moved Qt Creator and other tools
4 Posts 2 Posters 4.2k Views 1 Watching
  • 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.
  • S Offline
    S Offline
    silicomancer
    wrote on last edited by
    #1

    I am using Qt5 with VS2012. My .vcxproj files are generated from .pro files using qmake. My current task is to generate a header file (that contains simple version information) every time the application is built using Visual Studio. I could add a custom pre-build step to my VS project but that would get lost every time the .vcxproj is regnerated from .pro. So I need a .pro file based solution.

    I was told QMAKE_EXTRA_COMPILERS is what I need. So I tried to add a new compiler to one of my .pro files. Something like this:

    @
    PHONY_DEPS = .
    headergen.input = PHONY_DEPS
    headergen.output = test.c
    headergen.variable_out = GENERATED_SOURCES
    headergen.commands = echo Test > test.c
    headergen.name = CREATE test.c
    headergen.CONFIG += combine
    QMAKE_EXTRA_COMPILERS += headergen
    @

    This actually creates a test.c file every time I build my application. However I do not want to generate a .c file but a .h header:

    @
    PHONY_DEPS = .
    headergen.input = PHONY_DEPS
    headergen.output = test.h
    headergen.variable_out = HEADERS
    headergen.commands = echo Test > test.h
    headergen.name = CREATE test.h
    headergen.CONFIG += combine
    QMAKE_EXTRA_COMPILERS += headergen
    @

    This one fails without any error printed by qmake. The .vcxproj simply does not contain any additional build step.

    I never used QMAKE_EXTRA_COMPILERS before and the documentation is pretty poor. Could someone please give me a hint how to create a header generation rule?

    1 Reply Last reply
    0
    • S Offline
      S Offline
      silicomancer
      wrote on last edited by
      #2

      Nobody who could give a hint? Nobody who knows that technique?

      1 Reply Last reply
      0
      • O Offline
        O Offline
        ossi
        wrote on last edited by
        #3

        for headers, you need to add xxx.CONFIG += no_link. if you are lucky, things will be executed in the right order ...

        1 Reply Last reply
        0
        • S Offline
          S Offline
          silicomancer
          wrote on last edited by
          #4

          Many thanks for your answer! Sorry for the late reply. I could not try out your suggestion earlier.

          I added the no_link config option. This means I used
          @
          PHONY_DEPS = .
          headergen.input = PHONY_DEPS
          headergen.output = test.h
          headergen.variable_out = HEADERS
          headergen.commands = echo Test > test.h
          headergen.name = CREATE test.h
          headergen.CONFIG += combine no_link
          QMAKE_EXTRA_COMPILERS += headergen
          @

          This adds a <ClInclude Include="test.h" /> line to the generated .vcxproj file but unfortunately no CustomBuild step. So still there is something missing. One more idea?

          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