Don't set QT_PLUGIN_PATH in the deployment test's run environment
Otherwise we don't properly test whether the deployed executable can run without adjusting the environment. We temporarily adjust the test_widgets_app_deployment test and set CMAKE_INSTALL_LIBDIR to make the test pass. It would now fail on Linux distros where CMAKE_INSTALL_LIBDIR defaults to "lib64" but Qt is built with lib dir "lib". The next commit removes this hack. Change-Id: I63c79ef1ee23ffaeed881337fde6e9d889ecc0fe Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io>
This commit is contained in:
parent
1f7850cd46
commit
5ca714318c
@ -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()
|
||||
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()
|
||||
|
||||
#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}")
|
||||
|
||||
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)
|
||||
|
@ -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
|
||||
|
@ -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()
|
||||
|
Loading…
Reference in New Issue
Block a user