├── .gitignore ├── .travis.yml ├── MyProject.pro ├── README.md ├── app ├── app.pro └── main.cpp ├── defaults.pri ├── src ├── myclass.cpp ├── myclass.h └── src.pro └── tests ├── main.cpp └── tests.pro /.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 | -------------------------------------------------------------------------------- /.travis.yml: -------------------------------------------------------------------------------- 1 | language: cpp 2 | os: 3 | - linux 4 | branches: 5 | only: 6 | - master 7 | compiler: 8 | - gcc 9 | sudo: required 10 | dist: trusty 11 | addons: 12 | apt: 13 | sources: 14 | - ubuntu-sdk-team 15 | packages: 16 | - qtdeclarative5-dev 17 | script: 18 | - sudo apt-get install catch 19 | - /usr/lib/x86_64-linux-gnu/qt5/bin/qmake 20 | - make 21 | - cd tests 22 | - LD_LIBRARY_PATH=../src ./tests 23 | -------------------------------------------------------------------------------- /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 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | qtcreator-project-structure 2 | =========================== 3 | 4 | [![Build Status](https://travis-ci.org/ComputationalPhysics/qtcreator-project-structure.svg)](https://travis-ci.org/ComputationalPhysics/qtcreator-project-structure) 5 | <-- **Yes**, that's right. The "build" fails. That is, it builds as it is supposed to, but the tests 6 | fail as they are supposed to. This is after all an example repository with a project structure for tests. 7 | 8 | More info here: http://dragly.org/2015/11/24/getting-started-with-unit-tests-in-qt-creator-with-catch/ 9 | -------------------------------------------------------------------------------- /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 | -------------------------------------------------------------------------------- /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 | -------------------------------------------------------------------------------- /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 | -------------------------------------------------------------------------------- /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 | #define CATCH_CONFIG_MAIN // This tells Catch to provide a main() - only do this in one cpp file 2 | #include "catch.hpp" 3 | #include 4 | 5 | TEST_CASE( "MyMath", "[mymath]" ) { 6 | SECTION("Addition") { 7 | MyClass my; 8 | REQUIRE(my.addition(3,4) == 7); 9 | } 10 | } 11 | -------------------------------------------------------------------------------- /tests/tests.pro: -------------------------------------------------------------------------------- 1 | TEMPLATE = app 2 | 3 | include(../defaults.pri) 4 | 5 | CONFIG += console 6 | CONFIG += c++14 7 | CONFIG -= app_bundle 8 | CONFIG -= qt 9 | 10 | SOURCES += main.cpp 11 | 12 | LIBS += -L../src -lmyapp 13 | --------------------------------------------------------------------------------