Allow to disable aspects at configure time

This allows to remove dependencies and reduce deployment size when a given
aspect is not required.

Change-Id: I5aa90e4825b375cd446c47727aa11d03c40703c9
Reviewed-by: Oswald Buddenhagen <oswald.buddenhagen@qt.io>
Reviewed-by: Sean Harmer <sean.harmer@kdab.com>
This commit is contained in:
Paul Lemire 2017-07-04 09:47:15 +02:00
parent a20f0c5228
commit 718165fc24
12 changed files with 172 additions and 51 deletions

View File

@ -3,3 +3,8 @@ Qt3D options:
-assimp .............. Select used assimp library [system/qt/no]
-qt3d-profile-jobs ... Enable jobs profiling [no]
-qt3d-profile-gl ..... Enable OpenGL profiling [no]
-qt3d-render ......... Enable the Qt3D Render aspect [yes]
-qt3d-input .......... Enable the Qt3D Input aspect [yes]
-qt3d-logic .......... Enable the Qt3D Logic aspect [yes]
-qt3d-extras ......... Enable the Qt3D Extras aspect [yes]
-qt3d-animation....... Enable the Qt3D Animation aspect [yes]

View File

@ -1,2 +1,5 @@
TEMPLATE = subdirs
SUBDIRS += qt3d
QT_FOR_CONFIG += 3dcore
qtConfig(qt3d-extras): SUBDIRS += qt3d

View File

@ -6,7 +6,12 @@
"options": {
"assimp": { "type": "enum", "values": [ "qt", "system", "no" ] },
"qt3d-profile-jobs": "boolean",
"qt3d-profile-gl": "boolean"
"qt3d-profile-gl": "boolean",
"qt3d-render": "boolean",
"qt3d-input": "boolean",
"qt3d-logic": "boolean",
"qt3d-extras": "boolean",
"qt3d-animation": "boolean"
}
},
@ -48,6 +53,38 @@
"privateFeature",
{ "type": "define", "name": "QT3D_OPENGL_RUN_STATS", "value": 1 }
]
},
"qt3d-render": {
"label": "Render aspect",
"purpose": "Use the 3D Render Aspect library",
"section": "Aspects",
"output": [ "publicFeature" ]
},
"qt3d-input": {
"label": "Input aspect",
"purpose": "Use the 3D Input Aspect library",
"section": "Aspects",
"output": [ "publicFeature" ]
},
"qt3d-logic": {
"label": "Logic aspect",
"purpose": "Use the 3D Logic Aspect library",
"section": "Aspects",
"output": [ "publicFeature" ]
},
"qt3d-extras": {
"label": "Extras aspect",
"purpose": "Use the 3D Extra library",
"section": "Aspects",
"condition": "features.qt3d-render && features.qt3d-input && features.qt3d-logic",
"output": [ "publicFeature" ]
},
"qt3d-animation": {
"label": "Animation aspect",
"purpose": "Use the 3D Animation Aspect library",
"section": "Aspects",
"condition": "features.qt3d-render",
"output": [ "publicFeature" ]
}
},
@ -61,7 +98,17 @@
"assimp",
"system-assimp",
"qt3d-profile-jobs",
"qt3d-profile-gl"
"qt3d-profile-gl",
{
"section": "Aspects",
"entries": [
"qt3d-render",
"qt3d-input",
"qt3d-logic",
"qt3d-animation",
"qt3d-extras"
]
}
]
}
]

View File

@ -41,6 +41,7 @@
#define QT3DCORE_GLOBAL_H
#include <QtCore/qglobal.h>
#include <Qt3DCore/qt3dcore-config.h>
QT_BEGIN_NAMESPACE

View File

@ -3,7 +3,10 @@ TARGET = qtquickscene3dplugin
TARGETPATH = QtQuick/Scene3D
IMPORT_VERSION = 2.0
QT += qml quick 3dcore 3drender 3drender-private 3dinput 3dlogic
QT += qml quick 3dcore 3drender 3drender-private
qtConfig(qt3d-input): QT += 3dinput
qtConfig(qt3d-logic): QT += 3dlogic
# Qt3D is free of Q_FOREACH - make sure it stays that way:
DEFINES += QT_NO_FOREACH

View File

@ -39,11 +39,19 @@
#include "scene3ditem_p.h"
#include <Qt3DCore/QAspectEngine>
#include <Qt3DCore/qt3dcore_global.h>
#include <Qt3DCore/qentity.h>
#include <Qt3DCore/QAspectEngine>
#if QT_CONFIG(qt3d_input)
#include <Qt3DInput/QInputAspect>
#include <Qt3DInput/qinputsettings.h>
#endif
#if QT_CONFIG(qt3d_logic)
#include <Qt3DLogic/qlogicaspect.h>
#endif
#include <Qt3DRender/QRenderAspect>
#include <Qt3DRender/qcamera.h>
#include <Qt3DRender/qrendersurfaceselector.h>
@ -121,12 +129,20 @@ void Scene3DItem::setAspects(const QStringList &aspects)
if (aspect == QLatin1String("render")) // This one is hardwired anyway
continue;
if (aspect == QLatin1String("input")) {
#if QT_CONFIG(qt3d_input)
m_aspectEngine->registerAspect(new Qt3DInput::QInputAspect);
continue;
#else
qFatal("Scene3D requested the Qt 3D input aspect but Qt 3D wasn't configured to build the Qt 3D Input aspect");
#endif
}
if (aspect == QLatin1String("logic")) {
#if QT_CONFIG(qt3d_logic)
m_aspectEngine->registerAspect(new Qt3DLogic::QLogicAspect);
continue;
#else
qFatal("Scene3D requested the Qt 3D input aspect but Qt 3D wasn't configured to build the Qt 3D Input aspect");
#endif
}
m_aspectEngine->registerAspect(aspect);
}
@ -189,6 +205,7 @@ void Scene3DItem::applyRootEntityChange()
}
}
#if QT_CONFIG(qt3d_input)
// Set ourselves up as a source of input events for the input aspect
Qt3DInput::QInputSettings *inputSettings = m_entity->findChild<Qt3DInput::QInputSettings *>();
if (inputSettings) {
@ -196,6 +213,7 @@ void Scene3DItem::applyRootEntityChange()
} else {
qCDebug(Scene3D) << "No Input Settings found, keyboard and mouse events won't be handled";
}
#endif
}
}

View File

@ -81,7 +81,6 @@ SOURCES += \
$$PWD/segmentsvisitor.cpp \
$$PWD/commandthread.cpp
include($$OUT_PWD/../core/qt3dcore-config.pri)
QT_FOR_CONFIG += 3dcore-private
qtConfig(qt3d-profile-jobs): {
HEADERS += $$PWD/commandexecuter_p.h

View File

@ -13,7 +13,7 @@ src_logic.depends = src_core
src_input.subdir = $$PWD/input
src_input.target = sub-input
src_input.depends = src_render
src_input.depends = src_core
src_animation.subdir = $$PWD/animation
src_animation.target = sub-animation
@ -27,7 +27,7 @@ qtHaveModule(quick) {
# Quick3D libs
src_quick3d_core.subdir = $$PWD/quick3d/quick3d
src_quick3d_core.target = sub-quick3d-core
src_quick3d_core.depends = src_core src_input
src_quick3d_core.depends = src_core
src_quick3d_render.subdir = $$PWD/quick3d/quick3drender
src_quick3d_render.target = sub-quick3d-render
@ -60,7 +60,7 @@ qtHaveModule(quick) {
src_quick3d_imports_scene3d.file = $$PWD/quick3d/imports/scene3d/importsscene3d.pro
src_quick3d_imports_scene3d.target = sub-quick3d-imports-scene3d
src_quick3d_imports_scene3d.depends = src_quick3d_render src_input
src_quick3d_imports_scene3d.depends = src_quick3d_render
src_quick3d_imports_input.file = $$PWD/quick3d/imports/input/importsinput.pro
src_quick3d_imports_input.target = sub-quick3d-imports-input
@ -102,30 +102,57 @@ qtHaveModule(quick) {
SUBDIRS += \
src_core \
src_render \
src_logic \
src_input \
src_animation \
src_extras \
src_plugins_sceneparsers \
src_plugins_geometryloaders \
doc
QT_FOR_CONFIG += 3dcore
include($$OUT_PWD/core/qt3dcore-config.pri)
qtConfig(qt3d-input): SUBDIRS += src_input
qtConfig(qt3d-logic): SUBDIRS += src_logic
qtConfig(qt3d-render): SUBDIRS += src_render
qtConfig(qt3d-animation): SUBDIRS += src_animation
qtConfig(qt3d-extras) {
SUBDIRS += \
src_extras \
src_plugins_sceneparsers \
src_plugins_geometryloaders
}
qtHaveModule(quick) {
SUBDIRS += \
src_quick3d_core \
src_quick3d_core_imports \
src_quick3d_render \
src_quick3d_input \
src_quick3d_animation \
src_quick3d_extras \
src_quick3d_imports_render \
src_quick3d_imports_scene3d \
src_quick3d_imports_input \
src_quick3d_imports_logic \
src_quick3d_imports_animation \
src_quick3d_imports_extras \
src_plugins_render \
src_quick3d_scene2d \
src_quick3d_imports_scene2d
src_quick3d_core_imports
qtConfig(qt3d-input) {
SUBDIRS += \
src_quick3d_input \
src_quick3d_imports_input
}
qtConfig(qt3d-logic): SUBDIRS += src_quick3d_imports_logic
qtConfig(qt3d-render) {
SUBDIRS += \
src_quick3d_render \
src_quick3d_imports_render \
src_quick3d_imports_scene3d
qtConfig(qt3d-input) {
src_quick3d_imports_scene3d.depends += src_input
SUBDIRS += \
src_quick3d_scene2d \
src_quick3d_imports_scene2d
}
qtConfig(qt3d-logic): src_quick3d_imports_scene3d.depends += src_logic
}
qtConfig(qt3d-animation) {
SUBDIRS += \
src_quick3d_animation \
src_quick3d_imports_animation
}
qtConfig(qt3d-extras) {
SUBDIRS += \
src_quick3d_extras \
src_quick3d_imports_extras \
src_plugins_render
}
}

View File

@ -2,11 +2,14 @@ TEMPLATE = subdirs
SUBDIRS = \
core \
render \
quick3d \
cmake \
input \
animation \
extras
cmake
installed_cmake.depends = cmake
QT_FOR_CONFIG += 3dcore
qtConfig(qt3d-render): SUBDIRS += render
qtConfig(qt3d-input): SUBDIRS += input
qtConfig(qt3d-animation): SUBDIRS += animation
qtConfig(qt3d-extras): SUBDIRS += extras
qtConfig(qt3d-render):qtConfig(qt3d-input): SUBDIRS += quick3d

View File

@ -14,7 +14,6 @@ qtConfig(private_tests) {
material \
vsyncframeadvanceservice \
meshfunctors \
qmaterial \
qattribute \
qbuffer \
qgeometry \
@ -24,7 +23,6 @@ qtConfig(private_tests) {
buffer \
attribute \
geometry \
geometryloaders \
geometryrenderer \
raycasting \
qcameraselector \
@ -44,11 +42,8 @@ qtConfig(private_tests) {
framegraphnode \
qobjectpicker \
objectpicker \
picking \
# qboundingvolumedebug \
# boundingvolumedebug \
boundingsphere \
qdefaultmeshes \
trianglesextractor \
triangleboundingvolume \
ddstextures \
@ -70,8 +65,6 @@ qtConfig(private_tests) {
graphicshelpergl3_3 \
graphicshelpergl3_2 \
graphicshelpergl2 \
gltfplugins \
pickboundingvolumejob \
sendrendercapturejob \
textures \
qparameter \
@ -81,8 +74,6 @@ qtConfig(private_tests) {
qabstracttexture \
qabstracttextureimage \
qrendersettings \
updatemeshtrianglelistjob \
updateshaderdatatransformjob \
texturedatamanager \
rendertarget \
transform \
@ -107,11 +98,29 @@ qtConfig(private_tests) {
memorybarrier \
qshaderprogram \
qshaderprogrambuilder \
qscene2d \
scene2d \
coordinatereader \
framegraphvisitor \
renderer
QT_FOR_CONFIG = 3dcore-private
qtConfig(qt3d-extras) {
SUBDIRS += \
qmaterial \
geometryloaders \
picking \
boundingsphere \
qdefaultmeshes \
pickboundingvolumejob \
gltfplugins \
updatemeshtrianglelistjob \
updateshaderdatatransformjob
}
qtConfig(qt3d-input) {
SUBDIRS += \
qscene2d \
scene2d
}
!macos: SUBDIRS += graphicshelpergl4
}

View File

@ -1,4 +1,7 @@
TEMPLATE = subdirs
SUBDIRS = \
core \
render
core
QT_FOR_CONFIG += 3dcore
qtConfig(qt3d-render): SUBDIRS += render

View File

@ -1,8 +1,11 @@
TEMPLATE = subdirs
!package: SUBDIRS += \
auto \
manual
QT_FOR_CONFIG += 3dcore
!package {
SUBDIRS += auto
qtConfig(qt3d-extras): SUBDIRS += manual
}
# Benchmarks make sense in release mode only.
# Disable them for code coverage.