├── defaults.pri ├── src ├── myclass.cpp ├── myclass.h └── src.pro ├── .gitignore ├── README.md ├── app ├── app.pro └── main.cpp ├── MyProject.pro └── tests ├── tests.pro └── main.cpp /defaults.pri: -------------------------------------------------------------------------------- 1 | INCLUDEPATH += $$PWD/src 2 | SRC_DIR = $$PWD 3 | -------------------------------------------------------------------------------- /src/myclass.cpp: -------------------------------------------------------------------------------- 1 | #include "myclass.h" 2 | 3 | double MyClass::addition(double a, double b) { 4 | return a * b; 5 | } 6 | -------------------------------------------------------------------------------- /src/myclass.h: -------------------------------------------------------------------------------- 1 | #ifndef MYCLASS_H 2 | #define MYCLASS_H 3 | 4 | class MyClass { 5 | public: 6 | double addition(double a, double b); 7 | }; 8 | 9 | #endif // MYCLASS_H 10 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | # Compiled Object files 2 | *.slo 3 | *.lo 4 | *.o 5 | 6 | # Compiled Dynamic libraries 7 | *.so 8 | *.dylib 9 | 10 | # Compiled Static libraries 11 | *.lai 12 | *.la 13 | *.a 14 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | qtcreator-project-structure 2 | =========================== 3 | Code as described in this guide: http://dragly.org/2014/03/13/new-project-structure-for-projects-in-qt-creator-with-unit-tests/ 4 | -------------------------------------------------------------------------------- /app/app.pro: -------------------------------------------------------------------------------- 1 | include(../defaults.pri) 2 | 3 | CONFIG += console 4 | CONFIG -= app_bundle 5 | CONFIG -= qt 6 | 7 | TEMPLATE = app 8 | 9 | SOURCES += main.cpp 10 | 11 | LIBS += -L../src -lmyapp 12 | -------------------------------------------------------------------------------- /MyProject.pro: -------------------------------------------------------------------------------- 1 | TEMPLATE = subdirs 2 | CONFIG+=ordered 3 | SUBDIRS = \ 4 | src \ 5 | app \ 6 | tests 7 | 8 | app.depends = src 9 | tests.depends = src 10 | 11 | OTHER_FILES += \ 12 | defaults.pri 13 | -------------------------------------------------------------------------------- /app/main.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | 4 | using namespace std; 5 | 6 | int main() 7 | { 8 | MyClass adder; 9 | cout << adder.addition(10, 20) << endl; 10 | return 0; 11 | } 12 | -------------------------------------------------------------------------------- /tests/tests.pro: -------------------------------------------------------------------------------- 1 | include(../defaults.pri) 2 | 3 | CONFIG += console 4 | CONFIG -= app_bundle 5 | CONFIG -= qt 6 | 7 | TEMPLATE = app 8 | 9 | SOURCES += main.cpp 10 | 11 | LIBS += -lunittest++ -L../src -lmyapp 12 | -------------------------------------------------------------------------------- /src/src.pro: -------------------------------------------------------------------------------- 1 | include(../defaults.pri) 2 | 3 | CONFIG += console 4 | CONFIG -= app_bundle 5 | CONFIG -= qt 6 | 7 | TEMPLATE = lib 8 | 9 | TARGET = myapp 10 | 11 | SOURCES += myclass.cpp 12 | HEADERS += myclass.h 13 | -------------------------------------------------------------------------------- /tests/main.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | 4 | TEST(MyMath) { 5 | MyClass my; 6 | CHECK(my.addition(3,4) == 7); 7 | } 8 | 9 | int main() 10 | { 11 | return UnitTest::RunAllTests(); 12 | } 13 | --------------------------------------------------------------------------------