summaryrefslogtreecommitdiffstats
path: root/tests/auto/cmake/cmake.pro
blob: 1de466bcc03f9a9b7b9afeaf9d11f30d0a6529ec (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

CMAKE_VERSION = $$system(cmake --version)

# Cause make to do nothing.
TEMPLATE = subdirs

mac:CONFIG+=insignificant_test

check.commands =
isEmpty(CMAKE_VERSION) {
    message("cmake executable not found. Not running CMake unit tests")
} else {
    CTEST_VERSION = $$system(ctest --version)
    isEmpty(CTEST_VERSION) {
        message("ctest executable not found. Not running CMake unit tests")
    } else {
        CMAKE_VERSION = $$last(CMAKE_VERSION)
        CMAKE_VERSION_MAJOR = $$section(CMAKE_VERSION, ., 0, 0)
        CMAKE_VERSION_MINOR = $$section(CMAKE_VERSION, ., 1, 1)
        CMAKE_VERSION_PATCH = $$section(CMAKE_VERSION, ., 2, 2)

        VERSION_OK =
        greaterThan(CMAKE_VERSION_MAJOR, 2) {
            VERSION_OK = 1
        } else:greaterThan(CMAKE_VERSION_MAJOR, 1):greaterThan(CMAKE_VERSION_MINOR, 8) {
            VERSION_OK = 1
        } else:greaterThan(CMAKE_VERSION_MAJOR, 1):greaterThan(CMAKE_VERSION_MINOR, 7):greaterThan(CMAKE_VERSION_PATCH, 2) {
            VERSION_OK = 1
        }

        isEmpty(VERSION_OK) {
            message("cmake $$CMAKE_VERSION is too old for this test.")
        } else {
            SET = set
            equals(QMAKE_DIR_SEP, "/"):SET = export

            CMAKE_BUILD_TYPE = Debug
            CONFIG(release, debug|release):CMAKE_BUILD_TYPE = Release

            BUILD_DIR = $$replace($$list($$OUT_PWD/build), /, $$QMAKE_DIR_SEP)

            check.commands = \
                cd . && $$SET CMAKE_PREFIX_PATH=$$[QT_INSTALL_PREFIX] && \
                $(MKDIR) $$BUILD_DIR && cd $$BUILD_DIR && \
                cmake $$_PRO_FILE_PWD_ -DCMAKE_BUILD_TYPE=$${CMAKE_BUILD_TYPE} && \
                $(TESTRUNNER) ctest --output-on-failure

        }
    }
}

insignificant_test:!isEmpty(check.commands) {
    check.commands = -$${check.commands}
}

QMAKE_EXTRA_TARGETS *= check