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. [solved]Get Informations about the selected compiler in the .pro file
QtWS25 Last Chance

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

Scheduled Pinned Locked Moved General and Desktop
compiler
8 Posts 2 Posters 2.9k Views
  • 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.
  • T Offline
    T Offline
    tommy87
    wrote on 6 Mar 2015, 10:29 last edited by tommy87 3 Jun 2015, 12:40
    #1

    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?

    1 Reply Last reply
    0
    • S Offline
      S Offline
      SGaist
      Lifetime Qt Champion
      wrote on 6 Mar 2015, 10:32 last edited by SGaist 3 Jun 2015, 11:29
      #2

      Hi,

      IIRC something like

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

      should work

      [edit: corrected coding style SGaist]

      Interested in AI ? www.idiap.ch
      Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

      1 Reply Last reply
      0
      • T Offline
        T Offline
        tommy87
        wrote on 6 Mar 2015, 10:43 last edited by tommy87 3 Jun 2015, 10:51
        #3

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

        1 Reply Last reply
        0
        • T Offline
          T Offline
          tommy87
          wrote on 6 Mar 2015, 11:01 last edited by tommy87 3 Jun 2015, 11:03
          #4

          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?

          1 Reply Last reply
          0
          • S Offline
            S Offline
            SGaist
            Lifetime Qt Champion
            wrote on 6 Mar 2015, 11:31 last edited by
            #5

            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 ?

            Interested in AI ? www.idiap.ch
            Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

            1 Reply Last reply
            0
            • T Offline
              T Offline
              tommy87
              wrote on 6 Mar 2015, 11:48 last edited by tommy87 3 Jun 2015, 12:31
              #6

              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

              1 Reply Last reply
              0
              • T Offline
                T Offline
                tommy87
                wrote on 6 Mar 2015, 12:39 last edited by SGaist 3 Jun 2015, 12:51
                #7

                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]

                1 Reply Last reply
                0
                • S Offline
                  S Offline
                  SGaist
                  Lifetime Qt Champion
                  wrote on 6 Mar 2015, 13:00 last edited by SGaist 3 Jun 2015, 13:01
                  #8

                  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

                  Interested in AI ? www.idiap.ch
                  Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

                  1 Reply Last reply
                  0

                  8/8

                  6 Mar 2015, 13:00

                  • Login

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