Priority: P2: Important
Affects Version/s: 6.0.0
Fix Version/s: None
Component/s: Build System: CMake
When using a static Qt, we can't build examples as part of the main Qt build due to issues with cyclic dependencies between the main Qt module libraries and the plugins (see
QTBUG-90819). We would have to manually link to the plugins in every example, but this is something that user projects wouldn't need to do and the examples would then be tainted with things that are only relevant to building Qt itself.
Ideally, we want the examples to be built in their own separate build. They should build against the Qt that the main build provides somehow. A potential solution to this is to move the examples out to their own test case(s) and make use of the ctest --build-and-test functionality. That ctest feature is specifically meant for situations like this, where you want to verify that a project can be configured and built.
While it would be nice to make every single example its own separate test case, that would have a fairly strong negative impact on test time. Every sub-build will need to do a full CMake run, which means performing compiler checks, etc. and this can take several seconds with some generators. We can minimise this impact by grouping examples by functionality, feature, etc. such that one test case builds multiple examples. We could potentially offer a CMake option for fine-grained tests if the user wanted it.
Tests support labels in CMake. We could potentially assign some labels based on the module, etc. for each example or group of examples. This would enable the developer to select just the subset of tests for the examples they want.
A further advantage of this approach is that it may open up the opportunity for building the examples against an existing Qt installation, similar to how we currently support the standalone test capabilities. This may have some advantages for CI as well.
|For Gerrit Dashboard: QTBUG-90820|
|334565,16||Build examples in isolated sub-builds using ExternalProject||dev||qt/qtbase||Status: MERGED||+2||0|
|334569,6||Switch examples to build as isolated sub-builds||dev||qt/qtdeclarative||Status: MERGED||+2||0|
|353148,2||CMake: Switch examples to build as isolated sub-builds||dev||qt/qtsvg||Status: MERGED||+2||0|
|368783,7||CMake: Allow opting out of building examples as ExternalProjects||dev||qt/qtbase||Status: MERGED||+2||0|
|369289,2||CMake: Allow opting out of building examples as ExternalProjects||6.2||qt/qtbase||Status: MERGED||+2||0|