Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Split app and lib into different qmake projects #1

Open
wants to merge 2 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 12 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -16,3 +16,15 @@ app/QtNdiMonitorCapture.sln
app/QtNdiMonitorCapture.vcxproj
app/QtNdiMonitorCapture.vcxproj.filters
lib/support/simplecapture/pch.h.cpp
lib/debug/
lib/release/
plugins/*/debug/
plugins/*/release/
examples/*/debug/
examples/*/release/
Makefile*
debug_qmake_resources_qmlcache.qrc
release_qmake_resources_qmlcache.qrc
moc_.cpp.json
.qtc_clangd
.qmake.stash
26 changes: 9 additions & 17 deletions app/QtNdiMonitorCapture.pro
Original file line number Diff line number Diff line change
Expand Up @@ -11,29 +11,22 @@ CONFIG += c++17
INCLUDEPATH += ../lib/
INCLUDEPATH += ../lib/GraphicsCapture/

PRECOMPILED_HEADER = ../lib/GraphicsCapture/pch.h
win32:CONFIG(release, debug|release): LIBS += -L$$OUT_PWD/../lib/release/ -lQtNdi
else:win32:CONFIG(debug, debug|release): LIBS += -L$$OUT_PWD/../lib/debug/ -lQtNdi
else:unix: LIBS += -L$$OUT_PWD/../lib/ -lQtNdi

DEPENDPATH += $$PWD/../lib
$$PWD/../lib/GraphicsCapture

PRECOMPILED_HEADER =

HEADERS += \
MainWindow.h \
../lib/ndireceiver.h \
../lib/ndireceiverworker.h \
../lib/ndisender.h \
../lib/ndiwrapper.h \
../lib/GraphicsCapture/capture.interop.h \
../lib/GraphicsCapture/composition.interop.h \
../lib/GraphicsCapture/d3dHelpers.h \
../lib/GraphicsCapture/direct3d11.interop.h \
../lib/GraphicsCapture/SimpleCapture.h \
../lib/GraphicsCapture/Win32MonitorEnumeration.h

SOURCES += \
main.cpp \
MainWindow.cpp \
../lib/ndireceiver.cpp \
../lib/ndireceiverworker.cpp \
../lib/ndisender.cpp \
../lib/ndiwrapper.cpp \
../lib/GraphicsCapture/SimpleCapture.cpp \
../lib/GraphicsCapture/Win32MonitorEnumeration.cpp

RESOURCES = resources.qrc
Expand All @@ -42,8 +35,7 @@ TRANSLATIONS += \
QtNdiMonitorCapture_en_US.ts

DISTFILES += \
../.gitignore \
../lib/GraphicsCapture/readme.md
../.gitignore

CONFIG += lrelease
CONFIG += embed_translations
Expand Down
29 changes: 29 additions & 0 deletions examples/QtNdiQmlExample/QtNdiQmlExample.pro
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
QT += quickwidgets multimedia

CONFIG += c++17

SOURCES += \
main.cpp

resources.files = main.qml
resources.prefix = /$${TARGET}
RESOURCES += resources

TRANSLATIONS += \
QtNdiQmlExample_en_US.ts

CONFIG += lrelease
CONFIG += embed_translations

# Additional import path used to resolve QML modules in Qt Creator's code model
QML_IMPORT_PATH += \
$$PWD/../../plugins

# Additional import path used to resolve QML modules just for Qt Quick Designer
QML_DESIGNER_IMPORT_PATH = \
$$PWD/../../plugins

# Default rules for deployment.
qnx: target.path = /tmp/$${TARGET}/bin
else: unix:!android: target.path = /opt/$${TARGET}/bin
!isEmpty(target.path): INSTALLS += target
3 changes: 3 additions & 0 deletions examples/QtNdiQmlExample/QtNdiQmlExample_en_US.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
<?xml version="1.0" encoding="utf-8"?>
<!DOCTYPE TS>
<TS version="2.1" language="en_US"></TS>
40 changes: 40 additions & 0 deletions examples/QtNdiQmlExample/main.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
#include <QApplication>
#include <QQuickWidget>
#include <QQmlApplicationEngine>
#include <QLocale>
#include <QTranslator>

int main(int argc, char *argv[])
{
int returnCode = 0;

QApplication app(argc, argv);

QTranslator translator;
const QStringList uiLanguages = QLocale::system().uiLanguages();
for (const QString &locale : uiLanguages) {
const QString baseName = "QtNdiQmlExample_" + QLocale(locale).name();
if (translator.load(":/i18n/" + baseName)) {
app.installTranslator(&translator);
break;
}
}

QQuickWidget mainWindow;
mainWindow.engine()->addImportPath(QStringLiteral("../../plugins"));
const QUrl url(u"qrc:/QtNdiQmlExample/main.qml"_qs);
QQmlApplicationEngine engine = mainWindow.engine();
QObject::connect(&engine, &QQmlApplicationEngine::objectCreated,
&app, [url](QObject *obj, const QUrl &objUrl) {
if (!obj && url == objUrl)
QCoreApplication::exit(-1);
}, Qt::QueuedConnection);
mainWindow.setResizeMode(QQuickWidget::SizeRootObjectToView);
mainWindow.setSource(url);
QObject::connect(mainWindow.engine(), &QQmlEngine::quit, &mainWindow, &QQuickWidget::close);
mainWindow.show();
returnCode = app.exec();

qDebug() << "returnCode" << returnCode;
return returnCode;
}
34 changes: 34 additions & 0 deletions examples/QtNdiQmlExample/main.qml
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
import QtQuick
import QtQuickNdi
import QtMultimedia

Rectangle {
id: window
width: 800
height: 600
visible: true

Rectangle {
id: viewPort
anchors.fill: parent

QtNdiItem {
id: ndi
ndiSource: "BUGATTI (c922 Pro Stream Webcam)"
videoOutput: videoWindow1
}

VideoOutput {
id: videoWindow1
anchors.fill: parent
visible: ndi.active
}

MouseArea {
anchors.fill: parent
onClicked: ndi.active = !ndi.active
}
}


}
10 changes: 10 additions & 0 deletions examples/QtNdiQmlExample/plugin.qmltypes
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
import QtQuickNdi

Module {
Component {
name: "QtNdiItem"
prototype: "QQuickPaintedItem"
exports: ["QtQuickNdi/QtNdiItem 1.0"]
exportMetaObjectRevisions: [0]
}
}
43 changes: 43 additions & 0 deletions lib/QtNdi.pro
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
QT -= gui
QT += multimedia

TEMPLATE = lib
CONFIG += staticlib

CONFIG += c++17

INCLUDEPATH += GraphicsCapture/

PRECOMPILED_HEADER = GraphicsCapture/pch.h

HEADERS += \
qtndi.h \
ndireceiver.h \
ndireceiverworker.h \
ndisender.h \
ndiwrapper.h \
GraphicsCapture/composition.interop.h \
GraphicsCapture/d3dHelpers.h \
GraphicsCapture/direct3d11.interop.h \
GraphicsCapture/SimpleCapture.h

SOURCES += \
qtndi.cpp \
ndireceiver.cpp \
ndireceiverworker.cpp \
ndisender.cpp \
ndiwrapper.cpp \
GraphicsCapture/SimpleCapture.cpp

DISTFILES += \
GraphicsCapture/readme.md

QMAKE_CXXFLAGS += /Zc:twoPhase-

INCLUDEPATH += "../ndi/inc/"

# Default rules for deployment.
unix {
target.path = $$[QT_INSTALL_PLUGINS]/generic
}
!isEmpty(target.path): INSTALLS += target
5 changes: 5 additions & 0 deletions lib/qtndi.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
#include "qtndi.h"

QtNdi::QtNdi()
{
}
10 changes: 10 additions & 0 deletions lib/qtndi.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
#ifndef QTNDI_H
#define QTNDI_H

class QtNdi
{
public:
QtNdi();
};

#endif // QTNDI_H
54 changes: 54 additions & 0 deletions plugins/QtQuickNdi/QtQuickNdi.pro
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
TEMPLATE = lib
TARGET = QtQuickNdi
QT += qml quick quickwidgets multimedia multimediawidgets
CONFIG += plugin c++11 qmltypes metatypes

TARGET = $$qtLibraryTarget($$TARGET)
uri = QtQuickNdi

QML_IMPORT_NAME = QtQuickNdi
QML_IMPORT_MAJOR_VERSION = 1

INCLUDEPATH += $$PWD/../../lib/ \
$$PWD/../../lib/GraphicsCapture/ \
$$PWD/../../ndi/inc/

QMAKE_CXXFLAGS += /Zc:twoPhase-

win32 {
LIBS += -lwindowsapp
}

win32:CONFIG(release, debug|release): LIBS += -L$$OUT_PWD/../../lib/release/ -lQtNdi
else:win32:CONFIG(debug, debug|release): LIBS += -L$$OUT_PWD/../../lib/debug/ -lQtNdi
else:unix: LIBS += -L$$OUT_PWD/../../lib/ -lQtNdi

DEPENDPATH += $$PWD/../../lib/ \
$$PWD/../../lib/GraphicsCapture/

# Input
SOURCES += \
qtquickndi_plugin.cpp \
qtndiitem.cpp

HEADERS += \
qtquickndi_plugin.h \
qtndiitem.h

DISTFILES = qmldir

!equals(_PRO_FILE_PWD_, $$OUT_PWD) {
copy_qmldir.target = $$OUT_PWD/qmldir
copy_qmldir.depends = $$_PRO_FILE_PWD_/qmldir
copy_qmldir.commands = $(COPY_FILE) "$$replace(copy_qmldir.depends, /, $$QMAKE_DIR_SEP)" "$$replace(copy_qmldir.target, /, $$QMAKE_DIR_SEP)"
QMAKE_EXTRA_TARGETS += copy_qmldir
PRE_TARGETDEPS += $$copy_qmldir.target
}

qmldir.files = qmldir
unix {
installPath = $$[QT_INSTALL_QML]/$$replace(uri, \., /)
qmldir.path = $$installPath
target.path = $$installPath
INSTALLS += target qmldir
}
8 changes: 8 additions & 0 deletions plugins/QtQuickNdi/plugins.qmltypes
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
import QtQuick.tooling 1.2

// This file describes the plugin-supplied types contained in the library.
// It is used for QML tooling purposes only.
//
// This file was auto-generated by qmltyperegistrar.

Module {}
2 changes: 2 additions & 0 deletions plugins/QtQuickNdi/qmldir
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
module QtQuickNdi
plugin QtQuickNdi debug
Loading