aboutsummaryrefslogtreecommitdiffstats
path: root/tests/auto/blackbox/testdata/exports-cmake/find-cmake.qbs
blob: 52f388966670b4880edfd3216f09b9d6a5e86400 (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
import qbs.Probes

Product {
    Depends { name: "cpp" }

    Probes.BinaryProbe {
        id: cmakeProbe
        names: "cmake"
    }

    Probes.BinaryProbe {
        id: ninjaProbe
        names: ["ninja"]
    }

    property bool test: {
        var data = {
            cmakeFound: cmakeProbe.found,
            cmakeFilePath: cmakeProbe.filePath,
            crossCompiling: qbs.targetPlatform !== qbs.hostPlatform,
            installPrefix: qbs.installPrefix
        };
        data.buildEnv = {}
        Object.assign(data.buildEnv, cpp.buildEnv);  // deep copy buildEnv from a probe
        if (qbs.toolchain.includes("gcc")) {
            data.buildEnv["CC"] = cpp.cCompilerName;
            data.buildEnv["CXX"] = cpp.cxxCompilerName;
        } else {
            data.buildEnv["CC"] = cpp.compilerName;
            data.buildEnv["CXX"] = cpp.compilerName;
        }

        if (ninjaProbe.found) {
            data.generator = "Ninja";
        } else {
            if (qbs.toolchain.includes("msvc")) {
                data.generator = "NMake Makefiles"
            } else if (qbs.toolchain.includes("mingw")) {
                data.generator = "MinGW Makefiles";
            } else  if (qbs.toolchain.includes("gcc")) {
                data.generator = "Unix Makefiles";
            }
        }
        console.info("---" + JSON.stringify(data) + "---");
    }
}