Variables that persist across .pro files from a subdirs pro file

早过忘川 提交于 2019-12-30 08:02:13

问题


Greetings,

I've got a .pro file that looks like:

TEMPLATE = subdirs
SUBDIRS = foo bar

I want to set a variable, or define, or something in my subdirs .pro file that can be read in both the foo and bar .pro files.

I've tried to set an environment variable with:

export TEST=something

but that does not work, message($$(TEST)) always shows nothing (like TEST is unset).


回答1:


Another option is to place the common variables in a file called ".qmake.cache" stored in the root dir of the project. This way you don't need to include any .pri files in the subdir projects.




回答2:


Just place them in a common .pri file eg. common.pri and use qmake's own include syntax to include it i.e.

include(path/common.pri)

where path is the path to common.pri relative to the including .pro file.



来源:https://stackoverflow.com/questions/1450630/variables-that-persist-across-pro-files-from-a-subdirs-pro-file

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