From cfcd50875b84273942709f224a1cf37fa70b41b7 Mon Sep 17 00:00:00 2001 From: Alexandru Croitor Date: Thu, 13 Jun 2019 15:35:26 +0200 Subject: [PATCH] Try to find Test package before calling add_subdirectory(src) in qt_build_repo(). This is important for qtdeclarative for example, which builds QmlTest functionality in ./src, and thus needs Test lib to be available. Change-Id: I84326d79844526f2f177c19de30bab0c858773e3 Reviewed-by: Qt CMake Build Bot Reviewed-by: Simon Hausmann --- cmake/QtBuildInternals/QtBuildInternalsConfig.cmake | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/cmake/QtBuildInternals/QtBuildInternalsConfig.cmake b/cmake/QtBuildInternals/QtBuildInternalsConfig.cmake index eeba186a705..b2b262d05cd 100644 --- a/cmake/QtBuildInternals/QtBuildInternalsConfig.cmake +++ b/cmake/QtBuildInternals/QtBuildInternalsConfig.cmake @@ -69,6 +69,13 @@ endmacro() macro(qt_build_repo) qt_build_repo_begin(${ARGN}) + # If testing is enabled, try to find the qtbase Test package. + # Do this before adding src, because there might be test related conditions + # in source. + if (BUILD_TESTING) + find_package(Qt5 ${PROJECT_VERSION} CONFIG REQUIRED COMPONENTS Test) + endif() + if (EXISTS "${CMAKE_CURRENT_SOURCE_DIR}/src/CMakeLists.txt") add_subdirectory(src) endif() @@ -80,7 +87,6 @@ macro(qt_build_repo) endif() if (BUILD_TESTING AND EXISTS "${CMAKE_CURRENT_SOURCE_DIR}/tests/CMakeLists.txt") - find_package(Qt5 ${PROJECT_VERSION} CONFIG REQUIRED COMPONENTS Test Xml) add_subdirectory(tests) endif()