简体   繁体   中英

Qt qmake cross platform development

What is the correct way of defining cross platform behavior in 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.

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. Is there any way of adding arguments to $> qmake ... or better, not have to change anything?

You can write something like:

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

in your .pro file(s).

Yes, QMake does support conditional statements, in the form of scopes. 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.

For a full list of variables and functions, refer to QMake documentation .

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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