git_version.pri 945 Bytes
Newer Older
Daniel Agar's avatar
Daniel Agar committed
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25
# set the QGC version from git

exists ($$PWD/.git) {
  GIT_DESCRIBE = $$system(git --git-dir $$PWD/.git --work-tree $$PWD describe --always --tags)
  WindowsBuild {
    QGC_GIT_VER = echo extern \"C\" { const char *git_version() { return \"$$GIT_DESCRIBE\"; } } > git_version.cpp
    LIBS += git_version.obj
  } else {
    QGC_GIT_VER = echo \"extern \\\"C\\\" { const char *git_version() { return \\\"$$GIT_DESCRIBE\\\"; } }\" > git_version.cpp
    LIBS += git_version.o
  }
}

WindowsBuild {
  LIBS += git_version.obj
} else {
  LIBS += git_version.o
}

CONFIG(debug) {
  GIT_VERSION_CXXFLAGS = $$QMAKE_CXXFLAGS_DEBUG
} else {
  GIT_VERSION_CXXFLAGS = $$QMAKE_CXXFLAGS_RELEASE
}

26 27 28 29 30
MacBuild {
    QMAKE_PRE_LINK += $$QGC_GIT_VER && $$QMAKE_CXX -mmacosx-version-min=$$QMAKE_MACOSX_DEPLOYMENT_TARGET -c $$GIT_VERSION_CXXFLAGS git_version.cpp
} else {
    QMAKE_PRE_LINK += $$QGC_GIT_VER && $$QMAKE_CXX -c $$GIT_VERSION_CXXFLAGS git_version.cpp
}