CMake: Fix failing standalone tests on Windows
Due to the install prefix being changed for standalone tests,
the correct $qt_prefix/bin folder was not added to the PATH
environment variable when running tests.
Make sure to always include the the original qt install prefix,
even if a different install prefix is specified when configuring
standalone tests.
Amends 39090ea15c
Change-Id: I22aab732bb2bb679074a811d28d8209e1d535df3
Reviewed-by: Joerg Bornemann <joerg.bornemann@qt.io>
bb10
parent
88f6087f01
commit
a876ff1283
|
|
@ -3310,17 +3310,34 @@ function(qt_add_test name)
|
|||
if (arg_TIMEOUT)
|
||||
set_tests_properties(${name} PROPERTIES TIMEOUT ${arg_TIMEOUT})
|
||||
endif()
|
||||
# Get path to qtbase/bin, then prepend this path containing the shared libraries to PATH
|
||||
set(INSTALL_PREFIX_BIN "${CMAKE_INSTALL_PREFIX}/${INSTALL_BINDIR}")
|
||||
set(test_env_path "PATH=${CMAKE_CURRENT_BINARY_DIR}${QT_PATH_SEPARATOR}${INSTALL_PREFIX_BIN}${QT_PATH_SEPARATOR}$ENV{PATH}")
|
||||
|
||||
# Get path to <original_qtbase_install_prefix>/bin, as well as CMAKE_INSTALL_PREFIX/bin, then
|
||||
# prepend them to the PATH environment variable.
|
||||
# It's needed on Windows to find the shared libraries and plugins.
|
||||
# original_qtbase_install_prefix is the CMAKE_INSTALL_PREFIX specified when building qtbase.
|
||||
# The regular CMAKE_INSTALL_PREFIX can be different for example when building standalone tests.
|
||||
# Latest CMAKE_INSTALL_PREFIX takes priority for the PATH environment variable.
|
||||
set(install_prefixes "${CMAKE_INSTALL_PREFIX}")
|
||||
if(QT_BUILD_INTERNALS_ORIGINAL_INSTALL_PREFIX)
|
||||
list(APPEND install_prefixes "${QT_BUILD_INTERNALS_ORIGINAL_INSTALL_PREFIX}")
|
||||
endif()
|
||||
|
||||
set(test_env_path "PATH=${CMAKE_CURRENT_BINARY_DIR}")
|
||||
foreach(install_prefix ${install_prefixes})
|
||||
set(test_env_path "${test_env_path}${QT_PATH_SEPARATOR}${install_prefix}/${INSTALL_BINDIR}")
|
||||
endforeach()
|
||||
set(test_env_path "${test_env_path}${QT_PATH_SEPARATOR}$ENV{PATH}")
|
||||
string(REPLACE ";" "\;" test_env_path "${test_env_path}")
|
||||
set_property(TEST "${name}" APPEND PROPERTY ENVIRONMENT "${test_env_path}")
|
||||
set_property(TEST "${name}" 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)
|
||||
list(APPEND plugin_paths "${CMAKE_INSTALL_PREFIX}/${INSTALL_PLUGINSDIR}")
|
||||
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}")
|
||||
|
|
|
|||
|
|
@ -10,6 +10,14 @@ set(QT_BUILD_INTERNALS_PATH "${CMAKE_CURRENT_LIST_DIR}")
|
|||
set(CMAKE_INSTALL_PREFIX @CMAKE_INSTALL_PREFIX@ CACHE PATH
|
||||
"Install path prefix, prepended onto install directories." FORCE)
|
||||
|
||||
# Save the original install prefix in an additional variable.
|
||||
# While CMAKE_INSTALL_PREFIX may be overridden in certain cases (like for standalone tests building
|
||||
# or for singular qt-cmake-standalone-test usage), we still need the original qtbase install prefix
|
||||
# to know where the shared libraries are located to inject them into PATH when running tests via
|
||||
# ctest.
|
||||
set(QT_BUILD_INTERNALS_ORIGINAL_INSTALL_PREFIX @CMAKE_INSTALL_PREFIX@ CACHE PATH
|
||||
"Original install prefix specified when building qtbase." FORCE)
|
||||
|
||||
# Propagate developer builds to other modules via BuildInternals package.
|
||||
if(@FEATURE_developer_build@)
|
||||
set(FEATURE_developer_build ON CACHE BOOL "Developer build." FORCE)
|
||||
|
|
|
|||
Loading…
Reference in New Issue