How to pass a cmd-command output to a #DEFINE MACRO in QMake

你说的曾经没有我的故事 提交于 2019-12-01 22:35:37

It could be something like that:

DEFINES += "SVN_V=\"\\\"$$system(svnversion -n)\\\"\""

$$system() is a qmake function to execute system command and obtain output from it.

external quotes around SVN_V... - is for qmake - it must understand that this is a single define. If $$system() returns space delimited string "Unknown version" you will get in result: -DSVN="Unknown -Dversion".

Next quotes \" - to pass $$system() result to compiler. Without it you will get two arguments instead of one "Unknown and version".

Double quoted quotes \\\" is to pass value to preprocessor. Without it value will be without quotes and recognized as int. \\\" will be resolved by qmake as \" and passed to compiler.

My cent on table: svn info --show-item revision

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!