diff options
author | Alexandru Croitor <alexandru.croitor@qt.io> | 2021-06-24 18:40:24 +0200 |
---|---|---|
committer | Qt Cherry-pick Bot <cherrypick_bot@qt-project.org> | 2021-06-25 16:24:23 +0000 |
commit | 2c7a69b4010ccf9b5507951d4badc85dbf87f287 (patch) | |
tree | 6f3259f2e2a59101f4d4c58c43faac56cd7b76b0 /tests | |
parent | 96d66e5ffc8456ff5c5b499ff82707b46932076f (diff) |
CMake: Restore CMake auto tests
This is mainly a preparation change to allow adding new tests.
Some of the tests still need to be ported to use the new 6.2 QML
module creation API, because running qt_add_resources doesn't process
QML files anymore.
Change-Id: I249931eb2b4de32a204283ae1bf8698ec5a48980
Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
Reviewed-by: Alexey Edelev <alexey.edelev@qt.io>
Reviewed-by: Joerg Bornemann <joerg.bornemann@qt.io>
(cherry picked from commit 0170258ca0c5c116df3e598b45ff3c29d16e8803)
Reviewed-by: Qt Cherry-pick Bot <cherrypick_bot@qt-project.org>
Diffstat (limited to 'tests')
-rw-r--r-- | tests/auto/CMakeLists.txt | 5 | ||||
-rw-r--r-- | tests/auto/cmake/CMakeLists.txt | 99 | ||||
-rw-r--r-- | tests/auto/cmake/test_plugins/CMakeLists.txt | 17 |
3 files changed, 69 insertions, 52 deletions
diff --git a/tests/auto/CMakeLists.txt b/tests/auto/CMakeLists.txt index 6701df3016..3d89d8b396 100644 --- a/tests/auto/CMakeLists.txt +++ b/tests/auto/CMakeLists.txt @@ -7,10 +7,7 @@ if(TARGET Qt::Quick) endif() add_subdirectory(core) add_subdirectory(qmldevtools) -# special case begin -# add_subdirectory(cmake) -# add_subdirectory(installed_cmake) -# special case end +add_subdirectory(cmake) add_subdirectory(toolsupport) if(NOT UIKIT) add_subdirectory(qmltest) diff --git a/tests/auto/cmake/CMakeLists.txt b/tests/auto/cmake/CMakeLists.txt index de776e9dd1..48093d749a 100644 --- a/tests/auto/cmake/CMakeLists.txt +++ b/tests/auto/cmake/CMakeLists.txt @@ -1,41 +1,64 @@ -cmake_minimum_required(VERSION 2.8) - -project(qmake_cmake_files) +# 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() -find_package(Qt5Core REQUIRED) - -include("${_Qt5CTestMacros}") - -test_module_includes( - Qml QQmlEngine - Quick QQuickWindow -) - -expect_pass(test_plugins) - -add_test(qtquickcompiler ${CMAKE_CTEST_COMMAND} - --build-and-test - "${CMAKE_CURRENT_SOURCE_DIR}/qtquickcompiler/" - "${CMAKE_CURRENT_BINARY_DIR}/qtquickcompiler" - --build-config "${CMAKE_BUILD_TYPE}" - --build-generator ${CMAKE_GENERATOR} - --build-makeprogram ${CMAKE_MAKE_PROGRAM} - --build-project qqc_test - --build-options "-DCMAKE_PREFIX_PATH=${CMAKE_PREFIX_PATH}" ${BUILD_OPTIONS_LIST} - --test-command qqc_test - -) - -add_test(qmlimportscanner ${CMAKE_CTEST_COMMAND} - --build-and-test - "${CMAKE_CURRENT_SOURCE_DIR}/qmlimportscanner/" - "${CMAKE_CURRENT_BINARY_DIR}/qmlimportscanner" - --build-config "${CMAKE_BUILD_TYPE}" - --build-generator ${CMAKE_GENERATOR} - --build-makeprogram ${CMAKE_MAKE_PROGRAM} - --build-project qis_test - --build-options "-DCMAKE_PREFIX_PATH=${CMAKE_PREFIX_PATH}" ${BUILD_OPTIONS_LIST} - --test-command qis_test -) +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() diff --git a/tests/auto/cmake/test_plugins/CMakeLists.txt b/tests/auto/cmake/test_plugins/CMakeLists.txt index a23f9c332c..4d41ec693f 100644 --- a/tests/auto/cmake/test_plugins/CMakeLists.txt +++ b/tests/auto/cmake/test_plugins/CMakeLists.txt @@ -1,16 +1,13 @@ -project(test_plugins) +cmake_minimum_required(VERSION 3.14) -cmake_minimum_required(VERSION 2.8) -if (POLICY CMP0056) - cmake_policy(SET CMP0056 NEW) -endif() +project(check_for_existence_of_plugin_targets) -find_package(Qt5Qml REQUIRED) +find_package(Qt6 COMPONENTS REQUIRED Qml) # See QTBUG-43438 -if (NOT TARGET Qt5::QTcpServerConnectionFactory) - message(SEND_ERROR "Qt5::QTcpServerConnectionFactory does not exist") +if(NOT TARGET Qt6::QTcpServerConnectionFactoryPlugin) + message(FATAL_ERROR "Qt6::QTcpServerConnectionFactoryPlugin does not exist") endif() -if (NOT TARGET Qt5::QLocalClientConnectionFactory) - message(SEND_ERROR "Qt5::QLocalClientConnectionFactory does not exist") +if(NOT TARGET Qt6::QLocalClientConnectionFactoryPlugin) + message(FATAL_ERROR "Qt6::QLocalClientConnectionFactoryPlugin does not exist") endif() |