Can i store a value in a variable in QT .PRO file
-
You can create variables in qmake the same way you do it in shell:
MyVariable="some value" # Then use it: message("Variable: "$$MyVariable)
-
You can create variables in qmake the same way you do it in shell:
MyVariable="some value" # Then use it: message("Variable: "$$MyVariable)
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)
} -
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)
}@ManiRon said in Can i store a value in a variable in QT .PRO file:
contains($$MyVariable,win32-g++){
Wrong syntax. No
$$
is necessary incontains
.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. -
@ManiRon said in Can i store a value in a variable in QT .PRO file:
contains($$MyVariable,win32-g++){
Wrong syntax. No
$$
is necessary incontains
.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.@sierdzio actually i am facing some problem
- i want to run my application in windows , Linux, Xenomai.
- i have separate library for each platform
- i want to invoke the library based on the platform i run
- I can use win32 and unix for windows and linux
- but what should i use for xenomai
- 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
-
!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
-
!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
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 ?
-
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 ?
@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.
-
@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.
-
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
}@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? -
@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?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 ?
-
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 ?
@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.
-
@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.