qmake creates build artifacts in source directory even when building in out-of-source build directory
-
Hi!
Can someone explain why
qmakecreates 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 └── testswhere
buildis the directory for building source files insrcandtests-buildis the directory for building sources intests, and the followingtests.proproject file intests:TEMPLATE = subdirs CONFIG += ordered SUBDIRS = \ mock-ui \ ../src/controller \ tests tests.depends = controller mock-uiwhen I run
cd tests-build qmake ../tests make checkthen
controllerproject build artifacts appear insrc/controllerinstead oftests-buildwhere they should appear.Is this because the
controllerproject is outside of thetestsubdirs 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.
@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 testsThe
testssubdirs project is a QTest project for testingcontroller.controlleris a separate static library module that should be unaware of tests, hence it lies outside of tests insrc.Note that
mock-uiandtestsbuild artifacts end up intests-buildas expected, onlycontrollermisbehaves. -
Can you show the complete structure of your project ?
-
@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-buildThanks 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-buildThanks for looking into this!
Hi @Mrts,
usually the
SUBDIRSpro 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
SUBDIRSpro 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