How to refer to the source directory in qmake?

后端 未结 5 1874
长发绾君心
长发绾君心 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:11

    I found a better and cleaner solution

    version.target = version.h
    version.commands = bash ${QMAKE_VAR__PRO_FILE_PWD_}/generate-version.sh
    QMAKE_EXTRA_TARGETS += version
    

    The variable _PRO_FILE_PWD_ is documented since qt 4.5 and contains the path to the directory containing the project file in use (Contains the .pro file)

    But to access this variable for QMAKE_EXTRA_TARGETS, QMAKE_VAR_ must be appended.

提交回复
热议问题