Warning, /frameworks/extra-cmake-modules/tests/ECMQmlModuleTest/check.cmake.in is written in an unsupported language. File is not indexed.
0001 #
0002 # SPDX-FileCopyrightText: 2021 Arjen Hiemstra <ahiemstra@heimr.nl>
0003 #
0004 # SPDX-License-Identifier: BSD-3-Clause
0005
0006 set(SOURCE_DIR "@CMAKE_CURRENT_SOURCE_DIR@")
0007 set(INSTALL_DIR "@CMAKE_INSTALL_PREFIX@/test")
0008 set(SHARED "@BUILD_SHARED_LIBS@")
0009 set(QML_ONLY "@QML_ONLY@")
0010 set(DEPENDS "@DEPENDS@")
0011 set(QT_VERSION "@QT_MAJOR_VERSION@")
0012 set(TEST_INSTALL_DIR "${INSTALL_DIR}/Test")
0013
0014 function(check_file_exists file)
0015 if (NOT EXISTS ${file})
0016 message(FATAL_ERROR "File \"${file}\" does not exist")
0017 endif()
0018 endfunction()
0019
0020 function (check_file_contents)
0021 cmake_parse_arguments(ARGS "" "GENERATED;EXPECTED" "" ${ARGN})
0022
0023 if (NOT EXISTS "${ARGS_GENERATED}")
0024 message(FATAL_ERROR "${ARGS_GENERATED} was not generated")
0025 endif()
0026 file(READ "${ARGS_GENERATED}" generated_contents)
0027 if (NOT EXISTS "${ARGS_EXPECTED}")
0028 message(FATAL_ERROR "Original ${ARGS_EXPECTED} was not found")
0029 endif()
0030 file(READ "${ARGS_EXPECTED}" original_contents)
0031 if (NOT "${generated_contents}" STREQUAL "${original_contents}")
0032 message(FATAL_ERROR "${generated_file} contains '${generated_contents}' instead of '${original_contents}'")
0033 endif()
0034 endfunction()
0035
0036 if (SHARED)
0037 check_file_contents(
0038 GENERATED "${TEST_INSTALL_DIR}/QmlModule.qml"
0039 EXPECTED "${SOURCE_DIR}/QmlModule.qml"
0040 )
0041
0042 if (QML_ONLY AND NOT DEPENDS)
0043 check_file_contents(
0044 GENERATED "${TEST_INSTALL_DIR}/qmldir"
0045 EXPECTED "${SOURCE_DIR}/qmldir_expected_qmlonly_qt${QT_VERSION}"
0046 )
0047 endif()
0048
0049 if (DEPENDS)
0050 check_file_contents(
0051 GENERATED "${TEST_INSTALL_DIR}/qmldir"
0052 EXPECTED "${SOURCE_DIR}/qmldir_expected_depends_qt${QT_VERSION}"
0053 )
0054 endif()
0055
0056 if (NOT QML_ONLY AND NOT DEPENDS)
0057 check_file_contents(
0058 GENERATED "${TEST_INSTALL_DIR}/qmldir"
0059 EXPECTED "${SOURCE_DIR}/qmldir_expected_full_qt${QT_VERSION}"
0060 )
0061 endif()
0062
0063 if (NOT QML_ONLY OR ${QT_VERSION} GREATER_EQUAL 6)
0064 if (WIN32)
0065 check_file_exists("${TEST_INSTALL_DIR}/TestModule.dll")
0066 else()
0067 check_file_exists("${TEST_INSTALL_DIR}/libTestModule.so")
0068 endif()
0069 endif()
0070 else()
0071 if (${QT_VERSION} LESS 6)
0072 if (WIN32)
0073 check_file_exists("${TEST_INSTALL_DIR}/TestModule.lib")
0074 else()
0075 check_file_exists("${TEST_INSTALL_DIR}/libTestModule.a")
0076 endif()
0077 else()
0078 if (WIN32)
0079 check_file_exists("@MODULE_OUTPUT_PATH@/TestModule.lib")
0080 else()
0081 check_file_exists("@MODULE_OUTPUT_PATH@/libTestModule.a")
0082 endif()
0083 endif()
0084 endif()