CMake: Fix tst_moc to build when tests are built as part of Qt tree

tst_moc uses qt_wrap_cpp, which tries to dispatch to qt6_wrap_cpp
depending on the value of QT_DEFAULT_MAJOR_VERSION. That value is only
set in Qt6CoreConfigExtras.cmake.in, which is not loaded as part of
the qtbase build unless something does find_package(Qt6Core).

Set the QT_DEFAULT_MAJOR_VERSION to 6 before including the
Qt6CoreMacros in the qtbase top-level project.

Change-Id: I7b81d89d965f755e51727007e68771ac3931ac55
Reviewed-by: Joerg Bornemann <joerg.bornemann@qt.io>
This commit is contained in:
Alexandru Croitor 2020-08-21 16:59:17 +02:00
parent bf3d834ab4
commit dac557295b

View File

@ -74,6 +74,7 @@ if(NOT QT_BUILD_STANDALONE_TESTS)
qt_set_language_standards()
#include CoreMacros() for qt6_generate_meta_types()
set(QT_DEFAULT_MAJOR_VERSION 6)
include(src/corelib/Qt6CoreMacros.cmake)
# Needed when building qtbase for android.