mardi 13 septembre 2016

Using Qt how can I build a project once for each main()

So, I am starting using unit test using catch with Qt (plain c++, but using qmake with .pro file).

Its a small project with the following files:

DatagramSocket.cpp/h
main.cpp                     - this contains a main() function

But also for the unit test it has the files:

catch.hpp
unittestdatagramsocket.cpp   - this contains a main() function

In my .pro file I can build the project normally like this:

TEMPLATE = app
CONFIG += console c++11
CONFIG -= app_bundle
CONFIG -= qt
# TARGET = unittest-UDPDatagram
TARGET = UDPDatagram

SOURCES += \
    main.cpp \
    DatagramSocket.cpp \
    # unittestdatagramsocket.cpp


HEADERS += \
    DatagramSocket.h \
    catch.hpp

LIBS += \
    -lwsock32
    -lws2_32

And then I can run UDPDatagram.exe - it works.

Or I can build it for unit test like this:

TEMPLATE = app
CONFIG += console c++11
CONFIG -= app_bundle
CONFIG -= qt
TARGET = unittest-UDPDatagram
# TARGET = UDPDatagram

SOURCES += \
    # main.cpp \
    DatagramSocket.cpp \
    unittestdatagramsocket.cpp


HEADERS += \
    DatagramSocket.h \
    catch.hpp

LIBS += \
    -lwsock32
    -lws2_32

Then I can run unittest-UDPDatagram.exe - it works.

What I would like to do is for the build (whether debug or release) to build both every time. Is that possible?

Aucun commentaire:

Enregistrer un commentaire