From 6c20ae774cda49fc233125768b806447669f4265 Mon Sep 17 00:00:00 2001 From: Leander Beernaert Date: Tue, 10 Dec 2019 14:21:36 +0100 Subject: [PATCH] Add option to specify working directory for qt_add_test Change-Id: Iba5104cccdc613f7b2cf0d1454209578adaac824 Reviewed-by: Alexandru Croitor Reviewed-by: Simon Hausmann --- cmake/QtBuild.cmake | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/cmake/QtBuild.cmake b/cmake/QtBuild.cmake index 480093d043..8b87ef9fdb 100644 --- a/cmake/QtBuild.cmake +++ b/cmake/QtBuild.cmake @@ -2574,7 +2574,9 @@ endfunction() function(qt_add_test name) qt_parse_all_arguments(arg "qt_add_test" "RUN_SERIAL;EXCEPTIONS;GUI;QMLTEST" - "OUTPUT_DIRECTORY" "QML_IMPORTPATH;TESTDATA;${__default_private_args};${__default_public_args}" ${ARGN}) + "OUTPUT_DIRECTORY;WORKING_DIRECTORY" + "QML_IMPORTPATH;TESTDATA;${__default_private_args};${__default_public_args}" ${ARGN} + ) if (NOT arg_OUTPUT_DIRECTORY) set(arg_OUTPUT_DIRECTORY "${CMAKE_CURRENT_BINARY_DIR}") @@ -2658,7 +2660,11 @@ function(qt_add_test name) set(test_working_dir "${CMAKE_CURRENT_SOURCE_DIR}") set(test_executable ${QT_CMAKE_EXPORT_NAMESPACE}::qmltestrunner) else() - set(test_working_dir "${CMAKE_CURRENT_BINARY_DIR}") + if (arg_WORKING_DIRECTORY) + set(test_working_dir "${arg_WORKING_DIRECTORY}") + else() + set(test_working_dir "${CMAKE_CURRENT_BINARY_DIR}") + endif() set(test_executable "${name}") endif()