summaryrefslogtreecommitdiffstats
path: root/examples
diff options
context:
space:
mode:
authorAlexandru Croitor <alexandru.croitor@qt.io>2020-08-19 17:47:16 +0200
committerAlexandru Croitor <alexandru.croitor@qt.io>2020-08-23 11:04:04 +0200
commit5138a970f316203043c3ce3566719674431c757b (patch)
tree221ed3920372bdaf14ef3613dff83156959e2d28 /examples
parentdcf856ca7a4b4a645cb321417ddb3b78244bb43b (diff)
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>
Diffstat (limited to 'examples')
-rw-r--r--examples/dbus/remotecontrolledcar/car/CMakeLists.txt4
1 files changed, 2 insertions, 2 deletions
diff --git a/examples/dbus/remotecontrolledcar/car/CMakeLists.txt b/examples/dbus/remotecontrolledcar/car/CMakeLists.txt
index 142268c1ce..63b047484d 100644
--- a/examples/dbus/remotecontrolledcar/car/CMakeLists.txt
+++ b/examples/dbus/remotecontrolledcar/car/CMakeLists.txt
@@ -24,8 +24,8 @@ find_package(Qt6 COMPONENTS Widgets)
set(car_SRCS)
qt6_add_dbus_adaptor(car_SRCS
car.xml
- car.h
- Car
+ qobject.h
+ "" # empty parent_class value on purpose to not pass -l flag
car_adaptor
)
# special case end