I have a fairly large application that I need to create / support, so I decided to use googletest and for convenience I wanted to structure the test and application code as subprojects. I created a super project with the following structure:
SuperProject - SuperProject.pro - defaults.pri - Application -- Application.pro -- Sources -- main.cpp -- Headers - Tests -- Tests.pro -- main.cpp -- Sources -- Headers
From superproject.pro
TEMPLATE = subdirs CONFIG += ordered SUBDIRS += \ Application \ Tests \ OTHER_FILES += \ defaults.pri
With defaults.pri
INCLUDEPATH += $$PWD/Application
And Tests.pro
include(gtest_dependency.pri) include(../defaults.pri) TEMPLATE = app QT += core CONFIG += console c++11 CONFIG -= app_bundle CONFIG += thread HEADERS += tst_redoundo.h SOURCES += main.cpp
And Application.pro
include(ExcelLib/qtxlsx.pri) include(../defaults.pri) TEMPLATE = app QT += qml quick CONFIG += c++14 static {
: w
The application compiles and works fine on its own, as does the test code. But as soon as I try to include something from the application, for example,
#include "util.h" #include "tst_redoundo.h" #include <gtest/gtest.h> int main(int argc, char *argv[]) { Util u; ::testing::InitGoogleTest(&argc, argv); return RUN_ALL_TESTS(); }
The code compiles, but does not bind to, an undefined reference to the Util constructor. Most tutorials with the same setup as mine assume that the pattern that the test code links are associated with is TEMPLATE = lib , but I can't change the pattern from app to lib for the application. How can I link the linker to the application?
c ++ qt
arynaq
source share