2

I have a library and I would like it to copy itself to a directory depending upon what configuration i'm in (debug or release). Here is my project file.

#-------------------------------------------------
#
# Project created by QtCreator 2011-08-13T12:48:33
#
#-------------------------------------------------

TARGET = JECLibrary
TEMPLATE = lib

DEFINES += JECLIBRARY_LIBRARY

SOURCES += \
    JECMessageText.cpp \
    JECMessageCombo.cpp \
    JECButton.cpp

HEADERS +=\
        JECLibrary_global.h \
    JECMessageText.h \
    JECMessageCombo.h \
    JECButton.h

CONFIG(debug, debug|release)
{
    DLLDESTDIR += $$quote(../../../Jane/Jane/Build/debug)
    message("Copying to Jane Debug Directory.")
}
CONFIG(release, debug|release)
{
    DLLDESTDIR += $$quote(../../../Jane/Jane/Build/release)
    message("Copying to Jane Release Directory.")
}

FORMS += \
    JECMessageText.ui \
    JECMessageCombo.ui

For some reason, the debug or release DLL are copied to both directories instead of just one. So if I run in release mode, I get the release DLL in both the Debug directory and release directory.

I'm totally confused. Could someone shed some light on this? Thanks

jecjackal
  • 1,407
  • 2
  • 20
  • 35

1 Answers1

5

The opening brace should be on the same line as the condition:

CONFIG(debug, debug|release) {
    DLLDESTDIR += $$quote(../../../Jane/Jane/Build/debug)
    message("Copying to Jane Debug Directory.")
}
CONFIG(release, debug|release) {
    DLLDESTDIR += $$quote(../../../Jane/Jane/Build/release)
    message("Copying to Jane Release Directory.")
}

or

CONFIG(debug, debug|release) {
    DLLDESTDIR += $$quote(../../../Jane/Jane/Build/debug)
    message("Copying to Jane Debug Directory.")
} else {
    DLLDESTDIR += $$quote(../../../Jane/Jane/Build/release)
    message("Copying to Jane Release Directory.")
}

But both messages will be displayed, because the files Makefile.Debug and Makefile.Release are both created when you run qmake (on Windows, or if you add debug_and_release to the CONFIG variable on other OSes).

alexisdm
  • 29,448
  • 6
  • 64
  • 99
  • yes but the resulting dll or exe (depending on what project i'm running) will both be release or debug depending upon what mode its in. So if I run it in debug, the exe in the release folder will be the debug version. How do i stop this? Also i tried the else method and QMake gave me an error. TY for the reply. – jecjackal Aug 20 '11 at 13:46
  • I corrected the first block, and both method seem to be working correctly (the generated Makefiles each contains the correct path). What error did qmake give you ? – alexisdm Aug 20 '11 at 19:31