我想在QMAKESPEC文件中创建一个基于其他变量的变量,如下所示(另见内联注释):
# some project-related paths
PROJECT_ABC_ROOT_PATH=$HOME/dev/project_one
PROJECT_XYZ_ROOT_PATH=$HOME/dev/project_two
# variable below is used to select one from the paths above
PROJ_NAME=ABC
# [1] this gives "projec_one" path properly
CURRENT_PATH=$${PROJECT_ABC_ROOT_PATH}
# [2] this doesn't work
CURRENT_PATH=$${PROJECT_$${PROJ_NAME}_ROOT_PATH}
有人可以就如何更正版本[2]提出建议吗?
答案 0 :(得分:1)
尝试以下方法:
# some project-related paths
PROJECT_ABC_ROOT_PATH=$HOME/dev/project_one
PROJECT_XYZ_ROOT_PATH=$HOME/dev/project_two
# variable below is used to select one from the paths above
PROJ_NAME=ABC
CURRENT_PATH=$$eval(PROJECT_$${PROJ_NAME}_ROOT_PATH)