aboutsummaryrefslogtreecommitdiffstats
path: root/tests/manual/minimumSystemVersion/main.cpp
blob: dab68af7e1269be2900adf8584c27380d36391ba (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
#include <stdio.h>
#include <QCoreApplication>
#include <QDebug>
#include <QProcess>

int main(int argc, char *argv[])
{
    QCoreApplication a(argc, argv);
    QTextStream out(stdout);
#ifdef Q_OS_WIN32
    out.setIntegerBase(16);
    out.setNumberFlags(QTextStream::ShowBase);
#ifdef WINVER
    out << "WINVER = " << WINVER;
#else
    out << "WINVER is not defined";
#endif
    endl(out);

    QProcess dumpbin;
    dumpbin.start("dumpbin", QStringList() << "/HEADERS" << a.applicationFilePath());
    dumpbin.waitForStarted();

    out << "dumpbin says...";
    endl(out);

    while (dumpbin.waitForReadyRead()) {
        while (dumpbin.canReadLine()) {
            QString line = dumpbin.readLine();
            if (line.contains("version"))
                out << line.trimmed() << "\n";
        }
    }

    dumpbin.waitForFinished();
#endif

#ifdef Q_OS_MACX
    out.setIntegerBase(10);

    // This gets set by -mmacosx-version-min. If left undefined, defaults to the current OS version.
    out << "__MAC_OS_X_VERSION_MIN_REQUIRED = " << __MAC_OS_X_VERSION_MIN_REQUIRED;
    endl(out);

    // This gets determined by the SDK version you're compiling with
    out << "__MAC_OS_X_VERSION_MAX_ALLOWED = " << __MAC_OS_X_VERSION_MAX_ALLOWED;
    endl(out);

    bool print = false;
    QProcess otool;
    otool.start("otool", QStringList() << "-l" << a.applicationFilePath());
    otool.waitForStarted();

    out << "otool says...";
    endl(out);

    while (otool.waitForReadyRead()) {
        while (otool.canReadLine()) {
            QString line = otool.readLine();
            if (line.contains("LC_VERSION_MIN_MACOSX"))
                print = true;

            if (print && (line.contains("version") || line.contains("sdk"))) {
                out << line.trimmed();
                endl(out);

                if (line.contains("sdk"))
                    print = false;
            }
        }
    }
#endif

    return 0;
}