How to refer to the source directory in qmake?

后端 未结 5 1891
长发绾君心
长发绾君心 2020-12-30 10:57

I added

version.target = version.h
version.commands = bash generate-version.sh

QMAKE_EXTRA_TARGETS += version

PRE_TARGETDEPS += version.h
<
5条回答
  •  春和景丽
    2020-12-30 11:01

    I use (Linux and g++)

    DEFINES += SVN_VERSION=\\\"\""`svnversion $$PWD`\""\\\"
    DEFINES += COMPILE_DATE=\\\"\""`date`\""\\\"
    DEFINES += SW_VERSION=\\\"\"0.5\"\\\"
    

    which defines the macro SVNVERSON to be the svn version. To access it from C++:

    QString svnVersion = SVN_VERSION;
    QString swVersion  = SW_VERSION;
    

    Explanation: On the shell I want to see this call:

    -DSVN_VERSION=\""`svnversion /path/to/my/source`"\"
    

    As you see some escapes are necessary on shell level. In the .pro-file it then has to be escaped twice.

提交回复
热议问题