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

版权声明:本文为博主原创文章,转载注明出处 https://blog.csdn.net/u010875635/article/details/71424306

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

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


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

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

#message($$myPLATFORM) #print value

if(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
}



猜你喜欢

转载自blog.csdn.net/u010875635/article/details/71424306
今日推荐