qt5base-lts/examples
Alexandru Croitor 5138a970f3 CMake: Workaround building DBus 'car' example with qmake
While trying to implement instructions for building examples with
qmake in the CI, an issue has surfaced.

When building examples with CMake with -DBUILD_EXAMPLES=ON in the CI,
the examples are built in-source, aka source dir == build dir.
This means that the header files generated by qdbusxml2cpp will be
placed in the qtbase source dir.

The instructions that try to build examples with qmake build the
examples in a separate build dir after building the examples with CMake.

Unfortunately the qtbase/examples/dbus/remotecontrolledcar/car example
includes the generated DBus adaptor header via a statement like
  #include "car_adaptor.h"
and the compiler prefers to pick up the header file from the example
source dir (the one generated by CMake), rather than the one generated
by qmake in the example build dir.

Because CMake's DBus integration uses different flags than qmake's
DBus integration, the generated header file code is not compatible
with the qmake generated cpp file, and the example fails to link when
building with qmake, because it can't find an appropriate constructor
symbol.

In an ideal world, we wouldn't do in-source builds with the CMake
build, but that leads to other issues which I currently don't recall.

To circumvent the issue, adapt the CMake DBus qt6_add_dbus_adaptor
function to allow not passing the problematic '-l' flag by making it
optional. This shouldn't break existing code, but allows us to
generate a compatible header that will be used by qmake and succeed in
linking the example.

Task-number: QTBUG-85986
Change-Id: I06759f79aeb66bb32da7f158f55dd4734c4a9887
Reviewed-by: Joerg Bornemann <joerg.bornemann@qt.io>
2020-08-23 11:04:04 +02:00
..
aggregate install a sane top-level examples.pro file 2012-12-11 13:37:57 +01:00
corelib Move QStringRef and remains to Qt5Compat 2020-08-20 00:58:13 +02:00
dbus CMake: Workaround building DBus 'car' example with qmake 2020-08-23 11:04:04 +02:00
embedded Port the QXmlStream API from QStringRef to QStringView 2020-08-19 19:48:03 +02:00
gui CMake: Regenerate examples 2020-07-09 09:38:28 +02:00
network Port the QXmlStream API from QStringRef to QStringView 2020-08-19 19:48:03 +02:00
opengl CMake: Regenerate examples 2020-07-09 09:38:28 +02:00
qmake Add cmdline feature to qmake 2019-02-18 07:12:14 +00:00
qpa CMake: Regenerate examples 2020-07-09 09:38:28 +02:00
qtconcurrent CMake: Regenerate examples 2020-07-09 09:38:28 +02:00
qtestlib Don't depend on tools for the qtestlib examples 2020-08-12 19:37:15 +02:00
sql Deprecate QVariant::Type uses in QSqlField 2020-08-15 10:56:33 +02:00
vulkan Fix compiler warning about qsizetype/int mismatch 2020-08-04 13:28:33 +02:00
widgets Move QStringRef and remains to Qt5Compat 2020-08-20 00:58:13 +02:00
xml Port the QXmlStream API from QStringRef to QStringView 2020-08-19 19:48:03 +02:00
CMakeLists.txt CMake: Regenerate examples 2020-07-09 09:38:28 +02:00
examples.pro Doc: Move touch examples around so they get included in docs 2018-09-14 03:56:22 +00:00
README

Qt is supplied with a number of example applications that have been
written to provide developers with examples of the Qt API in use,
highlight good programming practice, and showcase features found in each of
Qt's core technologies.


Documentation for examples can be found in the Examples section
of the Qt documentation.