mardi 24 mars 2015

QT Creator: How to generate the library and testing executable for a custom widget

There is the following files:



MyWidget
|- MyWidget.cpp
|- MyWidget.hpp
|- MyWidget_UnitTest.cpp


I would like to generate at once following files:



  1. MyWidget.dll (or equivalent for non windows OS)

  2. MyWidget_UnitTest.exe (or equivalent for non windows OS)


So it is easy to test the widget for bugs, but also to have the result inside further widgets or projects.


I tried to manipulate the .pro file, but with no success:



# ONLY TESTING UNIT
QT += core gui
greaterThan(QT_MAJOR_VERSION, 4): QT += widgets
TARGET = MyWidget_UnitTest
TEMPLATE = app
SOURCES +=\
MyWidget.cpp \
MyWidget_UnitTest.cpp
HEADERS += \
MyWidget.hpp
CONFIG += c++11 -Wall

#ONLY LIB
QT += core gui
greaterThan(QT_MAJOR_VERSION, 4): QT += widgets
TARGET = MyWidget_UnitTest
TEMPLATE = lib
SOURCES +=\
MyWidget.cpp \
MyWidget_UnitTest.cpp
HEADERS += \
MyWidget.hpp
CONFIG += c++11 -Wall
CONFIG += dll


I am unable to merge both into a single project.


Possibly more result could be added: static vs dynamic lib, etc.


Aucun commentaire:

Enregistrer un commentaire