Qt Forum

    • Login
    • Search
    • Categories
    • Recent
    • Tags
    • Popular
    • Users
    • Groups
    • Search
    • Unsolved

    Qt Academy Launch in California!

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

    General and Desktop
    compiler
    2
    8
    2374
    Loading More Posts
    • 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
      tommy87 last edited by tommy87

      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 Reply Quote 0
      • SGaist
        SGaist Lifetime Qt Champion last edited by SGaist

        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 Reply Quote 0
        • T
          tommy87 last edited by tommy87

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

          1 Reply Last reply Reply Quote 0
          • T
            tommy87 last edited by tommy87

            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 Reply Quote 0
            • SGaist
              SGaist Lifetime Qt Champion last edited by

              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 Reply Quote 0
              • T
                tommy87 last edited by tommy87

                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 Reply Quote 0
                • T
                  tommy87 last edited by SGaist

                  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 Reply Quote 0
                  • SGaist
                    SGaist Lifetime Qt Champion last edited by SGaist

                    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 Reply Quote 0
                    • First post
                      Last post