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] -assimp .............. Select used assimp library [system/qt/no]
-qt3d-profile-jobs ... Enable jobs profiling [no] -qt3d-profile-jobs ... Enable jobs profiling [no]
-qt3d-profile-gl ..... Enable OpenGL 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 TEMPLATE = subdirs
SUBDIRS += qt3d
QT_FOR_CONFIG += 3dcore
qtConfig(qt3d-extras): SUBDIRS += qt3d

View File

@ -6,7 +6,12 @@
"options": { "options": {
"assimp": { "type": "enum", "values": [ "qt", "system", "no" ] }, "assimp": { "type": "enum", "values": [ "qt", "system", "no" ] },
"qt3d-profile-jobs": "boolean", "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", "privateFeature",
{ "type": "define", "name": "QT3D_OPENGL_RUN_STATS", "value": 1 } { "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", "assimp",
"system-assimp", "system-assimp",
"qt3d-profile-jobs", "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 #define QT3DCORE_GLOBAL_H
#include <QtCore/qglobal.h> #include <QtCore/qglobal.h>
#include <Qt3DCore/qt3dcore-config.h>
QT_BEGIN_NAMESPACE QT_BEGIN_NAMESPACE

View File

@ -3,7 +3,10 @@ TARGET = qtquickscene3dplugin
TARGETPATH = QtQuick/Scene3D TARGETPATH = QtQuick/Scene3D
IMPORT_VERSION = 2.0 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: # Qt3D is free of Q_FOREACH - make sure it stays that way:
DEFINES += QT_NO_FOREACH DEFINES += QT_NO_FOREACH

View File

@ -39,11 +39,19 @@
#include "scene3ditem_p.h" #include "scene3ditem_p.h"
#include <Qt3DCore/QAspectEngine> #include <Qt3DCore/qt3dcore_global.h>
#include <Qt3DCore/qentity.h> #include <Qt3DCore/qentity.h>
#include <Qt3DCore/QAspectEngine>
#if QT_CONFIG(qt3d_input)
#include <Qt3DInput/QInputAspect> #include <Qt3DInput/QInputAspect>
#include <Qt3DInput/qinputsettings.h> #include <Qt3DInput/qinputsettings.h>
#endif
#if QT_CONFIG(qt3d_logic)
#include <Qt3DLogic/qlogicaspect.h> #include <Qt3DLogic/qlogicaspect.h>
#endif
#include <Qt3DRender/QRenderAspect> #include <Qt3DRender/QRenderAspect>
#include <Qt3DRender/qcamera.h> #include <Qt3DRender/qcamera.h>
#include <Qt3DRender/qrendersurfaceselector.h> #include <Qt3DRender/qrendersurfaceselector.h>
@ -121,12 +129,20 @@ void Scene3DItem::setAspects(const QStringList &aspects)
if (aspect == QLatin1String("render")) // This one is hardwired anyway if (aspect == QLatin1String("render")) // This one is hardwired anyway
continue; continue;
if (aspect == QLatin1String("input")) { if (aspect == QLatin1String("input")) {
#if QT_CONFIG(qt3d_input)
m_aspectEngine->registerAspect(new Qt3DInput::QInputAspect); m_aspectEngine->registerAspect(new Qt3DInput::QInputAspect);
continue; 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 (aspect == QLatin1String("logic")) {
#if QT_CONFIG(qt3d_logic)
m_aspectEngine->registerAspect(new Qt3DLogic::QLogicAspect); m_aspectEngine->registerAspect(new Qt3DLogic::QLogicAspect);
continue; 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); 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 // Set ourselves up as a source of input events for the input aspect
Qt3DInput::QInputSettings *inputSettings = m_entity->findChild<Qt3DInput::QInputSettings *>(); Qt3DInput::QInputSettings *inputSettings = m_entity->findChild<Qt3DInput::QInputSettings *>();
if (inputSettings) { if (inputSettings) {
@ -196,6 +213,7 @@ void Scene3DItem::applyRootEntityChange()
} else { } else {
qCDebug(Scene3D) << "No Input Settings found, keyboard and mouse events won't be handled"; 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/segmentsvisitor.cpp \
$$PWD/commandthread.cpp $$PWD/commandthread.cpp
include($$OUT_PWD/../core/qt3dcore-config.pri)
QT_FOR_CONFIG += 3dcore-private QT_FOR_CONFIG += 3dcore-private
qtConfig(qt3d-profile-jobs): { qtConfig(qt3d-profile-jobs): {
HEADERS += $$PWD/commandexecuter_p.h HEADERS += $$PWD/commandexecuter_p.h

View File

@ -13,7 +13,7 @@ src_logic.depends = src_core
src_input.subdir = $$PWD/input src_input.subdir = $$PWD/input
src_input.target = sub-input src_input.target = sub-input
src_input.depends = src_render src_input.depends = src_core
src_animation.subdir = $$PWD/animation src_animation.subdir = $$PWD/animation
src_animation.target = sub-animation src_animation.target = sub-animation
@ -27,7 +27,7 @@ qtHaveModule(quick) {
# Quick3D libs # Quick3D libs
src_quick3d_core.subdir = $$PWD/quick3d/quick3d src_quick3d_core.subdir = $$PWD/quick3d/quick3d
src_quick3d_core.target = sub-quick3d-core 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.subdir = $$PWD/quick3d/quick3drender
src_quick3d_render.target = sub-quick3d-render 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.file = $$PWD/quick3d/imports/scene3d/importsscene3d.pro
src_quick3d_imports_scene3d.target = sub-quick3d-imports-scene3d 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.file = $$PWD/quick3d/imports/input/importsinput.pro
src_quick3d_imports_input.target = sub-quick3d-imports-input src_quick3d_imports_input.target = sub-quick3d-imports-input
@ -102,30 +102,57 @@ qtHaveModule(quick) {
SUBDIRS += \ SUBDIRS += \
src_core \ src_core \
src_render \
src_logic \
src_input \
src_animation \ src_animation \
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_extras \
src_plugins_sceneparsers \ src_plugins_sceneparsers \
src_plugins_geometryloaders \ src_plugins_geometryloaders
doc }
qtHaveModule(quick) { qtHaveModule(quick) {
SUBDIRS += \ SUBDIRS += \
src_quick3d_core \ src_quick3d_core \
src_quick3d_core_imports \ src_quick3d_core_imports
src_quick3d_render \
qtConfig(qt3d-input) {
SUBDIRS += \
src_quick3d_input \ src_quick3d_input \
src_quick3d_animation \ src_quick3d_imports_input
src_quick3d_extras \ }
qtConfig(qt3d-logic): SUBDIRS += src_quick3d_imports_logic
qtConfig(qt3d-render) {
SUBDIRS += \
src_quick3d_render \
src_quick3d_imports_render \ src_quick3d_imports_render \
src_quick3d_imports_scene3d \ src_quick3d_imports_scene3d
src_quick3d_imports_input \
src_quick3d_imports_logic \ qtConfig(qt3d-input) {
src_quick3d_imports_animation \ src_quick3d_imports_scene3d.depends += src_input
src_quick3d_imports_extras \ SUBDIRS += \
src_plugins_render \
src_quick3d_scene2d \ src_quick3d_scene2d \
src_quick3d_imports_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 = \ SUBDIRS = \
core \ core \
render \ cmake
quick3d \
cmake \
input \
animation \
extras
installed_cmake.depends = 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 \ material \
vsyncframeadvanceservice \ vsyncframeadvanceservice \
meshfunctors \ meshfunctors \
qmaterial \
qattribute \ qattribute \
qbuffer \ qbuffer \
qgeometry \ qgeometry \
@ -24,7 +23,6 @@ qtConfig(private_tests) {
buffer \ buffer \
attribute \ attribute \
geometry \ geometry \
geometryloaders \
geometryrenderer \ geometryrenderer \
raycasting \ raycasting \
qcameraselector \ qcameraselector \
@ -44,11 +42,8 @@ qtConfig(private_tests) {
framegraphnode \ framegraphnode \
qobjectpicker \ qobjectpicker \
objectpicker \ objectpicker \
picking \
# qboundingvolumedebug \ # qboundingvolumedebug \
# boundingvolumedebug \ # boundingvolumedebug \
boundingsphere \
qdefaultmeshes \
trianglesextractor \ trianglesextractor \
triangleboundingvolume \ triangleboundingvolume \
ddstextures \ ddstextures \
@ -70,8 +65,6 @@ qtConfig(private_tests) {
graphicshelpergl3_3 \ graphicshelpergl3_3 \
graphicshelpergl3_2 \ graphicshelpergl3_2 \
graphicshelpergl2 \ graphicshelpergl2 \
gltfplugins \
pickboundingvolumejob \
sendrendercapturejob \ sendrendercapturejob \
textures \ textures \
qparameter \ qparameter \
@ -81,8 +74,6 @@ qtConfig(private_tests) {
qabstracttexture \ qabstracttexture \
qabstracttextureimage \ qabstracttextureimage \
qrendersettings \ qrendersettings \
updatemeshtrianglelistjob \
updateshaderdatatransformjob \
texturedatamanager \ texturedatamanager \
rendertarget \ rendertarget \
transform \ transform \
@ -107,11 +98,29 @@ qtConfig(private_tests) {
memorybarrier \ memorybarrier \
qshaderprogram \ qshaderprogram \
qshaderprogrambuilder \ qshaderprogrambuilder \
qscene2d \
scene2d \
coordinatereader \ coordinatereader \
framegraphvisitor \ framegraphvisitor \
renderer 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 !macos: SUBDIRS += graphicshelpergl4
} }

View File

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

View File

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