Declaring bin and build directories



  • I have a project with subdirs app, src and tests. When I compile the project, I would like for the executable to go to bin subdirectory and all the object and moc files to go to build subdirectory. How do I do this? I would like it to work so that if I clone the project to another computer, it will automatically compile to these directories without having to change any settings.

    I have also another question. When I hit run in qt creator, it only runs the tests. Can I somehow make it run the tests and the app?


  • Moderators

    You can specify various output paths in the .pro file, for example:

    DESTDIR = ../bin
    MOC_DIR = ../build
    RCC_DIR = ../build
    UI_DIR = ../build
    OBJECTS_DIR = ../build


  • @Chris-Kawa Yes that's it thank you. Now how would I specify different build folders for release and debug? I.e. build/release and build/debug.


  • Moderators

    One way to do this:

    CONFIG(debug, debug|release) {
        MYVARIABLE= debug
    }
    CONFIG(release, debug|release) {
        MYVARIABLE= release
    }
    
    DESTDIR = ../bin/$$MYVARIABLE
    MOC_DIR = ../build/$$MYVARIABLE
    ...


  • Thank you!


Log in to reply
 

Looks like your connection to Qt Forum was lost, please wait while we try to reconnect.