CMake: Build a subset of tests when targeting iOS in the CI
Add infrastructure to build cmake auto tests in the CI when targeting iOS. Currently the are only CI instructions for qtbase. More work is needed to make it work for other repos. With this change, we will build a single Widgets application targeting the iOS simulator. We can't target the device SDK in the CI because signing fails due to a missing signing certificate and provisioning profile. The Coin instructions will now set a QT_BUILD_ENVIRONMENT=ci env var whose value will be checked in _qt_internal_test_expect_pass, to ensure we build for the simulator SDK when using a universal Qt. Without this, xcodebuild will try to build with the device SDK and fail to build the project. Pick-to: 6.2 Task-number: QTBUG-95839 Change-Id: Ib39c9527b107b2004746ccbdc9d9d1d658f88c76 Reviewed-by: Tor Arne Vestbø <tor.arne.vestbo@qt.io> Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
This commit is contained in:
parent
1f3949a5a8
commit
80705298ca
@ -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
|
||||
|
@ -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"
|
||||
|
@ -15,6 +15,9 @@ instructions:
|
||||
- condition: property
|
||||
property: target.osVersion
|
||||
equals_value: QEMU
|
||||
- condition: property
|
||||
property: target.osVersion
|
||||
equals_value: IOS_ANY
|
||||
- condition: property
|
||||
property: features
|
||||
contains_value: AndroidTestRun
|
||||
|
@ -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:
|
||||
|
@ -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}")
|
||||
|
||||
|
@ -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)
|
||||
|
@ -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)
|
||||
|
22
tests/auto/cmake/test_build_simple_widget_app/CMakeLists.txt
Normal file
22
tests/auto/cmake/test_build_simple_widget_app/CMakeLists.txt
Normal file
@ -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)
|
||||
|
49
tests/auto/cmake/test_build_simple_widget_app/main.cpp
Normal file
49
tests/auto/cmake/test_build_simple_widget_app/main.cpp
Normal file
@ -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();
|
||||
}
|
Loading…
Reference in New Issue
Block a user