diff options
-rw-r--r-- | src/corelib/Qt6CTestMacros.cmake | 40 | ||||
-rw-r--r-- | tests/auto/cmake/CMakeLists.txt | 1 | ||||
-rw-r--r-- | tests/auto/cmake/test_widgets_app_deployment/CMakeLists.txt | 2 |
3 files changed, 29 insertions, 14 deletions
diff --git a/src/corelib/Qt6CTestMacros.cmake b/src/corelib/Qt6CTestMacros.cmake index 198a7abc6f..c2cb883ee7 100644 --- a/src/corelib/Qt6CTestMacros.cmake +++ b/src/corelib/Qt6CTestMacros.cmake @@ -163,6 +163,13 @@ function(_qt_internal_get_cmake_test_configure_options out_var) endfunction() function(_qt_internal_set_up_test_run_environment testname) + set(no_value_options NO_PLUGIN_PATH) + set(single_value_options "") + set(multi_value_options "") + cmake_parse_arguments(PARSE_ARGV 1 arg + "${no_value_options}" "${single_value_options}" "${multi_value_options}" + ) + # This is copy-pasted from qt_add_test and adapted to the standalone project case. if(CMAKE_HOST_SYSTEM_NAME STREQUAL "Windows") set(QT_PATH_SEPARATOR "\\;") @@ -201,20 +208,20 @@ function(_qt_internal_set_up_test_run_environment testname) set_property(TEST "${testname}" APPEND PROPERTY ENVIRONMENT "${test_env_path}") set_property(TEST "${testname}" APPEND PROPERTY ENVIRONMENT "QT_TEST_RUNNING_IN_CTEST=1") - # Add the install prefix to list of plugin paths when doing a prefix build - if(NOT QT_INSTALL_DIR) - foreach(install_prefix ${install_prefixes}) - list(APPEND plugin_paths "${install_prefix}/${INSTALL_PLUGINSDIR}") - endforeach() - endif() - - #TODO: Collect all paths from known repositories when performing a super - # build. - list(APPEND plugin_paths "${PROJECT_BINARY_DIR}/${INSTALL_PLUGINSDIR}") - list(JOIN plugin_paths "${QT_PATH_SEPARATOR}" plugin_paths_joined) - set_property(TEST "${testname}" - APPEND PROPERTY ENVIRONMENT "QT_PLUGIN_PATH=${plugin_paths_joined}") + if(NOT arg_NO_PLUGIN_PATH) + # Add the install prefix to list of plugin paths when doing a prefix build + if(NOT QT_INSTALL_DIR) + foreach(install_prefix ${install_prefixes}) + list(APPEND plugin_paths "${install_prefix}/${INSTALL_PLUGINSDIR}") + endforeach() + endif() + # TODO: Collect all paths from known repositories when performing a super build. + list(APPEND plugin_paths "${PROJECT_BINARY_DIR}/${INSTALL_PLUGINSDIR}") + list(JOIN plugin_paths "${QT_PATH_SEPARATOR}" plugin_paths_joined) + set_property(TEST "${testname}" + APPEND PROPERTY ENVIRONMENT "QT_PLUGIN_PATH=${plugin_paths_joined}") + endif() endfunction() # Checks if the test project can be built successfully. Arguments: @@ -259,6 +266,7 @@ macro(_qt_internal_test_expect_pass _dir) NO_CLEAN_STEP NO_BUILD_PROJECT_ARG NO_IOS_DEFAULT_ARGS + NO_RUN_ENVIRONMENT_PLUGIN_PATH ) set(_test_single_args BINARY @@ -435,7 +443,11 @@ macro(_qt_internal_test_expect_pass _dir) endif() if(_ARGS_BINARY) - _qt_internal_set_up_test_run_environment("${testname}") + set(run_env_args "") + if(_ARGS_NO_RUN_ENVIRONMENT_PLUGIN_PATH) + list(APPEND run_env_args NO_PLUGIN_PATH) + endif() + _qt_internal_set_up_test_run_environment("${testname}" ${run_env_args}) endif() unset(__expect_pass_source_dir) diff --git a/tests/auto/cmake/CMakeLists.txt b/tests/auto/cmake/CMakeLists.txt index 30cd340f16..e841308fc8 100644 --- a/tests/auto/cmake/CMakeLists.txt +++ b/tests/auto/cmake/CMakeLists.txt @@ -332,6 +332,7 @@ set(deploy_args # Need to explicitly specify a writable install prefix. BUILD_OPTIONS -DCMAKE_INSTALL_PREFIX=${CMAKE_CURRENT_BINARY_DIR}/test_widgets_app_deployment_installed + NO_RUN_ENVIRONMENT_PLUGIN_PATH ) # For now, the test should only pass on Windows and macOS shared and static builds and fail on diff --git a/tests/auto/cmake/test_widgets_app_deployment/CMakeLists.txt b/tests/auto/cmake/test_widgets_app_deployment/CMakeLists.txt index 60e3f0af75..9a0c4e8af1 100644 --- a/tests/auto/cmake/test_widgets_app_deployment/CMakeLists.txt +++ b/tests/auto/cmake/test_widgets_app_deployment/CMakeLists.txt @@ -5,6 +5,8 @@ cmake_minimum_required(VERSION 3.16) project(deployment_api) enable_testing() +set(CMAKE_INSTALL_LIBDIR lib) ### temporary hack to make the test pass - remove in next commit! + find_package(Qt6 COMPONENTS REQUIRED Widgets Test) qt6_standard_project_setup() |