Commit Graph

9 Commits

Author SHA1 Message Date
Alexandru Croitor
d50a7d635c CMake: Fix prl files of static Qt builds
Static Qt plugins should not be included in the list of libraries of
a prl file. They end up being there due to our circular dependency
trick where the plugins depend on the module they belong
to.

This in turn causes the giant static plugin generator expressions to
be processed in qt_collect_libs(), and the generated prl file ends up
having target names like Qt6::QJpegPlugin which are obviously not
linker flags.

To eliminate the static plugins from prl files, add an additional
dummy boolean generator expression '$<BOOL:QT_IS_PLUGIN_GENEX>'
that always evaluates to true. We can string match on this expression
in qt_collect_libs, and thus remove the whole static plugin genex
entry.

This should fix linking of apps with qmake that use a CMake-built
static Qt.

Task-number: QTBUG-85865
Task-number: QTBUG-85240
Task-number: QTBUG-85801
Change-Id: I949dc5edb10d94c4ab84ed430af7c164d8efaaa6
Reviewed-by: Cristian Adam <cristian.adam@qt.io>
2020-08-06 19:19:46 +02:00
Alexandru Croitor
b714219fea Fix qt_import_plugins compatibility with Qt 5
Handle versionless plugin names passed to qt_import_plugins.

Task-number: QTBUG-74137
Task-number: QTBUG-80477
Change-Id: Ic7fb6e54d2822c7eb58a7874b4a1c137f0c101d9
Reviewed-by: Qt CMake Build Bot
Reviewed-by: Cristian Adam <cristian.adam@qt.io>
2020-01-27 11:59:51 +00:00
Leander Beernaert
108393d33b Fix Generator Expression for static non-prefix builds
Change-Id: Icd32164943d7bb0639de3022bae749d0010674fc
Reviewed-by: Simon Hausmann <simon.hausmann@qt.io>
2020-01-10 10:18:55 +00:00
Jean-Michaël Celerier
ea81b69cde Implement qtbase fixes for superbuilds
Change-Id: I0d3445cf0740e3925fa9342dac4d07892518afe5
Reviewed-by: Qt CMake Build Bot
Reviewed-by: Cristian Adam <cristian.adam@qt.io>
2020-01-08 10:42:21 +00:00
Alexandru Croitor
87ba355d95 Fix automatic plugin importing in static builds
QtPlugins.cmake.in uses file(GENERATE) and target_sources() to
propagate the generated cpp files which contain plugin initialization
code to their consuming targets.

Unfortunately due to a bug in CMake, if the file is generated in a
different scope than the consuming target, the CMake generation
step will fail saying that the source file can not be found.
See https://gitlab.kitware.com/cmake/cmake/issues/18399 for details.

In the case of qtdeclarative, find_package(Qt6) is called at the top
level scope (this is when the file gets generated),
but the targets are created in subdirectory scopes, and the GENERATED
source file property is not propagated across scropes.

Circumvent the issue by instead using file(WRITE) and configure_file()
which create the file at configure time rather than generate time.

This will pollute the current binary directory with some more files,
but at least successfully fixes the build.

Change-Id: I3ab3b12dcbf6a9d0ab9ee87173e4a1952325b37b
Reviewed-by: Leander Beernaert <leander.beernaert@qt.io>
Reviewed-by: Simon Hausmann <simon.hausmann@qt.io>
Reviewed-by: Qt CMake Build Bot
2019-10-09 09:22:27 +00:00
Jean-Michaël Celerier
d1542e8a73 Match qt_import_plugin API with qt5's
Some work was needed to make the plug-in types,
and which plug-ins are available for each type
in client code.

Change-Id: Ib71feca31069deca3d3f54c8613054f5f8ae410c
Reviewed-by: Simon Hausmann <simon.hausmann@qt.io>
Reviewed-by: Qt CMake Build Bot
2019-10-09 09:05:39 +00:00
Alexandru Croitor
59912b9558 Fix building examples when doing a Qt static build
The build failed due to two different reasons.

We tried to assign properties on an aliased target, which does not
work. Make sure to set properties on the original unaliased target.

We tried to query for the value of the QT_DEFAULT_PLUGINS property
when automatically linking to plugins, but the generator expression
failed in the AND section, because querying for an unexisting value
does not return an integer, and the AND expression expects an integer.
The fix is to wrap the relevant expression in a BOOL generator
expression.

Change-Id: Ia065bc1de939cee49e5de0b2aef70e356cc5419a
Reviewed-by: Simon Hausmann <simon.hausmann@qt.io>
Reviewed-by: Qt CMake Build Bot
2019-07-22 18:48:17 +00:00
Jean-Michaël Celerier
a5b78a3660 cmake: implement default qpa plugin behavior for static builds
This is done by adding a DEFAULT_IF argument to add_qt_plugin, which accepts
if-evaluated expressions.

e.g.

    add_qt_plugin(myplugin
	DEFAULT_IF ${foo} STREQUAL ${bar}
        ...
    )

so that this mechanism can be reused later if necessary.

Change-Id: I7eba9adaaa28e55a4f0f94cf206e868b990027e6
Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io>
2019-07-05 14:58:52 +00:00
Jean-Michaël Celerier
5769e1a2f6 cmake: allow client apps to load static plug-ins
Based in part on Kyle Edwards's implementation :
https://codereview.qt-project.org/c/qt/qtbase/+/243731

Example :
```
cmake_minimum_required(VERSION 3.15)
project(foo)

add_executable(foo main.cpp)

find_package(ICU COMPONENTS i18n uc data REQUIRED)
find_package(Qt6 COMPONENTS Core Gui REQUIRED)
target_link_libraries(foo Qt6::Core Qt6::Gui)

qt_import_plugins(foo
    INCLUDE
        Qt6::qxcb
    EXCLUDE
        Qt6::qgtk3 Qt6::qeglfs-kms-integration Qt6::qjpeg
)
```

Change-Id: If7736c42f669f7d7f43052cae59c28fc7fcb4156
Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io>
2019-07-05 14:56:56 +00:00