| Trolltech Home | Qt-interest Home | Recent Threads | All Threads | Author | Date | |
| All threads index page 4 | |
Hi all,
Why does the include() command evaluate the variables in the path the included file is in and not the folder the parent
.pro file is?
For instance:
global.pri containing:
message("My current folder is: " $$system(pwd))
then in a subdirectory one level down from the .pri file the actual project file e.g. => src/myproject.pro:
include(../global.pri)
When running qmake over this it writes out that the current folder is the directory the .pri file is in, even though
qmake was run from within src/. I would have expected that it will give me the full path to the "src" folder.
Does anyone know if this the correct behavior or a bug?
thank you,
--stathis
--
[ signature omitted ]
> Why does the include() command evaluate the variables in the path the > included file is in and not the folder the parent .pro file is? (..snip..) > Does anyone know if this the correct behavior or a bug? It's the correct behavior. Reasoning: A pri include file might be used from several projects, as that is the sole intention of include files, to be reused in several places/projects. So, any file added to for example SOURCES in the .pri has to be in relation to the location of the pri file, since the pri files doesn't know the location of the files in relation to the project which includes it. Makes sense? :-) -- [ signature omitted ]
Attachment:
signature.asc
Description: OpenPGP digital signature
Marius Storm-Olsen wrote: >> Why does the include() command evaluate the variables in the path the >> included file is in and not the folder the parent .pro file is? > (..snip..) >> Does anyone know if this the correct behavior or a bug? > > It's the correct behavior. > > Reasoning: > A pri include file might be used from several projects, as that is the > sole intention of include files, to be reused in several places/projects. > So, any file added to for example SOURCES in the .pri has to be in > relation to the location of the pri file, since the pri files doesn't > know the location of the files in relation to the project which includes > it. Makes sense? :-) > > -- > .marius > Yes that makes perfect sense, I agree. However, in my particular case I want to inline a large chunk of qmake code that I use in multiple projects and wouldn't want to rewrite it each time. I'd like it not to be evaluated in the .pri's location, but in each project's location qmake is currently run from. This is mainly because there are system calls to be executed relative to the local structure of each of these projects. I guess I can pass the path to the .pri, as a solution. I was thinking more of a command to "source" (e.g. source(inline.pri)) files, as in scripting world. Thanks for the clarification though. cheers, --stathis
Attachment:
Attachment:
smime.p7s
Attachment:
Attachment:
signature.asc
Description: S/MIME Cryptographic Signature
Message 4 in thread
Stathis <stathis@xxxxxxxxxxxxxxxx> wrote on 07/17/2007 01:09:49 PM:
# Yes that makes perfect sense, I agree. However, in my particular
# case I want to inline a large chunk of qmake code that I use in
# multiple projects and wouldn't want to rewrite it each time.
What I do to solve this is something line the following:
(in .pro file)
TOPDIR=../..
include($${TOPDIR}/make/my.pri)
(in .pri file)
# yada yada yada...
#
system($${TOPDIR}/my/path/...) # Will run from an absolute path
# Or alternately:
system(something) # Will run from a relative path
--
[ signature omitted ]
Message 5 in thread
> # Yes that makes perfect sense, I agree. However, in my particular
> # case I want to inline a large chunk of qmake code that I use in
> # multiple projects and wouldn't want to rewrite it each time.
>
> What I do to solve this is something line the following:
(..snip..)
Yep, or simply:
(in .pro file)
PRO_DIR=$$PWD
include(../where/ever/shared.pri)
(in .pri file)
isEmpty(PRO_DIR):error("Projects .pro file needs to set PRO_DIR!")
message("Project is located here $$PRO_DIR")
Description: OpenPGP digital signature