Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. General and Desktop
  4. How to differentiate between VS2017/2019 and older Visual Studio versions in qmake .pro file?

How to differentiate between VS2017/2019 and older Visual Studio versions in qmake .pro file?

Scheduled Pinned Locked Moved Solved General and Desktop
3 Posts 2 Posters 980 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • B Offline
    B Offline
    Bart_Vandewoestyne
    wrote on last edited by Bart_Vandewoestyne
    #1

    According to https://docs.microsoft.com/en-us/cpp/build/reference/permissive-standards-conformance?view=msvc-160 the /permissive- flag is only supported since VS2017. I wanted to use that compiler flag for my project, but only if it is compiled with VS2017 or later. I am using Qt 5.15.1. I tried using

        win32-msvc2017 | win32-msvc2019 {
            QMAKE_CXXFLAGS += /permissive-
        }
    

    but that fails, because there are no win32-msvc2017 nor win32-msvc2019 in the mkspecs directory of my Qt 5.15.1 install. There is only a win32-msvc directory. How can I specify that the /permissive- flag should only be used when compiling my project with VS2017 or later?

    1 Reply Last reply
    0
    • Christian EhrlicherC Offline
      Christian EhrlicherC Offline
      Christian Ehrlicher
      Lifetime Qt Champion
      wrote on last edited by
      #2

      You can try the (undocumented) variable QMAKE_MSC_VER (see mkspecs\common\msvc-version.conf)

      Qt Online Installer direct download: https://download.qt.io/official_releases/online_installers/
      Visit the Qt Academy at https://academy.qt.io/catalog

      B 1 Reply Last reply
      1
      • Christian EhrlicherC Christian Ehrlicher

        You can try the (undocumented) variable QMAKE_MSC_VER (see mkspecs\common\msvc-version.conf)

        B Offline
        B Offline
        Bart_Vandewoestyne
        wrote on last edited by Bart_Vandewoestyne
        #3

        @Christian-Ehrlicher said in How to differentiate between VS2017/2019 and older Visual Studio versions in qmake .pro file?:

        You can try the (undocumented) variable QMAKE_MSC_VER (see mkspecs\common\msvc-version.conf)

        To specify that I only want to use the /permissive- flag from VS2017 on and later, I just tried

            greaterThan(QMAKE_MSC_VER, 1900) {
                QMAKE_CXXFLAGS += /permissive-
            }
        

        which is similar to the code in mkspecs\common\msvc-version.confand that seems to work:

        DEBUG 2: evaluating joined expression
        DEBUG 2: new string
        DEBUG 2: literal "QMAKE_MSC_VER"
        DEBUG 2: evaluated expression => QMAKE_MSC_VER
        DEBUG 2: evaluating joined expression
        DEBUG 2: new string
        DEBUG 2: literal "1900"
        DEBUG 2: evaluated expression => QMAKE_MSC_VER 1900
        DEBUG 1: D:/blablabla.pri:83: calling built-in greaterThan(QMAKE_MSC_VER, 1900)
        DEBUG 1: D:/blablabla.pri.pri:83: test function returned true
        DEBUG 1: D:/blablabla.pri.pri:83: taking 'then' branch
        DEBUG 1: D:/blablabla.pri.pri:83: entering block
        

        Thanks!

        1 Reply Last reply
        1

        • Login

        • Login or register to search.
        • First post
          Last post
        0
        • Categories
        • Recent
        • Tags
        • Popular
        • Users
        • Groups
        • Search
        • Get Qt Extensions
        • Unsolved