qmake creates build artifacts in source directory even when building in out-of-source build directory
-
wrote on 26 Sept 2019, 18:39 last edited by
Hi!
Can someone explain why
qmake
creates build artifacts in source directory even when building in out-of-source build directory?Given the following directory tree:
. ├── build ├── src │ ├── app │ ├── controller │ └── ui ├── tests │ ├── mock-ui │ └── tests └── tests-build ├── mock-ui └── tests
where
build
is the directory for building source files insrc
andtests-build
is the directory for building sources intests
, and the followingtests.pro
project file intests
:TEMPLATE = subdirs CONFIG += ordered SUBDIRS = \ mock-ui \ ../src/controller \ tests tests.depends = controller mock-ui
when I run
cd tests-build qmake ../tests make check
then
controller
project build artifacts appear insrc/controller
instead oftests-build
where they should appear.Is this because the
controller
project is outside of thetest
subdirs project root? How can I fix this?Thanks in advance for any tips!
-
Hi and welcome to devnet,
Why is contoller outside of the subdir project ?
Note that qmake is not cmake, you usually do out of source builds, not "in a folder inside the sources". IIRC, there was an issue with how the paths were generated when inside a subfolder but I'm not 100% sure.
-
Hi and welcome to devnet,
Why is contoller outside of the subdir project ?
Note that qmake is not cmake, you usually do out of source builds, not "in a folder inside the sources". IIRC, there was an issue with how the paths were generated when inside a subfolder but I'm not 100% sure.
wrote on 26 Sept 2019, 18:56 last edited by Mrts@SGaist thanks for the welcome!
Note that both build directories are outside the sources, so they are already out of source builds:
. ├── build <-- build directory for sources in src ├── src ├── tests └── tests-build <-- build directory for sources in tests
The
tests
subdirs project is a QTest project for testingcontroller
.controller
is a separate static library module that should be unaware of tests, hence it lies outside of tests insrc
.Note that
mock-ui
andtests
build artifacts end up intests-build
as expected, onlycontroller
misbehaves. -
Can you show the complete structure of your project ?
-
wrote on 26 Sept 2019, 19:15 last edited by Mrts
@SGaist sure, here it goes:
. ├── build ├── src │ ├── app │ │ ├── app.pro │ │ ├── main.cpp │ │ └── parseargs.hpp │ ├── common.pri │ ├── controller │ │ ├── controller.cpp │ │ ├── controller.hpp │ │ ├── controller.pro │ │ └── monitorthread.hpp │ ├── ui │ │ ├── ui.cpp │ │ ├── ui.hpp │ │ └── ui.pro │ └── foo.pro ├── tests │ ├── mock-ui │ │ ├── mock-ui.cpp │ │ ├── mock-ui.hpp │ │ └── mock-ui.pro │ ├── tests │ │ ├── main.cpp │ │ └── tests.pro │ └── foo-tests.pro └── tests-build
Thanks for looking into this!
-
Are they all separated projects ?
-
@SGaist sure, here it goes:
. ├── build ├── src │ ├── app │ │ ├── app.pro │ │ ├── main.cpp │ │ └── parseargs.hpp │ ├── common.pri │ ├── controller │ │ ├── controller.cpp │ │ ├── controller.hpp │ │ ├── controller.pro │ │ └── monitorthread.hpp │ ├── ui │ │ ├── ui.cpp │ │ ├── ui.hpp │ │ └── ui.pro │ └── foo.pro ├── tests │ ├── mock-ui │ │ ├── mock-ui.cpp │ │ ├── mock-ui.hpp │ │ └── mock-ui.pro │ ├── tests │ │ ├── main.cpp │ │ └── tests.pro │ └── foo-tests.pro └── tests-build
Thanks for looking into this!
Hi @Mrts,
usually the
SUBDIRS
pro file is top-level, i.e. all referenced pro files are below it.That gives you one build directory with the same hierarchy as your source folders.
And please: Don't use
CONFIG+=ORDERED
!Regards
https://blog.rburchell.com/2013/10/every-time-you-configordered-kitten-dies.html
-
Hi @Mrts,
usually the
SUBDIRS
pro file is top-level, i.e. all referenced pro files are below it.That gives you one build directory with the same hierarchy as your source folders.
And please: Don't use
CONFIG+=ORDERED
!Regards
https://blog.rburchell.com/2013/10/every-time-you-configordered-kitten-dies.html
1/8