Qt World Summit: Submit your Presentation

adding git branch name to build directory name

  • Hi -

    I'm working on a project that requires relatively frequent branch changes on github. Most of the time, when I change a branch, I end up rebuilding most of my project (a process that takes about 7-8 minutes). I think if I retained a build directory for each branch, this would not be the case.

    Have any of you done this? My build directory name is based on:

    ../%{JS: Util.asciify("build-%{Project:Name}-%{Kit:FileSystemName}-%{BuildConfig:Name}")}


    EDIT: marking this solved, but it isn't really solved - Christian pointed out that my idea of a solution won't work, so answers are no longer necessary.

  • Lifetime Qt Champion

    @mzimmers said in adding git branch name to build directory name:

    this would not be the case.

    It's also the case since git does/can not restore the file modification time when switching to another branch.
    Simply use more than one source directory.

  • @Christian-Ehrlicher that's not an ideal solution for this particular implementation, in that this would entail changing projects. I'm sure some CMake mavens could work out a way to change source directories without changing projects, but that's above my pay grade.

    But your point about file modification times is certainly valid, so I guess my idea won't work either. Closing this thread accordingly.

  • Lifetime Qt Champion

    You can maybe use something like ccache or inrcedibuild.

  • I'd like to add to @Christian-Ehrlicher's answer: I once played around with ccache, incredibuild and other tools. I ended up using FASTBuild which allows to combine pre-compiled headers, caching, distributed builds and unity files. Caching will help you a lot when you are switching between branches. Unity files merges multiple files into one to cut down on compilation time. The combination of all features can speed up compilation times by a lot. On GitHub you'll find a bunch of scripts that will help you get started with a FASTBuild setup based on an existing qmake file: https://github.com/SimonSchroeder/QMake2Fastbuild.

  • @SimonSchroeder I took a closer look at ccache; it seems like it might be what I need. (The project in question is using cmake.) Is there an option in creator to prefix the actual compile command, or do I need to create soft links per the instructions?


  • I assume that you create a new Kit in Creator which uses ccache as its compiler. (I.e. first add ccache manually as a compiler in the compiler tab, then copy an existing kit and select the corresponding compiler instead.)

Log in to reply