summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--coin/instructions/cmake_build_and_upload_test_artifacts.yaml16
-rw-r--r--coin/instructions/cmake_setup_running_tests_env_vars.yaml2
-rw-r--r--coin/instructions/coin_module_test_template_v3.yaml3
-rw-r--r--coin/instructions/coin_qtbase_build_template_v2.yaml2
-rw-r--r--src/corelib/Qt6CTestMacros.cmake32
-rw-r--r--tests/auto/CMakeLists.txt16
-rw-r--r--tests/auto/cmake/CMakeLists.txt15
-rw-r--r--tests/auto/cmake/test_build_simple_widget_app/CMakeLists.txt22
-rw-r--r--tests/auto/cmake/test_build_simple_widget_app/main.cpp49
9 files changed, 153 insertions, 4 deletions
diff --git a/coin/instructions/cmake_build_and_upload_test_artifacts.yaml b/coin/instructions/cmake_build_and_upload_test_artifacts.yaml
index 4b3e3d46bf..1b0288d370 100644
--- a/coin/instructions/cmake_build_and_upload_test_artifacts.yaml
+++ b/coin/instructions/cmake_build_and_upload_test_artifacts.yaml
@@ -23,6 +23,22 @@ instructions:
env_var: COIN_CMAKE_ARGS
equals_value: null
+ # Set an informational build environment env var during the an integration's build phase.
+ # It can be checked during Qt and standalone tests configuration (so configure,
+ # qt-configure-module and qt-internal-configure-tests time).
+ # It's currently needed for some CMake autotest iOS-specific decisions, but it could be useful
+ # for other scenarios as well.
+ #
+ # A related QTEST_ENVIRONMENT env var is set during an integration's test phase.
+ #
+ # Note that CMake auto tests are configured and built during the /test/ phase, NOT the build
+ # phase.
+ # BUT, the options that will be passed to the project cmake invocation in the test phase, are
+ # decided during the /build/ phase.
+ - type: EnvironmentVariable
+ variableName: QT_BUILD_ENVIRONMENT
+ variableValue: "ci"
+
# Inform CMake to build just a minimal set of tests for static Qt builds.
- type: AppendToEnvironmentVariable
variableName: COIN_CMAKE_ARGS
diff --git a/coin/instructions/cmake_setup_running_tests_env_vars.yaml b/coin/instructions/cmake_setup_running_tests_env_vars.yaml
index be0f81dfa7..f2c290a3df 100644
--- a/coin/instructions/cmake_setup_running_tests_env_vars.yaml
+++ b/coin/instructions/cmake_setup_running_tests_env_vars.yaml
@@ -1,5 +1,7 @@
type: Group
instructions:
+ # Informs qtestblacklist.cpp that tests are run in the CI.
+ # A related QT_BUILD_ENVIRONMENT env var is set during an integration's build phase.
- type: EnvironmentVariable
variableName: QTEST_ENVIRONMENT
variableValue: "ci"
diff --git a/coin/instructions/coin_module_test_template_v3.yaml b/coin/instructions/coin_module_test_template_v3.yaml
index fa521f0d54..c3801c2dc9 100644
--- a/coin/instructions/coin_module_test_template_v3.yaml
+++ b/coin/instructions/coin_module_test_template_v3.yaml
@@ -16,6 +16,9 @@ instructions:
property: target.osVersion
equals_value: QEMU
- condition: property
+ property: target.osVersion
+ equals_value: IOS_ANY
+ - condition: property
property: features
contains_value: AndroidTestRun
disable_if:
diff --git a/coin/instructions/coin_qtbase_build_template_v2.yaml b/coin/instructions/coin_qtbase_build_template_v2.yaml
index 503916b417..d6c8bea247 100644
--- a/coin/instructions/coin_qtbase_build_template_v2.yaml
+++ b/coin/instructions/coin_qtbase_build_template_v2.yaml
@@ -26,7 +26,7 @@ instructions:
enable_if:
condition: property
property: target.osVersion
- in_values: [Android_ANY, QEMU]
+ in_values: [Android_ANY, QEMU, IOS_ANY]
enable_if:
condition: or
conditions:
diff --git a/src/corelib/Qt6CTestMacros.cmake b/src/corelib/Qt6CTestMacros.cmake
index 8460600a62..19601c5dec 100644
--- a/src/corelib/Qt6CTestMacros.cmake
+++ b/src/corelib/Qt6CTestMacros.cmake
@@ -132,6 +132,8 @@ endfunction()
#
# GENERATOR: Use a custom generator. When not specified, uses existing CMAKE_GENERATOR value.
#
+# NO_IOS_DEFAULT_ARGS: Skips setting default iOS-specific options like the generator to be used.
+#
# MAKE_PROGRAM: Specify a different make program. Can be useful with a custom make or ninja wrapper.
#
# BUILD_TYPE: Specify a different CMake build type. Defaults to CMAKE_BUILD_TYPE if it is not empty.
@@ -163,6 +165,7 @@ macro(_qt_internal_test_expect_pass _dir)
SIMULATE_IN_SOURCE
NO_CLEAN_STEP
NO_BUILD_PROJECT_ARG
+ NO_IOS_DEFAULT_ARGS
)
set(_test_single_args
BINARY
@@ -182,6 +185,13 @@ macro(_qt_internal_test_expect_pass _dir)
"${_test_multi_args}"
${ARGN}
)
+
+ if(NOT _ARGS_NO_IOS_DEFAULT_ARGS AND IOS)
+ set(_ARGS_NO_BUILD_PROJECT_ARG TRUE)
+ set(_ARGS_GENERATOR Xcode)
+ set(_ARGS_MAKE_PROGRAM xcodebuild)
+ endif()
+
if(_ARGS_TESTNAME)
set(testname "${_ARGS_TESTNAME}")
else()
@@ -250,6 +260,28 @@ macro(_qt_internal_test_expect_pass _dir)
list(APPEND additional_configure_args $ENV{QT_CMAKE_TESTS_ADDITIONAL_CONFIGURE_OPTIONS})
endif()
+ # When building an iOS CMake test in the CI using a universal Qt build, target the simulator
+ # sdk, because the CI currently doesn't have a proper setup for signing device binaries
+ # (missing a working signing certificate and provisioning profile). Allow opt-out.
+ if(IOS)
+ set(osx_arch_count 0)
+ if(QT_OSX_ARCHITECTURES)
+ list(LENGTH QT_OSX_ARCHITECTURES osx_arch_count)
+ endif()
+
+ set(build_environment "")
+ if(DEFINED ENV{QT_BUILD_ENVIRONMENT})
+ set(build_environment "$ENV{QT_BUILD_ENVIRONMENT}")
+ endif()
+ if(build_environment STREQUAL "ci"
+ AND osx_arch_count GREATER_EQUAL 2
+ AND NOT QT_UIKIT_SDK
+ AND NOT QT_NO_IOS_BUILD_ADJUSTMENT_IN_CI)
+ list(APPEND additional_configure_args
+ -DCMAKE_OSX_ARCHITECTURES=x86_64 -DCMAKE_OSX_SYSROOT=iphonesimulator)
+ endif()
+ endif()
+
set(__expect_pass_prefixes "${CMAKE_PREFIX_PATH}")
string(REPLACE ";" "\;" __expect_pass_prefixes "${__expect_pass_prefixes}")
diff --git a/tests/auto/CMakeLists.txt b/tests/auto/CMakeLists.txt
index c16c8b197b..f49e30074b 100644
--- a/tests/auto/CMakeLists.txt
+++ b/tests/auto/CMakeLists.txt
@@ -2,9 +2,19 @@
# Order by dependency [*], then alphabetic. [*] If bugs in part A of
# our source would break tests of part B, then test A before B.
-# Build only corelib and gui tests when targeting uikit (iOS),
-# because the script can't handle the SUBDIRS assignment well.
-if (UIKIT)
+if(UIKIT)
+ # For now, only build CMake auto tests when QT_BUILD_MINIMAL_STATIC_TEST
+ # is a requested (which is basically what CI will build).
+ # The reason is that qt_internal_add_test doesn't use qt_add_executable
+ # at the moment, which means none of the required iOS specific finalizers
+ # are run.
+ if(QT_BUILD_MINIMAL_STATIC_TESTS)
+ add_subdirectory(cmake)
+ return()
+ endif()
+
+ # Build only corelib and gui tests when targeting uikit (iOS),
+ # because the script can't handle the SUBDIRS assignment well.
add_subdirectory(corelib)
if (TARGET Qt::Gui)
add_subdirectory(gui)
diff --git a/tests/auto/cmake/CMakeLists.txt b/tests/auto/cmake/CMakeLists.txt
index cfbf7bafe6..967c21e2d6 100644
--- a/tests/auto/cmake/CMakeLists.txt
+++ b/tests/auto/cmake/CMakeLists.txt
@@ -109,6 +109,21 @@ endif()
include("${_Qt6CTestMacros}")
+if(NOT NO_WIDGETS)
+ _qt_internal_test_expect_pass(test_build_simple_widget_app)
+endif()
+
+# We only support a limited subset of cmake tests when targeting iOS:
+# - Only those that use qt_add_executable (but not add_executable)
+# - and don't try to run the built binaries via BINARY_ARGS option
+# - and don't use internal API like qt_internal_add_*
+#
+# So we can't run binaries in the simulator or on-device, but we at least
+# want build coverage (app linking succeeds).
+if(IOS)
+ return()
+endif()
+
_qt_internal_test_expect_pass(test_umbrella_config)
_qt_internal_test_expect_pass(test_wrap_cpp_and_resources)
if (NOT NO_WIDGETS)
diff --git a/tests/auto/cmake/test_build_simple_widget_app/CMakeLists.txt b/tests/auto/cmake/test_build_simple_widget_app/CMakeLists.txt
new file mode 100644
index 0000000000..daccf5bb80
--- /dev/null
+++ b/tests/auto/cmake/test_build_simple_widget_app/CMakeLists.txt
@@ -0,0 +1,22 @@
+cmake_minimum_required(VERSION 3.16)
+project(ios_projects LANGUAGES CXX)
+
+set(CMAKE_INCLUDE_CURRENT_DIR ON)
+set(CMAKE_AUTOMOC ON)
+
+find_package(Qt6 REQUIRED COMPONENTS Widgets)
+
+function(create_target target)
+ qt_add_executable(${target}
+ main.cpp
+ )
+ set_target_properties(${target} PROPERTIES
+ MACOSX_BUNDLE TRUE
+ )
+ target_link_libraries(${target} PUBLIC
+ Qt::Widgets
+ )
+endfunction()
+
+create_target(simple_widget_app)
+
diff --git a/tests/auto/cmake/test_build_simple_widget_app/main.cpp b/tests/auto/cmake/test_build_simple_widget_app/main.cpp
new file mode 100644
index 0000000000..fa4f75ae7b
--- /dev/null
+++ b/tests/auto/cmake/test_build_simple_widget_app/main.cpp
@@ -0,0 +1,49 @@
+/****************************************************************************
+**
+** Copyright (C) 2021 The Qt Company Ltd.
+** Contact: https://www.qt.io/licensing/
+**
+** This file is part of the QtCore module of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** Commercial License Usage
+** Licensees holding valid commercial Qt licenses may use this file in
+** accordance with the commercial license agreement provided with the
+** Software or, alternatively, in accordance with the terms contained in
+** a written agreement between you and The Qt Company. For licensing terms
+** and conditions see https://www.qt.io/terms-conditions. For further
+** information use the contact form at https://www.qt.io/contact-us.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 3 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL3 included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 3 requirements
+** will be met: https://www.gnu.org/licenses/lgpl-3.0.html.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU
+** General Public License version 2.0 or (at your option) the GNU General
+** Public license version 3 or any later version approved by the KDE Free
+** Qt Foundation. The licenses are as published by the Free Software
+** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3
+** included in the packaging of this file. Please review the following
+** information to ensure the GNU General Public License requirements will
+** be met: https://www.gnu.org/licenses/gpl-2.0.html and
+** https://www.gnu.org/licenses/gpl-3.0.html.
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#include <QApplication>
+#include <QWidget>
+
+int main(int argc, char *argv[])
+{
+ QApplication app(argc, argv);
+ QWidget widget;
+ widget.show();
+ return app.exec();
+}