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 
0012 function(check_file_exists file)
0013     if (NOT EXISTS ${file})
0014         message(FATAL_ERROR "File \"${file}\" does not exist")
0015     endif()
0016 endfunction()
0017 
0018 function (check_file_contents)
0019     cmake_parse_arguments(ARGS "" "GENERATED;EXPECTED" "" ${ARGN})
0020 
0021     if (NOT EXISTS "${ARGS_GENERATED}")
0022         message(FATAL_ERROR "${ARGS_GENERATED} was not generated")
0023     endif()
0024     file(READ "${ARGS_GENERATED}" generated_contents)
0025     if (NOT EXISTS "${ARGS_EXPECTED}")
0026         message(FATAL_ERROR "Original ${ARGS_EXPECTED} was not found")
0027     endif()
0028     file(READ "${ARGS_EXPECTED}" original_contents)
0029     if (NOT "${generated_contents}" STREQUAL "${original_contents}")
0030         message(FATAL_ERROR "${generated_file} contains '${generated_contents}' instead of '${original_contents}'")
0031     endif()
0032 endfunction()
0033 
0034 if (SHARED)
0035     check_file_contents(
0036         GENERATED "${INSTALL_DIR}/Test/QmlModule.qml"
0037         EXPECTED "${SOURCE_DIR}/QmlModule.qml"
0038     )
0039 
0040     if (NOT QML_ONLY AND NOT DEPENDS)
0041         if (WIN32)
0042             check_file_exists("${INSTALL_DIR}/Test/TestModule.dll")
0043         else()
0044             check_file_exists("${INSTALL_DIR}/Test/libTestModule.so")
0045         endif()
0046 
0047         check_file_contents(
0048             GENERATED "${INSTALL_DIR}/Test/qmldir"
0049             EXPECTED "${SOURCE_DIR}/qmldir_expected_full"
0050         )
0051     endif()
0052 
0053     if (QML_ONLY AND NOT DEPENDS)
0054         check_file_contents(
0055             GENERATED "${INSTALL_DIR}/Test/qmldir"
0056             EXPECTED "${SOURCE_DIR}/qmldir_expected_qmlonly"
0057         )
0058     endif()
0059 
0060     if (DEPENDS)
0061         check_file_contents(
0062             GENERATED "${INSTALL_DIR}/Test/qmldir"
0063             EXPECTED "${SOURCE_DIR}/qmldir_expected_depends"
0064         )
0065     endif()
0066 else()
0067     if (WIN32)
0068         check_file_exists("${INSTALL_DIR}/Test/TestModule.lib")
0069     else()
0070         check_file_exists("${INSTALL_DIR}/Test/libTestModule.a")
0071     endif()
0072 endif()