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 <simon.hausmann@qt.io>
This commit is contained in:
Alexandru Croitor 2019-06-13 15:35:26 +02:00
parent 60c2f9f3b4
commit cfcd50875b

View File

@ -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()