diff --git a/src/corelib/Qt6AndroidMacros.cmake b/src/corelib/Qt6AndroidMacros.cmake index 46463c8f4f..645be263be 100644 --- a/src/corelib/Qt6AndroidMacros.cmake +++ b/src/corelib/Qt6AndroidMacros.cmake @@ -1076,6 +1076,12 @@ function(_qt_internal_configure_android_multiabi_target target) "-DCMAKE_CXX_COMPILER_LAUNCHER=${compiler_launcher}") endif() + unset(user_cmake_args) + foreach(var IN LISTS QT_ANDROID_MULTI_ABI_FORWARD_VARS) + string(REPLACE ";" "$" var_value "${${var}}") + list(APPEND user_cmake_args "-D${var}=${var_value}") + endforeach() + set(missing_qt_abi_toolchains "") set(previous_copy_apk_dependencies_target ${target}) # Create external projects for each android ABI except the main one. @@ -1108,6 +1114,7 @@ function(_qt_internal_configure_android_multiabi_target target) "-DQT_INTERNAL_ANDROID_MULTI_ABI_BINARY_DIR=${CMAKE_BINARY_DIR}" "${config_arg}" "${extra_cmake_args}" + "${user_cmake_args}" "-B" "${android_abi_build_dir}" "-S" "${CMAKE_SOURCE_DIR}" EXCLUDE_FROM_ALL TRUE diff --git a/tests/auto/CMakeLists.txt b/tests/auto/CMakeLists.txt index a7d8964860..a310f422d0 100644 --- a/tests/auto/CMakeLists.txt +++ b/tests/auto/CMakeLists.txt @@ -27,6 +27,7 @@ endif() # Limit set of tests to run for Android multi-ABI Qt builds. if(QT_BUILD_MINIMAL_ANDROID_MULTI_ABI_TESTS) + add_subdirectory(cmake) add_subdirectory(corelib/kernel/qmath) add_subdirectory(widgets/effects/qpixmapfilter) add_subdirectory(corelib/platform) diff --git a/tests/auto/cmake/CMakeLists.txt b/tests/auto/cmake/CMakeLists.txt index 42cbc03138..fac5cb460e 100644 --- a/tests/auto/cmake/CMakeLists.txt +++ b/tests/auto/cmake/CMakeLists.txt @@ -71,7 +71,8 @@ enable_testing() # flag. Notably -rpath is specified which should implicitly enable -rpath-link, but that # doesn't seem to be the case. # Until this is figured out, disable the tests when cross-compiling to Linux. -if(UNIX AND NOT APPLE AND NOT WIN32 AND CMAKE_CROSSCOMPILING AND NOT QT_ENABLE_CMAKE_BOOT2QT_TESTS) +if(UNIX AND NOT APPLE AND NOT WIN32 AND CMAKE_CROSSCOMPILING AND NOT QT_ENABLE_CMAKE_BOOT2QT_TESTS + AND NOT QT_BUILD_MINIMAL_ANDROID_MULTI_ABI_TESTS) message(STATUS "Running CMake tests is disabled when cross-compiling to Linux / Boot2Qt.") return() endif() @@ -113,6 +114,43 @@ endif() include("${_Qt6CTestMacros}") +# Test only multi-abi specific functionality when QT_BUILD_MINIMAL_ANDROID_MULTI_ABI_TESTS is ON. +# Qt::Gui is the prerequisite for all Android tests. +if(QT_BUILD_MINIMAL_ANDROID_MULTI_ABI_TESTS AND NOT NO_GUI) + unset(multi_abi_vars) + foreach(abi IN_LISTS QT_ANDROID_ABIS) + list(APPEND multi_abi_vars "-DQT_PATH_ANDROID_ABI_${abi}=${QT_PATH_ANDROID_ABI_${abi}}") + endforeach() + if(QT_ANDROID_BUILD_ALL_ABIS) + list(APPEND multi_abi_vars "-DQT_ANDROID_BUILD_ALL_ABIS=${QT_ANDROID_BUILD_ALL_ABIS}") + endif() + + list(APPEND multi_abi_vars "-DQT_HOST_PATH=${QT_HOST_PATH}") + + set(multi_abi_forward_vars + TEST_SINGLE_VALUE_ARG + TEST_SPACES_VALUE_ARG + TEST_LIST_VALUE_ARG + TEST_ESCAPING_VALUE_ARG + ) + string(REPLACE ";" "[[;]]" multi_abi_forward_vars "${multi_abi_forward_vars}") + + set(single_value "TestValue") + set(list_value "TestValue[[;]]TestValue2[[;]]TestValue3") + set(escaping_value "TestValue\\\\[[;]]TestValue2\\\\[[;]]TestValue3") + set(spaces_value "TestValue TestValue2 TestValue3") + _qt_internal_test_expect_pass(test_android_multi_abi_forward_vars + BUILD_OPTIONS + ${multi_abi_vars} + "-DQT_ANDROID_MULTI_ABI_FORWARD_VARS=${multi_abi_forward_vars}" + "-DTEST_SINGLE_VALUE_ARG=${single_value}" + "-DTEST_LIST_VALUE_ARG=${list_value}" + "-DTEST_ESCAPING_VALUE_ARG=${escaping_value}" + "-DTEST_SPACES_VALUE_ARG=${spaces_value}" + ) + return() +endif() + if(NOT NO_WIDGETS) _qt_internal_test_expect_pass(test_build_simple_widget_app) set(extra_widget_app_options "") diff --git a/tests/auto/cmake/test_android_multi_abi_forward_vars/CMakeLists.txt b/tests/auto/cmake/test_android_multi_abi_forward_vars/CMakeLists.txt new file mode 100644 index 0000000000..0f84d5ff3e --- /dev/null +++ b/tests/auto/cmake/test_android_multi_abi_forward_vars/CMakeLists.txt @@ -0,0 +1,33 @@ +# Copyright (C) 2022 The Qt Company Ltd. +# SPDX-License-Identifier: BSD-3-Clause + +cmake_minimum_required(VERSION 3.16) + +project(test_android_multi_abi_forward_vars) + +find_package(Qt6 COMPONENTS Core Gui REQUIRED) + +if(NOT TEST_SINGLE_VALUE_ARG STREQUAL "TestValue") + message(FATAL_ERROR + "TEST_SINGLE_VALUE_ARG is not valid: ${TEST_SINGLE_VALUE_ARG}") +endif() + +if(NOT TEST_LIST_VALUE_ARG STREQUAL "TestValue;TestValue2;TestValue3") + message(FATAL_ERROR + "TEST_LIST_VALUE_ARG is not valid: ${TEST_LIST_VALUE_ARG}") +endif() + +if(NOT TEST_ESCAPING_VALUE_ARG STREQUAL "TestValue\;TestValue2\;TestValue3") + message(FATAL_ERROR + "TEST_ESCAPING_VALUE_ARG is not valid: ${TEST_ESCAPING_VALUE_ARG}") +endif() + +if(NOT TEST_SPACES_VALUE_ARG STREQUAL "TestValue TestValue2 TestValue3") + message(FATAL_ERROR + "TEST_SPACES_VALUE_ARG is not valid: ${TEST_SPACES_VALUE_ARG}") +endif() + +# Make sure that ABI external projects are created +qt6_add_executable(test_executable main.cpp) + +target_link_libraries(test_executable PRIVATE Qt::Core Qt::Gui) diff --git a/tests/auto/cmake/test_android_multi_abi_forward_vars/main.cpp b/tests/auto/cmake/test_android_multi_abi_forward_vars/main.cpp new file mode 100644 index 0000000000..a0c5ae2de5 --- /dev/null +++ b/tests/auto/cmake/test_android_multi_abi_forward_vars/main.cpp @@ -0,0 +1,4 @@ +// Copyright (C) 2022 The Qt Company Ltd. +// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only WITH Qt-GPL-exception-1.0 + +int main(int, char *[]) { return 0; }