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. Can i store a value in a variable in QT .PRO file
Forum Update on Monday, May 27th 2025

Can i store a value in a variable in QT .PRO file

Scheduled Pinned Locked Moved Unsolved General and Desktop
14 Posts 3 Posters 2.1k 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.
  • M ManiRon
    11 Sept 2018, 06:53

    @sierdzio

    ok sir,

    Now i want to check for "win32-g++" in this string "C:/Qt/Qt5.5.0/5.5/mingw492_32/mkspecs/win32-g++"

    How can i do that?

    i tried like this

    MyVariable = $$QMAKESPEC
    contains($$MyVariable,win32-g++){
    message(Windows)
    }
    else{
    message(LINUX)
    }

    S Offline
    S Offline
    sierdzio
    Moderators
    wrote on 11 Sept 2018, 07:00 last edited by
    #5

    @ManiRon said in Can i store a value in a variable in QT .PRO file:

    contains($$MyVariable,win32-g++){

    Wrong syntax. No $$ is necessary in contains.

    Besides, what @SGaist suggests is indeed the best choice in your case. Scopes work for all values from CONFIG variable, and for makespecs as well.

    (Z(:^

    M 1 Reply Last reply 11 Sept 2018, 07:03
    2
    • S sierdzio
      11 Sept 2018, 07:00

      @ManiRon said in Can i store a value in a variable in QT .PRO file:

      contains($$MyVariable,win32-g++){

      Wrong syntax. No $$ is necessary in contains.

      Besides, what @SGaist suggests is indeed the best choice in your case. Scopes work for all values from CONFIG variable, and for makespecs as well.

      M Offline
      M Offline
      ManiRon
      wrote on 11 Sept 2018, 07:03 last edited by ManiRon 9 Nov 2018, 07:07
      #6

      @sierdzio actually i am facing some problem

      1. i want to run my application in windows , Linux, Xenomai.
      2. i have separate library for each platform
      3. i want to invoke the library based on the platform i run
      4. I can use win32 and unix for windows and linux
      5. but what should i use for xenomai
      6. if i declare both in unix it throws error

      Any solution? thats why i though of using contains() else method to invoke that particular library by checking win32-g++,linux-g++ and if it not both i will run xenomai library like that i planned

      1 Reply Last reply
      0
      • S Offline
        S Offline
        sierdzio
        Moderators
        wrote on 11 Sept 2018, 07:09 last edited by
        #7
        !win32:!linux {
          # Your xenomai libs go here
        }
        

        That should work.

        Alternatively, you can use your own custom config here:

        xenomai {
          # Your xenomai libs go here
        } else {
          win32 {
          }
          linux {
          }
        }
        

        Run qmake this way:

        qmake CONFIG+=xenomai
        
        

        (Z(:^

        M 1 Reply Last reply 11 Sept 2018, 07:20
        3
        • S sierdzio
          11 Sept 2018, 07:09
          !win32:!linux {
            # Your xenomai libs go here
          }
          

          That should work.

          Alternatively, you can use your own custom config here:

          xenomai {
            # Your xenomai libs go here
          } else {
            win32 {
            }
            linux {
            }
          }
          

          Run qmake this way:

          qmake CONFIG+=xenomai
          
          
          M Offline
          M Offline
          ManiRon
          wrote on 11 Sept 2018, 07:20 last edited by ManiRon 9 Nov 2018, 07:26
          #8

          @sierdzio

          message($$QMAKESPEC)

          when i tried to print the project message for linux and windows i got something like this

          Project MESSAGE: C:/Qt/Qt5.5.0/5.5/mingw492_32/mkspecs/win32-g++ for windows and corresponding for linux.

          But when i tried the same for xenomai i didnt get any. Is there any way ?

          S 1 Reply Last reply 11 Sept 2018, 07:32
          0
          • M ManiRon
            11 Sept 2018, 07:20

            @sierdzio

            message($$QMAKESPEC)

            when i tried to print the project message for linux and windows i got something like this

            Project MESSAGE: C:/Qt/Qt5.5.0/5.5/mingw492_32/mkspecs/win32-g++ for windows and corresponding for linux.

            But when i tried the same for xenomai i didnt get any. Is there any way ?

            S Offline
            S Offline
            sierdzio
            Moderators
            wrote on 11 Sept 2018, 07:32 last edited by
            #9

            @ManiRon said in Can i store a value in a variable in QT .PRO file:

            But when i tried the same for xenomai i didnt get any. Is there any way ?

            If you don't specify a makespec then the variable will be empty. You can create your own mkspecs if you want to (they are stored in Qt directory and are simple text files), but I'd rather recommend using a predefined one. Does your platform come with some toolchain / precompiled Qt version? Then it should have some makespecs defined already.

            But the simplest solution is just to use one of the conditions I mentioned in my previous post.

            (Z(:^

            M 1 Reply Last reply 11 Sept 2018, 07:46
            0
            • S sierdzio
              11 Sept 2018, 07:32

              @ManiRon said in Can i store a value in a variable in QT .PRO file:

              But when i tried the same for xenomai i didnt get any. Is there any way ?

              If you don't specify a makespec then the variable will be empty. You can create your own mkspecs if you want to (they are stored in Qt directory and are simple text files), but I'd rather recommend using a predefined one. Does your platform come with some toolchain / precompiled Qt version? Then it should have some makespecs defined already.

              But the simplest solution is just to use one of the conditions I mentioned in my previous post.

              M Offline
              M Offline
              ManiRon
              wrote on 11 Sept 2018, 07:46 last edited by ManiRon 9 Nov 2018, 07:47
              #10

              @sierdzio

              xenomai {
              #Your xenomai libs go here
              } else {
              win32 {
              }
              linux {
              }
              }
              in this it is going to linux when i run in xenomai platform. not tested with this but test like this.
              linux{
              #xenomai libs
              }

              S 1 Reply Last reply 11 Sept 2018, 07:56
              0
              • M ManiRon
                11 Sept 2018, 07:46

                @sierdzio

                xenomai {
                #Your xenomai libs go here
                } else {
                win32 {
                }
                linux {
                }
                }
                in this it is going to linux when i run in xenomai platform. not tested with this but test like this.
                linux{
                #xenomai libs
                }

                S Offline
                S Offline
                sierdzio
                Moderators
                wrote on 11 Sept 2018, 07:56 last edited by
                #11

                @ManiRon said in Can i store a value in a variable in QT .PRO file:

                in this it is going to linux when i run in xenomai platform

                Because you have not called qmake with CONFIG+=xenomai, right?

                (Z(:^

                M 1 Reply Last reply 11 Sept 2018, 09:16
                0
                • S sierdzio
                  11 Sept 2018, 07:56

                  @ManiRon said in Can i store a value in a variable in QT .PRO file:

                  in this it is going to linux when i run in xenomai platform

                  Because you have not called qmake with CONFIG+=xenomai, right?

                  M Offline
                  M Offline
                  ManiRon
                  wrote on 11 Sept 2018, 09:16 last edited by
                  #12

                  @sierdzio

                  Actually i havent tested with your code . we tested yesterday like

                  linux{
                  Libs of xenomai
                  }
                  we thought it wont go in but it went in . the same we used for xenomai also we oserved the same .

                  One of the person from QT forum told that linux can be given for both linux and xenomai

                  now if this is the case . If i use the code which u mentioned it wont create a problem ?

                  S 1 Reply Last reply 11 Sept 2018, 09:29
                  0
                  • M ManiRon
                    11 Sept 2018, 09:16

                    @sierdzio

                    Actually i havent tested with your code . we tested yesterday like

                    linux{
                    Libs of xenomai
                    }
                    we thought it wont go in but it went in . the same we used for xenomai also we oserved the same .

                    One of the person from QT forum told that linux can be given for both linux and xenomai

                    now if this is the case . If i use the code which u mentioned it wont create a problem ?

                    S Offline
                    S Offline
                    sierdzio
                    Moderators
                    wrote on 11 Sept 2018, 09:29 last edited by
                    #13

                    @ManiRon said in Can i store a value in a variable in QT .PRO file:

                    now if this is the case . If i use the code which u mentioned it wont create a problem ?

                    No. Just try it out :-) You can put in some messages inside - then you'll know exactly which way qmake went. I recommend doing that anyway - to help find issues in the future.

                    (Z(:^

                    M 1 Reply Last reply 11 Sept 2018, 09:47
                    0
                    • S sierdzio
                      11 Sept 2018, 09:29

                      @ManiRon said in Can i store a value in a variable in QT .PRO file:

                      now if this is the case . If i use the code which u mentioned it wont create a problem ?

                      No. Just try it out :-) You can put in some messages inside - then you'll know exactly which way qmake went. I recommend doing that anyway - to help find issues in the future.

                      M Offline
                      M Offline
                      ManiRon
                      wrote on 11 Sept 2018, 09:47 last edited by
                      #14

                      @sierdzio ok I will try that and say

                      1 Reply Last reply
                      0

                      14/14

                      11 Sept 2018, 09:47

                      • Login

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