方法一: 在配置前面加上平台标识符的前缀
# windows
win32:INCLUDEPATH += F:/Dev/ffmpeg-4.3.2/include
win32:LIBS += -LF:/Dev/ffmpeg-4.3.2/lib \-lavcodec \-lavdevice \-lavfilter \-lavformat \-lavutil \-lpostproc \-lswscale \-lswresample# mac
macx:INCLUDEPATH += /usr/local/Cellar/ffmpeg/4.3.2/include
macx:LIBS += -L/usr/local/Cellar/ffmpeg/4.3.2/lib \-lavcodec \-lavdevice \-lavfilter \-lavformat \-lavutil \-lpostproc \-lswscale \-lswresample \-lavresample# linux
# linux:INCLUDEPATH += ...
# linux:LIBS += ...
或使用 大括号 简化:
# windows
win32 {INCLUDEPATH += F:/Dev/ffmpeg-4.3.2/includeLIBS += -LF:/Dev/ffmpeg-4.3.2/lib \-lavcodec \-lavdevice \-lavfilter \-lavformat \-lavutil \-lpostproc \-lswscale \-lswresample
}# mac
macx {INCLUDEPATH += /usr/local/Cellar/ffmpeg/4.3.2/includeLIBS += -L/usr/local/Cellar/ffmpeg/4.3.2/lib \-lavcodec \-lavdevice \-lavfilter \-lavformat \-lavutil \-lpostproc \-lswscale \-lswresample \-lavresample
}
方法二:将公共信息抽取成变量,然后使用$${}去访问
使用$${}
去访问
# mac
macx {FFMPEG_HOME = /usr/local/Cellar/ffmpeg/4.3.2INCLUDEPATH += $${FFMPEG_HOME}/includeLIBS += -L$${FFMPEG_HOME}/lib \-lavcodec \-lavdevice \-lavfilter \-lavformat \-lavutil \-lpostproc \-lswscale \-lswresample \-lavresample
}
message()
可以用来打印$${}
可以用来取值:.pro
中定义的变量$$()
可以用来取值系统环境变量
中的变量