[Qt-creator] Detecting different build configurations in the .pro file

Duane duane.hebert at group-upc.com
Mon May 14 14:41:29 CEST 2012


On 05/13/2012 01:39 AM, Orgad and Raizel Shaneh wrote:
> On Thu, May 10, 2012 at 10:36 PM, Duane Hebert
> <duane.hebert at group-upc.com>  wrote:
>>
>>
>> On 05/10/2012 03:29 PM, Orgad and Raizel Shaneh wrote:
>>>
>>> On Thu, May 10, 2012 at 10:25 PM, Duane<duane.hebert at group-upc.com>
>>>   wrote:
>>>>
>>>> On 05/10/2012 11:11 AM, Daniel Teske wrote:
>>>>>
>>>>> On Thursday 10 May 2012 16:35:16 ext Duane wrote:
>>>>>>
>>>>>> We're building for an embedded linux device.  I have a build of qt libs
>>>>>> using the linux frame buffer instead of x and a build of qt using the
>>>>>> regular linux desktop stuff.  For development I build with the desktop
>>>>>> version.  For deployement and hardware testing I build with the frame
>>>>>> buffer version.  This works well.
>>>>>>
>>>>>> The trouble is that I have some static libs for qwt and
>>>>>> qtsingleapplication, among others that when built, use conditional
>>>>>> builds based on Win32 or X11.  So when built for linux they use X11 but
>>>>>> when I'm building my app for the target, there is no X11.  So I have
>>>>>> builds of the libs with the frame buffer version of qt as well.  This
>>>>>> also works but I have to modify the .pro file each time that I change
>>>>>> build types.
>>>>>>
>>>>>> What I'd like to do is somehow in my project file include one version
>>>>>> lib or another based on which build I'm doing.  I was thinking maybe
>>>>>> using the mkspec or something.  The frame buffer version uses
>>>>>> qws/linux-... as opposed to just linux..
>>>>>>
>>>>>> Any idea how to achieve this or is it not possible?
>>>>>
>>>>> See http://qt-project.org/doc/qt-4.8/qmake-advanced-usage.html
>>>>> You can probably use what is described under "Platform Scope Values"
>>>>
>>>> Well I thought that I could use something like the example:
>>>> message($$QMAKESPEC)
>>>>
>>>>   linux-g++ {
>>>>       message(Linux)
>>>>   }
>>>>
>>>> because when looking at the makespec from the build configuration, the
>>>> one for the frame buffer shows qws/linux-x86-g++ and the desktop one
>>>> shows linux-g++.
>>>>
>>>>
>>>> But when I add
>>>> message($$QMAKESPEC)
>>>>
>>>>   linux-g++ {
>>>>       message(Linux)
>>>>   }
>>>>
>>>> qws/linux-x86-g++ {
>>>>      message(Linux frame buffer)
>>>> }
>>>>
>>>> to the .pro file, the output that I see is:
>>>> Project MESSAGE:
>>>> Project MESSAGE: Linux
>>>>
>>>> So it seems that $$QMAKESPEC is null.
>>>>
>>>> _______________________________________________
>>>> Qt-creator mailing list
>>>> Qt-creator at qt-project.org
>>>> http://lists.qt-project.org/mailman/listinfo/qt-creator
>>>
>>> There's an open report for that: QTBUG-22700. I think it's planned (or
>>> maybe already implemented?) for Qt 5.0.
>>>
>>
>> Thanks.  I wonder if there is a way to detect if X11 is defined?
>
> You can test for mkspec, wildcards allowed. In you case:
> linux-g++ {
>   # X11
> }
> linux-x86-g++ {
>   # framebuffer
> }
> linux-* {
>   # both, excluding windows and mac
> }


I would have thought so as well but this doesn't work.  In both builds, 
it falls into the linux-g++ case.  If I go to the projects view and put 
my mouse over the Qt version combo box, I get the tool tip and it says 
that the mkspec is qwt/linux-x86-g++.  When I switch builds to the x11 
build the mkspec is linux-g++.

But if I put:
linux-x86-g++ {
     message (Build using frame buffer)

}

linux-g++ {
    message (Build using X11)

}


and either build or run qmake, the Build using X11 shows.

This is not a severe problem, more of an annoyance. If I switch builds 
and don't change the .pro file, the build will fail eventually.  But it 
wastes some time.  I could set up separate projects but the projects are 
exactly the same except for a few libraries.




More information about the Qt-creator mailing list