简体   繁体   English

Qt Qmake跨平台开发

[英]Qt qmake cross platform development

What is the correct way of defining cross platform behavior in qmake? 在qmake中定义跨平台行为的正确方法是什么? I'm attempting to merge two projects that use the same codebase but have different parameters in the qmake project file for things like different compiler flags or icon files. 我正在尝试合并两个使用相同代码库但在qmake项目文件中具有不同参数的项目,以用于诸如不同的编译器标志或图标文件之类的事情。

To clarify, if someone pulls the MyProject.pro from version control and attempts to run qmake on it on a mac, I want a couple lines to change when compared to the same operation on a windows machine. 要澄清的是,如果有人从版本控制中拉出MyProject.pro并尝试在Mac上对其运行qmake,那么与Windows计算机上的同一操作相比,我希望几行更改。 Is there any way of adding arguments to $> qmake ... or better, not have to change anything? 有什么方法可以向$> qmake ...添加参数$> qmake ...或更优,而不必更改任何内容?

You can write something like: 您可以这样写:

win32:{
    # Do something Windows specific 
} else {
    # Options for other platforms
}

in your .pro file(s). 在您的.pro文件中。

Yes, QMake does support conditional statements, in the form of scopes. 是的,QMake确实支持范围形式的条件语句。 Basically, you write something like this: 基本上,您可以这样写:

DEFINES = MY_DEF

win32 {
  DEFINES += WE_ARE_ON_WINDOWS
  debug {
    DEFINES += DEBUG_WINDOWS
  }
}

As the example shows, scopes can be nested. 如示例所示,范围可以嵌套。 Operators such as | 运算符,例如| for OR are also possible. 也可以使用OR。

For a full list of variables and functions, refer to QMake documentation . 有关变量和函数的完整列表,请参阅QMake文档

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM