【Qt】Qt中为不同的Kit设定不同的条件编译

来源:互联网 发布:mac怎么升级 编辑:程序博客网 时间:2024/06/05 18:23

在不同Kit的qmake参数中定义一个变量,变量值可以为平台名称,例如x86、x64、armhf等等。

然后在.pro文件中读取这个变量,判断是哪个kit。


在build steps中的additional arguments中新增一个任意变量,例如myPlatform=x86

然后在.pro文件中识别变量,注意,contains后面{必须要在同一行,否则无效,所有{}内都会被执行。

#message($$myPLATFORM) #print valueif(contains(myPLATFORM,armhf)){ # { must here    message("compile for armhf")    INCLUDEPATH += /opt/libusb-1.0_armhf/include/libusb-1.0/    LIBS += -L"/opt/libusb-1.0_armhf/lib" -lusb-1.0}if(contains(myPLATFORM,x86)){  # { must here    message("compile for x86")    INCLUDEPATH += /opt/libusb-1.0_x86/include/libusb-1.0/    LIBS += -L"/opt/libusb-1.0_x86/lib" -lusb-1.0}if(contains(myPLATFORM,x64)){ # { must here    message("compile for x64")    INCLUDEPATH += /opt/libusb-1.0_x64/include/libusb-1.0/    LIBS += -L"/opt/libusb-1.0_x64/lib" -lusb-1.0}



0 0
原创粉丝点击