views:

1312

answers:

4

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:

win32:message("using win32")
win64:message("using win64")
amd64:message("using amd64")

The result is always "using win32".

Must I use a separate project-file for x32 and x64 projects, so they would compile against correct libraries? Is there any other way to identify between 32-bit and 64-bit environments?

A: 

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

Reed Hedges
I want to use Win32 API in Qt and I must link against libraries from Windows SDK. Obviously those libraries are in different directories, and thus I need to include different files using LIBS. Maybe I'm doing it all wrong? Is there a better way to do it?
Tuminoid
Specifically in Qt Open Source Edition, not commercial Qt with VS integration, but from the command line and via qmake project files.
Tuminoid
+1  A: 

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.

Hope this helps anyone else wondering the same thing. Still, if there is better way of doing this, please answer to this post.

Tuminoid
Of course you can use different .pro files that include the common parts too, but personally I find that a pain in the...
Tuminoid
+3  A: 

I do it like this

win32 {

    ## Windows common build here

    !contains(QMAKE_HOST.arch, x86_64) {
        message("x86 build")

        ## Windows x86 (32bit) specific build here

    } else {
        message("x86_64 build")

        ## Windows x64 (64bit) specific build here

    }
}
did
A: 

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

rubenvb