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. [solved] Git describe in project file / Makefile
QtWS25 Last Chance

[solved] Git describe in project file / Makefile

Scheduled Pinned Locked Moved General and Desktop
8 Posts 2 Posters 4.8k 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.
  • J Offline
    J Offline
    julietbravo
    wrote on 5 Dec 2013, 08:27 last edited by
    #1

    I'm trying to add git-tags to our program, using something like:

    @DEFINES += GITHASH=$(shell git describe)@

    in the project file. This method was suggested elsewhere (http://qt-project.org/forums/viewthread/34635), because it adds the command to the Makefile, therefore not requiring a re-run of qmake every time. However, its not working for us. The statement ends up in the Makefile as:

    @-DGITHASH=$(shell git describe)@

    but seems to be missing some quotation marks / slashes which (with my limited experience with Qt) I can't seem to add. Can anyone point me in the right direction of the correct syntax for such a statement in a Qt project file?

    1 Reply Last reply
    0
    • S Offline
      S Offline
      SGaist
      Lifetime Qt Champion
      wrote on 5 Dec 2013, 12:15 last edited by
      #2

      Hi and welcome to devnet,

      Do you mean something like:

      @DEFINES += GITHASH="$(shell git describe)"@

      ?

      If not, what is the exact output that you would like to see in the Makefile ?

      Interested in AI ? www.idiap.ch
      Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

      1 Reply Last reply
      0
      • J Offline
        J Offline
        julietbravo
        wrote on 5 Dec 2013, 14:48 last edited by
        #3

        If I try that, it returns in the Makefile as:

        @DEFINES = -DGITHASH="$(shell -Dgit -Ddescribe)"@

        1 Reply Last reply
        0
        • S Offline
          S Offline
          SGaist
          Lifetime Qt Champion
          wrote on 5 Dec 2013, 17:13 last edited by
          #4

          Ok, but then what would you expect to have in your Makefile ? Furthermore, what OS/Qt version are you using ?

          Interested in AI ? www.idiap.ch
          Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

          1 Reply Last reply
          0
          • J Offline
            J Offline
            julietbravo
            wrote on 5 Dec 2013, 17:21 last edited by
            #5

            Both OS X (10.9) and Arch linux with Qt5.1.1

            To be honest, I have no idea what should be in there. I guess that the general question should be: how can I get the command line output from 'git describe' into Qt/C++. Most other options that I've seen require some pre-processing step, building a header file from/with a separate script, but to me it seems that there should be easier ways?

            1 Reply Last reply
            0
            • S Offline
              S Offline
              SGaist
              Lifetime Qt Champion
              wrote on 5 Dec 2013, 21:07 last edited by
              #6

              For 10.9 I would recommend upgrading to 5.2

              Try this

              @
              REVISION = $$system(git --git-dir $$PWD/.git --work-tree $$PWD describe)
              DEFINES += GITHASH=\\"\"$$REVISION\\"\"
              @

              Git must be in your path

              Interested in AI ? www.idiap.ch
              Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

              1 Reply Last reply
              0
              • J Offline
                J Offline
                julietbravo
                wrote on 5 Dec 2013, 21:30 last edited by
                #7

                Thanks for helping! It's a bit awkward with all these escape characters, but with:

                @DEFINES += GITHASH=\"$$REVISION\"@

                it works. So combined:

                @REVISION = $$system(git --git-dir $$PWD/.git --work-tree $$PWD describe)
                DEFINES += GITHASH=\"$$REVISION\"@

                does the trick.

                1 Reply Last reply
                0
                • S Offline
                  S Offline
                  SGaist
                  Lifetime Qt Champion
                  wrote on 5 Dec 2013, 21:45 last edited by
                  #8

                  Welcome to the wonderful world of console + pro file char escaping. With the "awkward" version you should be safe for all OSs

                  Interested in AI ? www.idiap.ch
                  Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

                  1 Reply Last reply
                  0

                  2/8

                  5 Dec 2013, 12:15

                  topic:navigator.unread, 6
                  • Login

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