File: check.cmake.in

package info (click to toggle)
kf6-extra-cmake-modules 6.20.0-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 3,524 kB
  • sloc: python: 668; cpp: 326; ansic: 291; xml: 182; sh: 62; makefile: 8
file content (84 lines) | stat: -rw-r--r-- 2,651 bytes parent folder | download | duplicates (2)
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
#
# SPDX-FileCopyrightText: 2021 Arjen Hiemstra <ahiemstra@heimr.nl>
#
# SPDX-License-Identifier: BSD-3-Clause

set(SOURCE_DIR "@CMAKE_CURRENT_SOURCE_DIR@")
set(INSTALL_DIR "@CMAKE_INSTALL_PREFIX@/test")
set(SHARED "@BUILD_SHARED_LIBS@")
set(QML_ONLY "@QML_ONLY@")
set(DEPENDS "@DEPENDS@")
set(QT_VERSION "@QT_MAJOR_VERSION@")
set(TEST_INSTALL_DIR "${INSTALL_DIR}/Test")

function(check_file_exists file)
    if (NOT EXISTS ${file})
        message(FATAL_ERROR "File \"${file}\" does not exist")
    endif()
endfunction()

function (check_file_contents)
    cmake_parse_arguments(ARGS "" "GENERATED;EXPECTED" "" ${ARGN})

    if (NOT EXISTS "${ARGS_GENERATED}")
        message(FATAL_ERROR "${ARGS_GENERATED} was not generated")
    endif()
    file(READ "${ARGS_GENERATED}" generated_contents)
    if (NOT EXISTS "${ARGS_EXPECTED}")
        message(FATAL_ERROR "Original ${ARGS_EXPECTED} was not found")
    endif()
    file(READ "${ARGS_EXPECTED}" original_contents)
    if (NOT "${generated_contents}" STREQUAL "${original_contents}")
        message(FATAL_ERROR "${generated_file} contains '${generated_contents}' instead of '${original_contents}'")
    endif()
endfunction()

if (SHARED)
    check_file_contents(
        GENERATED "${TEST_INSTALL_DIR}/QmlModule.qml"
        EXPECTED "${SOURCE_DIR}/QmlModule.qml"
    )

    if (QML_ONLY AND NOT DEPENDS)
        check_file_contents(
            GENERATED "${TEST_INSTALL_DIR}/qmldir"
            EXPECTED "${SOURCE_DIR}/qmldir_expected_qmlonly_qt${QT_VERSION}"
        )
    endif()

    if (DEPENDS)
        check_file_contents(
            GENERATED "${TEST_INSTALL_DIR}/qmldir"
            EXPECTED "${SOURCE_DIR}/qmldir_expected_depends_qt${QT_VERSION}"
        )
    endif()

    if (NOT QML_ONLY AND NOT DEPENDS)
        check_file_contents(
            GENERATED "${TEST_INSTALL_DIR}/qmldir"
            EXPECTED "${SOURCE_DIR}/qmldir_expected_full_qt${QT_VERSION}"
        )
    endif()

    if (NOT QML_ONLY OR ${QT_VERSION} GREATER_EQUAL 6)
        if (WIN32)
            check_file_exists("${TEST_INSTALL_DIR}/TestModule.dll")
        else()
            check_file_exists("${TEST_INSTALL_DIR}/libTestModule.so")
        endif()
    endif()
else()
    if (${QT_VERSION} LESS 6)
        if (WIN32)
            check_file_exists("${TEST_INSTALL_DIR}/TestModule.lib")
        else()
            check_file_exists("${TEST_INSTALL_DIR}/libTestModule.a")
        endif()
    else()
        if (WIN32)
            check_file_exists("@MODULE_OUTPUT_PATH@/TestModule.lib")
        else()
            check_file_exists("@MODULE_OUTPUT_PATH@/libTestModule.a")
        endif()
    endif()
endif()