Qt-interest Archive, May 2008
qmake INCLUDEPATH precedence and user configuration
Message 1 in thread
We have an opensource project that was originally written for
FreeBSD and Linux. Thanks to Qt's brilliance we have recently
been able to get it to also work beautifully with Mac OS X
(only command-line was necessary not XCode). Nice, thanks.
For finding the pre-requisite libraries, we specify INCLUDEPATHs
in our project lib.pro files for each operating system.
However for Mac, the user could have installed pre-requisites
via either Fink (so in /sw/include), or MacPorts (so
in /opt/local/include), or directly in /usr/local/include
To date we do not try to set it for users, instead instructing
them to specifically add to the 'qmake' invocation, i.e.
qmake ... "macx:INCLUDEPATH += /opt/...
Of course we would now like to specify that for them, perhaps
by adding all likely INCLUDEPATHs to our lib.pro file. However,
maybe the user has two different versions of a pre-requisite,
so we should not assume. Does qmake give precedence, so the
first found libary wins?
How do developers normally handle such user configuration?
Do you use qmake prompt() to let them over-ride a default value?
-David
--
[ signature omitted ]
Message 2 in thread
On 15.05.08 17:52:33, David Crossley wrote:
> We have an opensource project that was originally written for
> FreeBSD and Linux. Thanks to Qt's brilliance we have recently
> been able to get it to also work beautifully with Mac OS X
> (only command-line was necessary not XCode). Nice, thanks.
>
> For finding the pre-requisite libraries, we specify INCLUDEPATHs
> in our project lib.pro files for each operating system.
> However for Mac, the user could have installed pre-requisites
> via either Fink (so in /sw/include), or MacPorts (so
> in /opt/local/include), or directly in /usr/local/include
>
> To date we do not try to set it for users, instead instructing
> them to specifically add to the 'qmake' invocation, i.e.
> qmake ... "macx:INCLUDEPATH += /opt/...
>
> Of course we would now like to specify that for them, perhaps
> by adding all likely INCLUDEPATHs to our lib.pro file. However,
> maybe the user has two different versions of a pre-requisite,
> so we should not assume. Does qmake give precedence, so the
> first found libary wins?
>
> How do developers normally handle such user configuration?
> Do you use qmake prompt() to let them over-ride a default value?
Usuallly you write a configure script, which checks for the existence of
the headers you need in the various paths, but also allows the user to
specify a path.
Then you can simply write what you found into variables in .qmake.cache
in your top-level project directory and qmake will use these values as
default for the variables when it runs through the various .pro files.
Check the Qt source to get a clearer idea how its done there.
Andreas
--
[ signature omitted ]
Message 3 in thread
Ah, that is the answer thanks. I see what is happening now.
As with all opensource projects, it grows and grows.
We started off supporting one operating system, where it
is okay to hard-code paths. Then we support more systems,
so more tweaks. Now it is time to get more serious about
the configuration. Thanks again.
-David
--
[ signature omitted ]
Message 4 in thread
Andreas Pakulat wrote:
>
> Usuallly you write a configure script, which checks for the existence of
> the headers you need in the various paths, but also allows the user to
> specify a path.
I didn't want to go to the full power of GNU 'configure'
just yet, but might still need to.
So i am hoping to use a simple shell script and qmake itself
to do the configuration stage.
I expected that 'qmake -query ...' should report the
operating system that it is running on. So "freebsd, linux, macx, ..."
However, i cannot find such a way to determine the OS.
Is that possible?
I know that the "scope" can be used later when processing
the *.pro files.
> Then you can simply write what you found into variables in .qmake.cache
> in your top-level project directory and qmake will use these values as
> default for the variables when it runs through the various .pro files.
>
> Check the Qt source to get a clearer idea how its done there.
Thanks, got that part sorted out now.
-David
--
[ signature omitted ]
Message 5 in thread
On 16.05.08 17:41:17, David Crossley wrote:
> Andreas Pakulat wrote:
> >
> > Usuallly you write a configure script, which checks for the existence of
> > the headers you need in the various paths, but also allows the user to
> > specify a path.
>
> I didn't want to go to the full power of GNU 'configure'
> just yet, but might still need to.
>
> So i am hoping to use a simple shell script and qmake itself
> to do the configuration stage.
>
> I expected that 'qmake -query ...' should report the
> operating system that it is running on. So "freebsd, linux, macx, ..."
> However, i cannot find such a way to determine the OS.
> Is that possible?
>
> I know that the "scope" can be used later when processing
> the *.pro files.
That doesn't work IIRC, because qmake is pretty dumb here. The configure
script in Qt's source tree actually does all the checking and then
creates a symlink to the right qmake mkspec depending on the OS you're
running. And when you later on invoke qmake it just uses whatever is the
default mkspec set in the mkspecs directory.
There are only very few variables that you can use with qmake -query,
check qmake/property.cpp in the Qt sources, all that are listed in the
value() function can be used, but nothing else.
So you're basically on your own writing a proper configure, for starters
on *nix like systems uname -a might tell you quite a bit about the
system.
There may even be tools out there that help you with that, but I don't
know any because I keep myself away from buildtools that don't have a
configure-phase built-in ;)
Andreas
--
[ signature omitted ]
Message 6 in thread
I easily solved it with a minimal shell script that verifies the
Qt version using 'qmake --version' which works for Qt3 and Qt4.
Then it calls qmake to create the Makefile from our top-level
qtstalker.pro file. This .pro file uses the relevant scope to
determine the include locations for the various types of OS.
It uses a system() to append the INCLUDEPATH and LIBS to
the .qmake.cache file.
Neat. The project can configure itself just using qmake.
Thanks.
-David
--
[ signature omitted ]