PDA

View Full Version : qmake sessions and placing subdir outputs into global binary dir (OUT_DIR)



ghorwin
8th February 2022, 12:19
Hi,

I have a project with quite a few Qt-libraries and applications, organized in a directory structure and built using a central session file:

Directory structure:



build/Qt/MyProject.pro
libs/lib1/lib1.pro
libs/lib2/lib2.pro
app/app1.pro


where MyProject.pro looks like:



TEMPLATE = subdirs
SUBDIRS = Lib1 Lib2 App1
Lib1.file = ../../libs/lib1/lib1.pro
Lib2.file = ../../libs/lib2/lib2.pro
App1.file = ../../app/app1.pro

App1.depends = Lib1 Lib2



Now I want to use different Qt kits to test the compilation. The output directories are created like:



build/build-MyProject-Desktop_Qt_5_15_2_MSVC2019_64bit-Debug
build/build-MyProject-Desktop_Qt_5_12_3_MSVC2017_64bit-Debug


Question:
How can I define in my lib1.pro, lib2.pro and app1.pro files that the objects, moc, ui files etc. are all placed under the respective kit?

app/app1.pro:



OBJECTS_DIR = ???? -> should go to build/build-MyProject-Desktop_Qt_5_15_2_MSVC2019_64bit-Debug/App1
MOC_DIR = ???? -> should go to build/build-MyProject-Desktop_Qt_5_15_2_MSVC2019_64bit-Debug/App1/moc
UI_DIR = ???? -> should go to build/build-MyProject-Desktop_Qt_5_15_2_MSVC2019_64bit-Debug/App1/ui


or rephrased, how do I obtain the OUT_DIR = build-MyProject-Desktop_Qt_5_15_2_MSVC2019_64bit-Debug of the sessions project inside app1.pro ?

d_stranz
8th February 2022, 16:44
Probably not the answer you want, but CMake is good at this type of thing. You can drive it from a script with a command line argument specifying the kit you want to use, then in the CMakeLists.txt file use that argument to generate the paths to the kit and the output files. I use this method to generate multiple builds of a large hierarchy of libraries for three different compiler versions, in 32- and 64-bit, release- and debug- modes.

I don't use Qt Creator, so I am not familiar with how you can automate builds with it. I had thought that all you had to do manually was to change the kit to use when building, and to select the appropriate kits in the kit configuration. I don't think any of this is stored in the .pro files.