From d8c8b4b2bd6f1efb9df754c20723b87c9aa78f7b Mon Sep 17 00:00:00 2001
From: Dimitar Tasev <dimitar.tasev@stfc.ac.uk>
Date: Mon, 1 Oct 2018 16:51:52 +0100
Subject: [PATCH] Fixed WidgetsTestQt5 include, re #23667"

CMake make test executable function now support QT_VERSION for Qt 4 and
5.

Separated the TEST_FILES for Qt5 into a new QT5_TEST_FILES
---
 buildconfig/CMake/QtTargetFunctions.cmake |  9 +++--
 qt/widgets/common/CMakeLists.txt          | 42 +++++++++++++++++++++++
 2 files changed, 49 insertions(+), 2 deletions(-)

diff --git a/buildconfig/CMake/QtTargetFunctions.cmake b/buildconfig/CMake/QtTargetFunctions.cmake
index 3aa745101a1..200f6c90731 100644
--- a/buildconfig/CMake/QtTargetFunctions.cmake
+++ b/buildconfig/CMake/QtTargetFunctions.cmake
@@ -245,9 +245,14 @@ endfunction ()
 
 function (mtd_add_qt_tests)
   _qt_versions(_qt_vers ${ARGN})
-  # Create targets
+  # Create test executables
   foreach(_ver ${_qt_vers})
-    mtd_add_qt_test_executable (QT_VERSION ${_ver} ${ARGN})
+    if (_ver EQUAL 4 AND ENABLE_MANTIDPLOT)
+      mtd_add_qt_test_executable (QT_VERSION ${_ver} ${ARGN})
+    endif ()
+    if (_ver EQUAL 5 AND ENABLE_WORKBENCH)
+      mtd_add_qt_test_executable (QT_VERSION ${_ver} ${ARGN})
+    endif ()
   endforeach()
 endfunction()
 
diff --git a/qt/widgets/common/CMakeLists.txt b/qt/widgets/common/CMakeLists.txt
index 5ac514e32e1..af9fe243e90 100644
--- a/qt/widgets/common/CMakeLists.txt
+++ b/qt/widgets/common/CMakeLists.txt
@@ -35,15 +35,20 @@ set ( QT5_SRC_FILES
   src/MessageDisplay.cpp
   src/MWRunFiles.cpp
   src/OptionsPropertyWidget.cpp
+  # check if used in QT5 and if so where
   src/PeriodicTableWidget.cpp
+  # check if used in QT5 and if so where
   src/pixmaps.cpp
   src/PluginLibraries.cpp
+  # check if used in QT5 and if so where
   src/pqHelpWindow.cxx
   src/ProcessingAlgoWidget.cpp
   src/PropertyWidget.cpp
   src/PropertyWidgetFactory.cpp
+  # check if used in QT5 and if so where
   src/PythonRunner.cpp
   src/QtSignalChannel.cpp
+  # check if used in QT5 and if so where
   src/RenameParDialog.cpp
   src/ScriptEditor.cpp
   src/SelectFunctionDialog.cpp
@@ -60,6 +65,7 @@ set ( QT5_SRC_FILES
   src/WorkspacePresenter/WorkspaceTreeWidgetSimple.cpp
   src/WorkspaceSelector.cpp
 
+  # todo check why/where this is used in qt5
   src/QtPropertyBrowser/DoubleDialogEditor.cpp
   src/QtPropertyBrowser/DoubleEditorFactory.cpp
   src/QtPropertyBrowser/FilenameDialogEditor.cpp
@@ -88,6 +94,7 @@ set ( QT5_MOC_FILES
   inc/MantidQtWidgets/Common/DataSelector.h
   inc/MantidQtWidgets/Common/FilePropertyWidget.h
   inc/MantidQtWidgets/Common/FindFilesThreadPoolManager.h
+  inc/MantidQtWidgets/Common/FindFilesThreadPoolManagerMockObjects.h
   inc/MantidQtWidgets/Common/FindFilesWorker.h
   inc/MantidQtWidgets/Common/FindReplaceDialog.h
   inc/MantidQtWidgets/Common/FunctionBrowser.h
@@ -788,6 +795,7 @@ set( TEST_FILES
 )
 
 mtd_add_qt_tests (TARGET_NAME MantidQtWidgetsCommonTest
+  QT_VERSION 4
   SRC ${TEST_FILES}
   INCLUDE_DIRS
     ../../../Framework/TestHelpers/inc
@@ -810,6 +818,40 @@ mtd_add_qt_tests (TARGET_NAME MantidQtWidgetsCommonTest
     GUITests
 )
 
+set( QT5_TEST_FILES
+  test/BatchAlgorithmRunnerTest.h
+  test/FileDialogHandlerTest.h
+  test/FindFilesThreadPoolManagerTest.h
+  test/FindFilesWorkerTest.h
+  test/InterfaceManagerTest.h
+  test/WorkspacePresenter/ADSAdapterTest.h
+  test/WorkspacePresenter/WorkspacePresenterTest.h
+)
+
+mtd_add_qt_tests (TARGET_NAME MantidQtWidgetsCommonTest
+  QT_VERSION 5
+  SRC ${QT5_TEST_FILES}
+  INCLUDE_DIRS
+    ../../../Framework/TestHelpers/inc
+    ../../../Framework/DataObjects/inc
+    ../../../Framework/Crystal/inc
+  TEST_HELPER_SRCS
+    ../../../Framework/TestHelpers/src/TearDownWorld.cpp
+    ../../../Framework/TestHelpers/src/WorkspaceCreationHelper.cpp
+    ../../../Framework/TestHelpers/src/ComponentCreationHelper.cpp
+    ../../../Framework/TestHelpers/src/InstrumentCreationHelper.cpp
+  LINK_LIBS
+    ${TARGET_LIBRARIES}
+    DataObjects
+    ${GMOCK_LIBRARIES}
+    ${GTEST_LIBRARIES}
+  MTD_QT_LINK_LIBS
+    MantidQtWidgetsCommon
+  PARENT_DEPENDENCIES
+    GUITests
+)
+
+
 ###########################################################################
 # Windows: Generate a qt.conf file so that the dev build finds the qt
 # plugins in third party. Done in two steps to get it into the build
-- 
GitLab