aboutsummaryrefslogtreecommitdiffstats
path: root/share/qtcreator/templates/wizards/autotest/files/tst.qbs
blob: a33cecd5990bf9941f71cf2217a7f1aa5b0afa7c (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
import qbs
@if "%{TestFrameWork}" == "GTest"
import qbs.Environment
import "googlecommon.js" as googleCommon
@endif
@if "%{TestFrameWork}" == "BoostTest"
import qbs.Environment
import qbs.File
@endif
@if "%{TestFrameWork}" == "Catch2"
import qbs.Environment
import qbs.File
@endif

CppApplication {
@if "%{TestFrameWork}" == "QtTest"
    Depends { name: "Qt.testlib" }
@if "%{RequireGUI}" == "false"
    consoleApplication: true
@else
    Depends { name: "Qt.gui" }
@endif
    files: [
       "%{TestCaseFileWithCppSuffix}"
    ]
@else
    consoleApplication: true
@endif

@if "%{TestFrameWork}" == "GTest"
    property string googletestDir: {
        if (typeof Environment.getEnv("GOOGLETEST_DIR") === 'undefined') {
            if ("%{GTestRepository}" === "" && googleCommon.getGTestDir(qbs, undefined) !== "") {
                console.warn("Using googletest from system")
            } else {
                console.warn("Using googletest src dir specified at Qt Creator wizard")
                console.log("set GOOGLETEST_DIR as environment variable or Qbs property to get rid of this message")
            }
            return "%{GTestRepository}"
        } else {
            return Environment.getEnv("GOOGLETEST_DIR")
        }
    }

@if "%{GTestCXX11}" == "true"
    cpp.cxxLanguageVersion: "c++11"
    cpp.defines: [ "GTEST_LANG_CXX11" ]
@endif
    cpp.dynamicLibraries: {
        if (qbs.hostOS.contains("windows")) {
            return [];
        } else {
            return [ "pthread" ];
        }
    }


    cpp.includePaths: [].concat(googleCommon.getGTestIncludes(qbs, googletestDir))
                        .concat(googleCommon.getGMockIncludes(qbs, googletestDir))

    files: [
        "%{MainCppName}",
        "%{TestCaseFileWithHeaderSuffix}",
    ].concat(googleCommon.getGTestAll(qbs, googletestDir))
     .concat(googleCommon.getGMockAll(qbs, googletestDir))
@endif
@if "%{TestFrameWork}" == "QtQuickTest"
    Depends { name: "cpp" }
    Depends { name: "Qt.core" }
    Depends {
        condition: Qt.core.versionMajor > 4
        name: "Qt.qmltest"
    }

    Group {
        name: "main application"
        files: [ "%{MainCppName}" ]
    }

    Group {
        name: "qml test files"
        files: "%{TestCaseFileWithQmlSuffix}"
    }

    cpp.defines: base.concat("QUICK_TEST_SOURCE_DIR=\\"" + path + "\\"")
@endif
@if "%{TestFrameWork}" == "BoostTest"
    type: "application"

    property string boostIncDir: {
        if (typeof Environment.getEnv("BOOST_INCLUDE_DIR") !== 'undefined')
            return Environment.getEnv("BOOST_INCLUDE_DIR");
        return "%{BoostIncDir}"; // set by Qt Creator wizard
    }

    Properties {
        condition: boostIncDir && File.exists(boostIncDir)
        cpp.includePaths: [boostIncDir];
    }

    condition: {
        if (!boostIncDir)
            console.log("BOOST_INCLUDE_DIR is not set, assuming Boost can be "
                        + "found automatically in your system");
        return true;
    }

    files: [ "%{MainCppName}" ]

@endif
@if "%{TestFrameWork}" == "Catch2"
    type: "application"

@if "%{Catch2NeedsQt}" == "true"
    Depends { name: "Qt.gui" }
@endif

    property string catchIncDir: {
        if (typeof Environment.getEnv("CATCH_INCLUDE_DIR") !== 'undefined')
            return Environment.getEnv("CATCH_INCLUDE_DIR");
        return "%{CatchIncDir}"; // set by Qt Creator wizard
    }

    Properties {
        condition: catchIncDir && File.exists(catchIncDir)
        cpp.includePaths: [catchIncDir];
    }

    condition: {
        if (!catchIncDir)
            console.log("CATCH_INCLUDE_DIR is not set, assuming Catch2 can be "
                        + "found automatically in your system");
        return true;
    }

    files: [
        "%{MainCppName}",
        "%{TestCaseFileWithCppSuffix}",
    ]
@endif

}