qt5base-lts/tests/auto/cmake/tst_qaddpreroutine/CMakeLists.txt
Alexandru Croitor 2fccea3b70 CMake: Fix tst_qaddpreroutine to work with static builds
DEFAULT_IF needs to be true so that in a static build the
built plugin is automatically linked into the test executable
using the special static plugin per-repo behavior in
qt_internal_add_executable.

The QtPostProcess routines are not executed for this test project
because we don't use qt_build_repo. This means that no
QtFooPluginCMakeConfig.cmake file is generated and thus there's no
point in using qt6_import_plugins because the pulic plugin genexes
won't know about this target anyway.

Explicitly set the CLASS_NAME so that the name expected by the
Q_IMPORT_PLUGIN macro matches the name of the plugin instance that moc
generates in QT_MOC_EXPORT_PLUGIN.

Amends 22e967c304

Task-number: QTBUG-87580
Task-number: QTBUG-90341
Pick-to: 6.1 6.0
Change-Id: I5ef361e7e2cebc46b35310c679f15c84cd61b4a5
Reviewed-by: Joerg Bornemann <joerg.bornemann@qt.io>
2021-04-26 19:35:55 +02:00

49 lines
1.2 KiB
CMake

#####################################################################
## tst_qaddpreroutine Test:
#####################################################################
cmake_minimum_required(VERSION 3.16)
if(DEFINED CMAKE_Core_MODULE_MAJOR_VERSION)
set(project_version "${CMAKE_Core_MODULE_MAJOR_VERSION}.\
${CMAKE_Core_MODULE_MINOR_VERSION}.${CMAKE_Core_MODULE_PATCH_VERSION}"
)
else()
set(project_version "6.0.0")
endif()
project(tst_qaddpreroutine
LANGUAGES CXX
VERSION "${project_version}"
)
find_package(Qt6 COMPONENTS Core BuildInternals CONFIG REQUIRED)
qt_prepare_standalone_project()
find_package(Qt6 COMPONENTS Gui Test CONFIG REQUIRED)
qt_internal_add_plugin(QTBUG_90341ThemePlugin
OUTPUT_NAME QTBUG_90341
OUTPUT_DIRECTORY "${CMAKE_BINARY_DIR}"
CLASS_NAME ThemePlugin
TYPE platformthemes
DEFAULT_IF TRUE
SOURCES
plugin.cpp
SKIP_INSTALL
PUBLIC_LIBRARIES
Qt::Core
Qt::Gui
Qt::GuiPrivate
)
qt_internal_add_test(tst_qaddpreroutine
SOURCES
tst_qaddpreroutine.cpp
PUBLIC_LIBRARIES
Qt::Gui
)
target_compile_definitions(tst_qaddpreroutine
PRIVATE QT_QPA_PLATFORM_PLUGIN_PATH=\"${CMAKE_BINARY_DIR}\")