aboutsummaryrefslogtreecommitdiffstats
path: root/tests/auto/cmake/CMakeLists.txt
blob: 48093d749aa2bcec1a8d0d8c42f35a273971afba (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
# This is an automatic test for the CMake configuration files.
# To run it manually,
# 1) mkdir build   # Create a build directory
# 2) cd build
# 3) # Run cmake on this directory
#    `$qt_prefix/bin/qt-cmake ..` or `cmake -DCMAKE_PREFIX_PATH=/path/to/qt ..`
# 4) ctest         # Run ctest

cmake_minimum_required(VERSION 3.14)
project(qtdeclarative_cmake_tests)
enable_testing()

set(required_packages Core)
set(optional_packages Qml Quick)

# Setup the test when called as a completely standalone project.
if(TARGET Qt6::Core)
    # Tests are built as part of the qtsensors build tree.
    # Setup paths so that the Qt packages are found.
    qt_internal_set_up_build_dir_package_paths()
endif()

find_package(Qt6 REQUIRED COMPONENTS ${required_packages})
find_package(Qt6 OPTIONAL_COMPONENTS ${optional_packages})

# Setup common test variables which were previously set by ctest_testcase_common.prf.
set(CMAKE_MODULES_UNDER_TEST "${required_packages}" "${optional_packages}")

foreach(qt_package ${CMAKE_MODULES_UNDER_TEST})
    set(package_name "${QT_CMAKE_EXPORT_NAMESPACE}${qt_package}")
    if(${package_name}_FOUND)
        set(CMAKE_${qt_package}_MODULE_MAJOR_VERSION "${${package_name}_VERSION_MAJOR}")
        set(CMAKE_${qt_package}_MODULE_MINOR_VERSION "${${package_name}_VERSION_MINOR}")
        set(CMAKE_${qt_package}_MODULE_PATCH_VERSION "${${package_name}_VERSION_PATCH}")
    endif()
endforeach()

include("${_Qt6CTestMacros}")

set(module_includes "")

if(TARGET Qt::Qml)
    list(APPEND module_includes
        Qml QQmlEngine
    )
endif()

if(TARGET Qt::Quick)
    list(APPEND module_includes
        Quick QQuickWindow
    )
endif()

_qt_internal_test_module_includes(${module_includes})

# TODO: Plugin targets are not available in shared builds at the moment QTBUG-94066
if(TARGET Qt::Qml AND NOT QT6_IS_SHARED_LIBS_BUILD)
    _qt_internal_test_expect_pass(test_plugins)
endif()

if(TARGET Qt::Quick)
    # _qt_internal_test_expect_pass(qtquickcompiler) # TODO: Replace with 6.2 qml module API
    # _qt_internal_test_expect_pass(qmlimportscanner) # TODO: Replace with 6.2 qml module API
endif()