qt5base-lts/tests/auto/gui/kernel/qguiapplication/CMakeLists.txt
Alexandru Croitor 92ee9bd6b8 CMake: Properly handle CONFIG += thread aka Threads::Threads
mkspecs/features/qt.prf adds a dependency on the system threading
library if the Qt Core thread feature is enabled. Because qt.prf is
loaded by any public or internal Qt project, it's essentially a public
dependency for any Qt consumer.

To mimic that in CMake, we check if the thread feature is enabled, and
and set the Threads::Threads library as a dependency of Qt6::Platform,
which is a public target used by all Qt modules and plugins and Qt
consumers.

We also need to create a Qt6Dependencies.cmake file so we
find_package(Threads) every time find_package(Qt6) is called.

For the .prl files to be usable, we have to filter out some
CMake implementation specific directory separator tokens
'CMAKE_DIRECTORY_ID_SEP' aka '::@', which are added because we call
target_link_libraries() with a target created in a different scope
(I think).

As a result of this change, we shouldn't have to hardcode
Threads::Threads in other projects, because it's now a global public
dependency.

Task-number: QTBUG-85801
Task-number: QTBUG-85877
Change-Id: Ib5d662c43b28e63f7da49d3bd77d0ad751220b31
Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
Reviewed-by: Cristian Adam <cristian.adam@qt.io>
2020-08-06 19:15:39 +02:00

55 lines
1.5 KiB
CMake

# Generated from qguiapplication.pro.
if(NOT QT_FEATURE_private_tests)
return()
endif()
#####################################################################
## tst_qguiapplication Test:
#####################################################################
# special case begin
if (WIN32)
set(target_version "1.2.3.4")
else()
set(target_version "1.2.3")
endif()
# special case end
qt_add_test(tst_qguiapplication
VERSION ${target_version} # special case
SOURCES
../../../corelib/kernel/qcoreapplication/tst_qcoreapplication.cpp ../../../corelib/kernel/qcoreapplication/tst_qcoreapplication.h # special case
tst_qguiapplication.cpp
DEFINES
QT_DISABLE_DEPRECATED_BEFORE=0x050E00
INCLUDE_DIRECTORIES
../../../corelib/kernel/qcoreapplication
PUBLIC_LIBRARIES
Qt::CorePrivate
Qt::GuiPrivate
)
# Resources:
set(tst_qguiapplication_resource_files
"icons/appicon.png"
"icons/usericon.png"
)
qt_add_resource(tst_qguiapplication "tst_qguiapplication"
PREFIX
"/"
FILES
${tst_qguiapplication_resource_files}
)
## Scopes:
#####################################################################
#### Keys ignored in scope 3:.:../../../corelib/kernel/qcoreapplication:../../../corelib/kernel/qcoreapplication/qcoreapplication.pro:WIN32:
# VERSION = "1.2.3.4"
#### Keys ignored in scope 4:.:../../../corelib/kernel/qcoreapplication:../../../corelib/kernel/qcoreapplication/qcoreapplication.pro:else:
# VERSION = "1.2.3"