当前位置:   article > 正文

Qt pro文件中判断 x86/arm(aarch64)交叉编译环境,区分 linux/windows系统, debug/release版本_qtcontains(qmake_host.arch, x86_64){ message("编译平台

qtcontains(qmake_host.arch, x86_64){ message("编译平台: x86") }else{ message

使用的arm编译器为aarch64, 很多博客都是使用 QMAKE_HOST.arch 进行判断,但这并不能分辨出 aarch64 编译器,有的更离谱的是定义一个函数,实在让人无言,自行尝试解决方案如下:

contains(QT_ARCH, arm64){
message("arm64") #在这里处理arm64所需
}else{
message("x86")
}
  • 1
  • 2
  • 3
  • 4
  • 5

linux/windows 区分:

win32{
//do something...
}
unix{
//do something...
}
  • 1
  • 2
  • 3
  • 4
  • 5
  • 6

debug / release 区分:

CONFIG += debug_and_release
CONFIG(debug, debug|release){  //处理debug
}else{  //处理release
}
  • 1
  • 2
  • 3
  • 4

都可以组合使用,如:

CONFIG += debug_and_release
CONFIG(debug, debug|release){  //处理debug
    win32{
    }
    unix{
    	contains(QT_ARCH, arm64){
			message("arm64")
			}else{
			message("x86")
			}
    }
}else{     //处理release
    win32{
    }
    unix{
    }
}
  • 1
  • 2
  • 3
  • 4
  • 5
  • 6
  • 7
  • 8
  • 9
  • 10
  • 11
  • 12
  • 13
  • 14
  • 15
  • 16
  • 17
声明:本文内容由网友自发贡献,不代表【wpsshop博客】立场,版权归原作者所有,本站不承担相应法律责任。如您发现有侵权的内容,请联系我们。转载请注明出处:https://www.wpsshop.cn/w/盐析白兔/article/detail/282958
推荐阅读
相关标签
  

闽ICP备14008679号