Identifier for win64 configuration in Qmake

后端 未结 5 2055
南旧
南旧 2020-12-05 13:35

Is there a \"win64\" identifier in Qmake project files? Qt Qmake advanced documentation does not mention other than unix / macx / win32.

So far I\'ve tried using:

相关标签:
5条回答
  • 2020-12-05 13:41

    I do it like this

    win32 {
    
        ## Windows common build here
    
        !contains(QMAKE_TARGET.arch, x86_64) {
            message("x86 build")
    
            ## Windows x86 (32bit) specific build here
    
        } else {
            message("x86_64 build")
    
            ## Windows x64 (64bit) specific build here
    
        }
    }
    
    0 讨论(0)
  • 2020-12-05 13:48

    UPDATE: since very recently, Qt has a way of doing this transparently and easily, without manual hassle:

    win32-g++:contains(QMAKE_HOST.arch, x86_64):{
        do something
    }
    

    Source: the brand new Qt Dev FAQ

    0 讨论(0)
  • 2020-12-05 13:49

    No, but you can create and use a new mkspec, I think qmake also defines a platform identifier named after the current mkspec. Why do you need to test for 64 bit?

    Reed

    0 讨论(0)
  • 2020-12-05 13:57

    I've figured out one way to do it.

    Qt allows you to pass arbitrary config parameters which you can use to separate the targets.

    By having a conditional config in your project file:

    CONFIG(myX64, myX64|myX32) {
        LIBPATH += C:\Coding\MSSDK60A\Lib\x64
    } else {
        LIBPATH += C:\Coding\MSSDK60A\Lib
    }
    

    and passing that custom config to qmake with

    qmake CONFIG+=myX64
    

    you get the wanted result.

    0 讨论(0)
  • 2020-12-05 13:59

    Since Qt5 you can use QT_ARCH to detect whether your configuration is 32 or 64. When the target is 32-bit, that returns i386 and in case of a 64-bit target it has the value of x86_64. So it can be used like:

    contains(QT_ARCH, i386) {
        message("32-bit")
    } else {
        message("64-bit")
    }
    
    0 讨论(0)
提交回复
热议问题