Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Qt Creator, build dir with branch name

Based on several kits I am using, the Qt Creator build directory is derived from

  • project name
  • Qt version
  • compiler
  • build configuration: debug / release

Example: build-client-Qt_5_3_0_fooProject_MINGW_32bit_qmake_MinGW22-Debug

My problem is, if I switch my git branch, I always have to recompile from scratch (time consuming). I wonder, if it might be possible to include the branch name, so I can keep different builds at the same time

=> Possible build dirs:

  • build-client-Qt_5_3_0_fooProject_MINGW_32bit_qmake_MinGW22-Debug_master
  • build-client-Qt_5_3_0_fooProject_MINGW_32bit_qmake_MinGW22-Debug_branchbar

Or is there a chance to add a third build configuration, e.g. Debug_others, resulting in a build directory such as

build-client-Qt_5_3_0_fooProject_MINGW_32bit_qmake_MinGW22-Debug_others

like image 436
Horst Walter Avatar asked Nov 01 '22 20:11

Horst Walter


1 Answers

You can manage builds in Project tab on the left. If you want to have build automaticaly switching dirs depending on the branch you are on, on each branch you would have to edit *.pro.user file. Find line:

<value type="QString" key="ProjectExplorer.BuildConfiguration.BuildDirectory">
    /home/etc/etc/etc
</value>

And change the directory to the one you want it to be (ex. edit the ending part of the value). On a different branch have it point somewhere else. Thus changing branches will change the shadow build directory.

P.S. If you have several builds (like debug, release) you need to check if the build directory you're editing is the one you want. Check activeBuildConfiguration number and edit it's directory only (the number of build is usually a line above the one I showed), or change activeBuildConfiguration to 0 and the first build directory.

It's a bit knotty but I think manageable.

like image 64
prajmus Avatar answered Nov 10 '22 00:11

prajmus