[SOLVED] Using wildcards for SOURCES when build dir is different from source dir
-
Hi guys,
I'm stuck with one problem when building my project and still can't find the reason for such behaviour. Consider the following project layout.
@Project
|_Project.pro
|_Module1
|_Module1.pro
|_Part1
| |_f.cpp
| |_f.h
|_Part2
|_g.cpp
|_g.h@Here is my Project.pro:
@TEMPLATE = subdirsSUBDIRS = Module1@
Here is my Module1.pro:
@TEMPLATE = libHEADERS = $$PWD/Part1/.h
$$PWD/Part2/.hSOURCES = $$PWD/Part1/.cpp
$$PWD/Part2/.cpp@Now i create build directory, because I want it to be separate from source directory, and run qmake:
$ cd <Project/Path>
$ mkdir build
$ cd build
$ qmake ../Project.pro
$ makeAnd here I get the following error:
@make[1]: *** No rule to make target
../../../Module1/Part1/f.cpp', needed by
f.o'. Stop.@I suppose this is because I have used wildcards for setting SOURCES and HEADERS variable. I think so, because If I don't use them and type the whole concrete paths when setting SOURCE/HEADERS my build goes ok.
Is this how it is supposed to behave when using wildcards, or it is a bug? If that is how it should be does anybody knows the way to fix that (of course I want to use wildcards because it save time and space:) )?
Thanks
-
In Module1.pro, you don't need the "$$PWD/", you can write a relative path.
Also, qmake doesn't like to have a build directory under src, try this instead:
@
$ cd
$ cd ..
$ mkdir build
$ cd build
$ qmake ../src/Project.pro
$ make
@ -
I think you are having some other issue: Qmake is very picky with where it wants its build directory. Try putting the build directory parallel to the source directory, not into it.
-
[quote author="Nicolas" date="1286191411"]In Module1.pro, you don't need the "$$PWD/", you can write a relative path.
Also, qmake doesn't like to have a build directory under src, try this instead:
@
$ cd
$ cd ..
$ mkdir build
$ cd build
$ qmake ../src/Project.pro
$ make
@[/quote]I do have to write $$PWD. PWD is the directory where the .pro file is located (this is from qmake variable reference). The location of sources is relative to $$PWD.
bq. Try putting the build directory parallel to the source directory, not into it.
I tried the same with build directory outside source directory. But the result was the same. I haven't tried to use build directory that is on the same level as my source directory is. Having them on the same exact level - isn't that a wrong limitation?
Thanks.
UPD: I can build Qt Creator with build directory that is several levels upper than the source tree.
-
[quote author="lyuts" date="1286192482"] [quote author="Nicolas" date="1286191411"]In Module1.pro, you don't need the "$$PWD/", you can write a relative path.
[/quote]I do have to write $$PWD. PWD is the directory where the .pro file is located (this is from qmake variable reference). The location of sources is relative to $$PWD.
[/quote]
I can assure you you don't need the $$PWD. Maybe you can give it a try without it.No other idea, sorry.
-
[quote author="Nicolas" date="1286192967"]
I can assure you you don't need the $$PWD. Maybe you can give it a try without it.
[/quote]This is maybe true when no wildcards are used. I put wildcards there and the no files could be located without $$PWD. When I put $$PWD the files list contains my files but the path prefixed is not correct, i.e. lead to a wrong location.
-
The undocumented qmake function files(glob) might do what you want. Try this for Module1.pro:
@
TEMPLATE = libHEADERS = $$files(Part1/.h)
$$files(Part2/.h)SOURCES = $$files(Part1/.cpp)
$$files(Part2/.cpp)
@