Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Qt .pro file: how to check if I'm compiling with MSVC 2013 toolset?

Tags:

qt

qmake

I've tried this condition, but it doesn't work. How to check for MSVC 2013?

win32-msvc2013*{
    QMAKE_CXXFLAGS += /FS
}

I'm using Qt 5.3 Beta which has msvc-2013 mkspec.

like image 425
Violet Giraffe Avatar asked Apr 30 '14 07:04

Violet Giraffe


2 Answers

Sorry for necroposting, but there seems no googleable solution. Seems I found one. There is vcvars.bat file, which is used for setting correct environment variables for VC. QtCreator, for example, use it while setting Tools -> Options -> Build & Run -> Compilers. Also it is used for MSVC Command Promt. Let`s check "VisualStudioVersion" env var in qmake (14.0 for MSVS 2015 in my case):

win32-msvc* {
    MSVC_VER = $$(VisualStudioVersion)
    equals(MSVC_VER, 14.0){
        message("msvc 2015")
    }
}
like image 63
anatoly Avatar answered Sep 19 '22 13:09

anatoly


Try this way:

win32-msvc* {
    system(cl|grep "Compiler Version 18.") {
        message( "msvc 2013 detected" )
        QMAKE_CXXFLAGS += /FS
    }
}

http://qt-project.org/doc/qt-4.8/qmake-function-reference.html

Can't test it I don't have Windows machine now.

like image 20
Marek R Avatar answered Sep 18 '22 13:09

Marek R