diff options
Diffstat (limited to 'tests/auto/cmake/CMakeLists.txt')
-rw-r--r-- | tests/auto/cmake/CMakeLists.txt | 68 |
1 files changed, 44 insertions, 24 deletions
diff --git a/tests/auto/cmake/CMakeLists.txt b/tests/auto/cmake/CMakeLists.txt index bf69829fb..2533156d5 100644 --- a/tests/auto/cmake/CMakeLists.txt +++ b/tests/auto/cmake/CMakeLists.txt @@ -1,48 +1,68 @@ +# Copyright (C) 2022 The Qt Company Ltd. +# SPDX-License-Identifier: BSD-3-Clause # This is an automatic test for the CMake configuration files. -# To run it, +# To run it manually, # 1) mkdir build # Create a build directory # 2) cd build -# 3) cmake .. # Run cmake on this directory. +# 3) # Run cmake on this directory +# `$qt_prefix/bin/qt-cmake ..` or `cmake -DCMAKE_PREFIX_PATH=/path/to/qt ..` # 4) ctest # Run ctest +# 5) ctest -V -R test_add_translation_macro # Run single test # # The expected output is something like: # -# Start 1: test_translation_macros -# 1/2 Test #1: test_translation_macros .......... Passed 0.98 sec -# Start 2: test_modules -# 2/2 Test #2: test_modules ..................... Passed 1.41 sec +# 1/2 Test #1: test_uiplugin_module ............. Passed 6.33 sec +# Start 4: test_uiplugin_via_designer +# 2/2 Test #2: test_uiplugin_via_designer ....... Passed 9.32 sec +# # # Note that if Qt is not installed, or if it is installed to a # non-standard prefix, the environment variable CMAKE_PREFIX_PATH # needs to be set to the installation prefix or build prefix of Qt # before running these tests. +cmake_minimum_required(VERSION 3.16) -cmake_minimum_required(VERSION 2.8) - -project(qmake_cmake_files) +project(qttools_cmake_tests) enable_testing() -find_package(Qt5Core REQUIRED) +set(required_packages Core) +set(optional_packages Widgets LinguistTools) -include("${_Qt5CTestMacros}") - -if(NOT CMAKE_CROSSCOMPILING) - expect_pass(test_create_translation_macro) - expect_pass(test_add_translation_macro) +# Setup the test when called as a completely standalone project. +if(TARGET Qt6::Core) + # Tests are built as part of the qtbase build tree. + # Setup paths so that the Qt packages are found, similar to examples. + qt_internal_set_up_build_dir_package_paths() endif() -if (NOT NO_WIDGETS) - test_module_includes( - Designer QFormBuilder - Help QHelpSearchQuery - UiTools QUiLoader - ) +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}") +foreach(qt_package ${optional_packages}) + set(package_name "${QT_CMAKE_EXPORT_NAMESPACE}${qt_package}") + list(APPEND CMAKE_MODULES_UNDER_TEST "${qt_package}") +endforeach() - expect_pass(test_uiplugin_via_designer) - if (NOT CMAKE_VERSION VERSION_LESS 3.0) - expect_pass(test_uiplugin_module) +foreach(qt_package ${CMAKE_MODULES_UNDER_TEST}) + 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}") + +if (TARGET Qt6::Widgets) + _qt_internal_test_expect_pass(test_uiplugin_module) + _qt_internal_test_expect_pass(test_uiplugin_via_designer) +endif() + +if(TARGET Qt6::lupdate) + add_subdirectory(linguist) endif() |