Qmake with debug_and_release



  • Hello

    In our project, we build some of the code in debug and release mode, so we use CONFIG += debug_and_release. This works except for one thing: The so/binaries have the same name and are linked at the same location for debug and release builds. Because we usually do make -j3, debug and release builds link into the same file, screwing it up from time to time.

    We have set DESTDIR and OBJECTS_DIR depending on debug or release build. Why does qmake choose to link the so in neither of the two locations? It compiles .o-files into OBJECTS_DIR, then links the so in the directory where .pro file is residing, and only then copies the linked result into destdir.

    Different names would complicate the dependencies inside the project, because I'd need to change the names of our libraries in LIBS depending on debug/release build. Now I just have to change the path.

    I keep hearing about shadow builds, would they be of service in my case? Or can I have qmake rename the target when it is copied to DESTDIR?

    Thanks!
    Christoph



  • Have a look at "this wiki page":http://developer.qt.nokia.com/wiki/How_to_build_a_static_Qt_version_for_Windows_with_gcc, there is a description on how to do that:

    @
    CONFIG(debug, debug|release) {
    mac: TARGET = $$join(TARGET,,,_debug)
    win32: TARGET = $$join(TARGET,,,d)
    }
    @
    You can do the same with the TARGETDIR, but I have no QtCreator here to test the code. Should be something like:

    @
    CONFIG(debug, debug|release) {
    TARGETDIR = ..\debug
    }
    CONFIG(release, debug|release) {
    TARGETDIR = ..\release}
    @



  • What is TARGETDIR? Do you mean DESTDIR?

    When I rename the target, is there some simple way to handle dependencies inside the project? My project creates a bunch of shared objects and uses them for executables. If I start renaming TARGET, wouldn't I have to create something like that for every created shared obj:
    @CONFIG(debug, debug|release) {
    LIBS += myLib1_Debug myLib2_Debug
    }
    CONFIG(release, debug|release) {
    LIBS += myLib1_Release myLib2_Release
    }@



  • DESTDIR sounds reasonable :-)
    Yes, you have to do that renaming io9n you projects.



  • I thought about introducing a special variable for project internal libs. I can then just loop over this variable and "fix" the libraries name. I'm also tending to just give the debug compilation a special name and leave release as is.

    Thanks for the pointers! :)



  • Honestly, you really don't want OBJECTS_DIR to be the same between the builds either! (What happens if you inadvertently get a mixture of debug and release object files...?)

    What I've done in the past is something like:
    @debug_and_release:build_pass {
    CONFIG(debug, debug|release) {
    CURBUILD = debug
    } else {
    CURBUILD = release
    }

    DESTDIR      = $${OUT_PWD}/$${CURBUILD}
    OBJECTS_DIR  = $${OUT_PWD}/$${CURBUILD}/$$dirname($${_PRO_FILE_PWD_})
    MOC_DIR      = $${OBJECTS_DIR}
    UI_DIR       = $${OBJECTS_DIR}
    RCC_DIR      = $${OBJECTS_DIR}
    INCLUDEPATH += $${OBJECTS_DIR}
    LIBS        += -L$${DESTDIR}
    
    unset(CURBUILD)
    

    }@

    I'm not positive those are all actually necessary, but you get the idea anyway.



  • We have different directories for OBJECTS_DIR between debug/release builds, but adding MOC/UI_DIR seems like a good idea.

    And I think it finally "clicked" on shadow building with qmake and that it won't help with my original problem :(. debug_and_release will just drop the two makefile somewhere else than the .pro file, but still link stuff in the PWD of the Makefiles, "overlinking" each other...



  • I'm getting crazy trying to make it work the way I think it should. I must be misunderstanding something.

    I would like to have qmake generate makefiles that produce the output (TARGET) in specific directories for debug and release. I've tried something on the lines of what you (and many others) suggest, but it simply doesn't work for me.

    I have:

    @TEMPLATE = lib
    CONFIG = qt shared debug_and_release build_all

    debug_and_release:build_pass {
    CONFIG(debug, debug|release) {
    TARGET = ColorAnalyzerSimulator_debug
    DESTDIR = debug
    } else {
    TARGET = ColorAnalyzerSimulator_release
    DESTDIR = release
    }
    }
    DEPENDPATH += .
    INCLUDEPATH += .

    Input

    HEADERS += ColorAnalyzerSimulator.h
    SOURCES += ColorAnalyzerSimulator.cpp@

    And I issue the command

    @qmake -spec macx-g++ -o Makefile.mac Simulator.pro@

    and when I look into the Makefile.mac.Debug, TARGET has the default name (Simulator) and DESTDIR is empty!!

    I have tried many variations of these settings but no result. I've also tried a similar thing on Linux and still no result.

    I really hope someone can help.

    [quote author="GordonSchumacher" date="1292262276"]Honestly, you really don't want OBJECTS_DIR to be the same between the builds either! (What happens if you inadvertently get a mixture of debug and release object files...?)

    What I've done in the past is something like:
    @debug_and_release:build_pass {
    CONFIG(debug, debug|release) {
    CURBUILD = debug
    } else {
    CURBUILD = release
    }

    DESTDIR      = $${OUT_PWD}/$${CURBUILD}
    OBJECTS_DIR  = $${OUT_PWD}/$${CURBUILD}/$$dirname($${_PRO_FILE_PWD_})
    MOC_DIR      = $${OBJECTS_DIR}
    UI_DIR       = $${OBJECTS_DIR}
    RCC_DIR      = $${OBJECTS_DIR}
    INCLUDEPATH += $${OBJECTS_DIR}
    LIBS        += -L$${DESTDIR}
    
    unset(CURBUILD)
    

    }@

    I'm not positive those are all actually necessary, but you get the idea anyway.[/quote]


Log in to reply
 

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