summaryrefslogtreecommitdiffstats
path: root/tests/auto/cmake
diff options
context:
space:
mode:
authorAlexandru Croitor <alexandru.croitor@qt.io>2021-08-19 16:19:21 +0200
committerAlexandru Croitor <alexandru.croitor@qt.io>2021-08-27 01:36:01 +0200
commit40e892bca9f52449dd48db25b58e1ae5f1abcb21 (patch)
treeb347ffab4448cd7ccc5e667a445b2b3ec0156282 /tests/auto/cmake
parent5f6b0f551962e3218044886f69f0d10eaa307ce3 (diff)
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. 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> (cherry picked from commit 80705298ca11587782beed49c4ae55f533cfc0c2) Reviewed-by: Joerg Bornemann <joerg.bornemann@qt.io>
Diffstat (limited to 'tests/auto/cmake')
-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
3 files changed, 86 insertions, 0 deletions
diff --git a/tests/auto/cmake/CMakeLists.txt b/tests/auto/cmake/CMakeLists.txt
index eb23e66fe8..24558bdd91 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();
+}