aboutsummaryrefslogtreecommitdiffstats
path: root/tests/auto/cmake
diff options
context:
space:
mode:
authorAlexandru Croitor <alexandru.croitor@qt.io>2022-08-16 18:37:30 +0200
committerAlexandru Croitor <alexandru.croitor@qt.io>2022-12-02 13:58:55 +0100
commit2e4fad5f1d29a6bd4547c21916bd626d59d194cf (patch)
treef3fd2309f209e50067657f913e84789efa07dd34 /tests/auto/cmake
parent8bc748e7e52d19a078b0281c5b8265a42015ffdb (diff)
CMake: Add iOS build auto test for Qt Quick project
Currently we can't run iOS tests in the CI, but we can at least build them. Reuse the CMake deployment auto test as a regular build test (no deployment) when targeting iOS. This ensures we don't regress in building iOS projects that use qml modules. Move the deployment test to be added earlier in the CMakeLists.txt file and return early when both IOS and QT_BUILD_MINIMAL_STATIC_TESTS are true, so that we build only that test in the CI for iOS. Pick-to: 6.4 Fixes: QTBUG-96056 Change-Id: I68002c5b70bb3f182cf55ec4a2d4888ea9e2b81e Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org> Reviewed-by: Jörg Bornemann <joerg.bornemann@qt.io>
Diffstat (limited to 'tests/auto/cmake')
-rw-r--r--tests/auto/cmake/CMakeLists.txt62
-rw-r--r--tests/auto/cmake/test_qml_app_deployment/CMakeLists.txt42
2 files changed, 68 insertions, 36 deletions
diff --git a/tests/auto/cmake/CMakeLists.txt b/tests/auto/cmake/CMakeLists.txt
index eacd8d7a44..fd2053176a 100644
--- a/tests/auto/cmake/CMakeLists.txt
+++ b/tests/auto/cmake/CMakeLists.txt
@@ -40,6 +40,45 @@ endforeach()
include("${_Qt6CTestMacros}")
+if(TARGET Qt::Quick)
+ set(deploy_args
+ test_qml_app_deployment
+ BINARY "${CMAKE_CTEST_COMMAND}"
+ BINARY_ARGS "-V"
+ # Need to explicitly specify a writable install prefix.
+ BUILD_OPTIONS
+ -DCMAKE_INSTALL_PREFIX=${CMAKE_CURRENT_BINARY_DIR}/test_qml_app_deployment_installed
+ NO_RUN_ENVIRONMENT_PLUGIN_PATH
+ )
+
+ # For now, the test should only pass on
+ # - Windows shared / static builds
+ # - macOS shared / static builds
+ #- Linux desktop shared / static builds
+ # - iOS static builds
+ # It should fail on other platforms, because there is no support for runtime dependency
+ # deployment on those platforms.
+ # In the static builds case, the runtime dependencies are just skipped, but the test should
+ # still pass.
+ if(WIN32 OR APPLE
+ OR (UNIX AND NOT APPLE AND NOT ANDROID AND NOT CMAKE_CROSSCOMPILING))
+ _qt_internal_test_expect_pass(${deploy_args})
+ else()
+ _qt_internal_test_expect_fail(${deploy_args})
+ endif()
+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_*
+#
+# 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()
+
set(module_includes "")
if(TARGET Qt::Qml)
@@ -95,28 +134,5 @@ if(TARGET Qt::Quick)
)
endif()
endif()
-
- set(deploy_args
- test_qml_app_deployment
- BINARY "${CMAKE_CTEST_COMMAND}"
- BINARY_ARGS "-V"
- # Need to explicitly specify a writable install prefix.
- BUILD_OPTIONS
- -DCMAKE_INSTALL_PREFIX=${CMAKE_CURRENT_BINARY_DIR}/test_qml_app_deployment_installed
- NO_RUN_ENVIRONMENT_PLUGIN_PATH
- )
-
- # For now, the test should only pass on Windows, macOS and desktop Linux shared and static
- # builds and fail on other platforms, because there is no support for runtime dependency
- # deployment on those platforms.
- # With static builds the runtime dependencies are just skipped, but the test should
- # still pass.
- if(WIN32
- OR (APPLE AND NOT IOS)
- OR (UNIX AND NOT APPLE AND NOT ANDROID AND NOT CMAKE_CROSSCOMPILING))
- _qt_internal_test_expect_pass(${deploy_args})
- else()
- _qt_internal_test_expect_fail(${deploy_args})
- endif()
endif()
diff --git a/tests/auto/cmake/test_qml_app_deployment/CMakeLists.txt b/tests/auto/cmake/test_qml_app_deployment/CMakeLists.txt
index d008c29e6a..50522a0909 100644
--- a/tests/auto/cmake/test_qml_app_deployment/CMakeLists.txt
+++ b/tests/auto/cmake/test_qml_app_deployment/CMakeLists.txt
@@ -38,10 +38,15 @@ function(create_test_executable target)
Qt::QuickTestUtilsPrivate
)
- install(TARGETS ${target}
- BUNDLE DESTINATION .
- RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR}
- )
+ # Skip installation on iOS, because ctest's --build-and-test only builds the Debug
+ # configuration by default, whereas installation installs both Release and Debug, and
+ # thus fails (due to missing Release libraries)
+ if(NOT IOS)
+ install(TARGETS ${target}
+ BUNDLE DESTINATION .
+ RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR}
+ )
+ endif()
# Need to manually install the backing libraries on Windows because windeployqt does not do it.
# On macOS, macdeployqt takes care of installing the backing library because it is detected
@@ -81,16 +86,27 @@ function(create_test_executable target)
# On unsupported deployment platforms, either the install_ test will fail not finding
# the location of the app (because we do not set a installed_app_location value)
# or the run_deployed_ test will fail because we didn't deploy the runtime dependencies.
+ #
+ # On iOS we don't want to install nor run the application. Installing won't work due to the
+ # ctest limitation described above, and running won't work because we'd have to do it via
+ # a simulator. More importantly installing would fail with
+ # Test command: NOT_AVAILABLE
+ # because using the add_test(NAME) signature fails to run when using ctest without a -C
+ # option.
+ # We still want to build the iOS app, to confirm that building works.
+ #
# When support for additional platforms is added, these locations will have to be augmented.
- add_test(install_${target} "${CMAKE_COMMAND}" --install .)
- set_tests_properties(install_${target} PROPERTIES FIXTURES_SETUP deploy_step)
- add_test(NAME run_deployed_${target}
- COMMAND "${installed_app_location}"
- # Make sure that we don't use the default working directory which is
- # CMAKE_CURRENT_BINARY_DIR because on Windows the loader might pick up dlls
- # from the working directory instead of the installed app dir, if the dll is
- # missing in the app dir.
- WORKING_DIRECTORY "${CMAKE_INSTALL_PREFIX}")
+ if(NOT IOS)
+ add_test(install_${target} "${CMAKE_COMMAND}" --install .)
+ set_tests_properties(install_${target} PROPERTIES FIXTURES_SETUP deploy_step)
+ add_test(NAME run_deployed_${target}
+ COMMAND "${installed_app_location}"
+ # Make sure that we don't use the default working directory which is
+ # CMAKE_CURRENT_BINARY_DIR because on Windows the loader might pick up dlls
+ # from the working directory instead of the installed app dir, if the dll is
+ # missing in the app dir.
+ WORKING_DIRECTORY "${CMAKE_INSTALL_PREFIX}")
+ endif()
endfunction()
# Create the backing targets before the app, so that the backing library