[solved]Get Informations about the selected compiler in the .pro file



  • Hey Guys, i having a Problem. I Need to know in the .pro file if the selected compiler is a special VS compiler.
    One solution I found is to use the predefined compiler macros like "_MSC_VER" but the problem is, I cant access them in the pro file.
    So are there other possibility's? Or is there a way to access predefined compiler macros in the .pro file?


  • Lifetime Qt Champion

    Hi,

    IIRC something like

    win32-msvc2012{
        // msvc-2012 specific stuff here
    }
    

    should work

    [edit: corrected coding style SGaist]



  • The codes doesn't seems to work...but maybe I miss something...
    what does the @ operator do



  • but you give me the right direction. This constant has give me new google results and I solved my problem now.

    contains(QMAKE_COMPILER_DEFINES, _MSC_VER)
    {
    #do something
    }

    Edit:
    or am I mistaken and this is the information against what qt was compiled?


  • Lifetime Qt Champion

    AFAIK it's set in the mkspec you use to compile your project, so by default the one that was used to build Qt

    What version of visual studio are you using ?



  • currently I am using visual studio 2012 (VS11), so it could be work right...

    I have test it just now with different compilers and it works :) But the problem I have now, is to access the variable in QMAKE_COMPILER_DEFINES...
    contains doesnt tell me the value...

    Edit:
    oh it doesn't work, it doesn't get the right version for VS 2013...

    But your code with "win32-msvc2012" seems to work. But if I use an else case, it didn't find the version:
    win32-msvc2013{
    message(VS12)
    } else:win32-mscvc2012{
    message(VS11)
    } else:win32-mscvc2010{
    message(VS10)
    } else {
    message(an _error occoured using VS10 as default)
    }

    oh and as a little extra, I need the information about x86 and x 64 too, some ideas?

    Edit 2:
    upps a spelling error, so solved. Only x86 and x 64 is left



  • so detecting the architecture is now finished too, so the topic is solved

    win32-msvc*:contains(QMAKE_TARGET.arch, x86_64): {
        message(using x64)
    } else:win32-msvc*:contains(QMAKE_TARGET.arch, x86): {
        message(x86)
    } else:win32 {
        message(using x86 as default)
    }
    

    [edit: corrected indentation to show the code properly SGaist]


  • Lifetime Qt Champion

    Like that:

    win32-msvc* {
        contains(QMAKE_TARGET.arch, x86_64) {
            message(using x64)
        } else: contains(QMAKE_TARGET.arch, x86) {
            message(x86)
        }
    } else:win32 {
        message(using x86 as default)
    }
    

    would be a bit clearer


Log in to reply
 

Looks like your connection to Qt Forum was lost, please wait while we try to reconnect.