summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGeorge Kiagiadakis <george.kiagiadakis@collabora.com>2012-04-08 15:17:46 +0300
committerGeorge Kiagiadakis <george.kiagiadakis@collabora.com>2012-04-08 15:17:46 +0300
commit8f5953496db383fec61d6f51f11ed051cf6a7378 (patch)
treebc645bba44034e5f721d6301cad6beb039aa8728
parent56938e2642949642b0f242de3b3eb4549bf8ada3 (diff)
examples: Improve the build system scripts
This commit makes: * all examples compilable with qmake. * all examples compilable with cmake out of the QtGStreamer build tree. * all examples compilable and runnable from the QtGStreamer build tree, without installing QtGStreamer.
-rw-r--r--examples/appsink-src/CMakeLists.txt8
-rw-r--r--examples/appsink-src/appsink-src.pro7
-rw-r--r--examples/player/CMakeLists.txt18
-rw-r--r--examples/player/player.pro8
-rw-r--r--examples/qmlplayer/CMakeLists.txt39
-rw-r--r--examples/qmlplayer/main.cpp14
-rw-r--r--examples/qmlplayer/qmlplayer.pro28
-rw-r--r--examples/qmlplayer/qmlplayer.qrc6
-rw-r--r--examples/recorder/CMakeLists.txt17
-rw-r--r--examples/recorder/recorder.pro24
-rw-r--r--examples/voip/CMakeLists.txt17
-rw-r--r--examples/voip/voip.pro24
12 files changed, 193 insertions, 17 deletions
diff --git a/examples/appsink-src/CMakeLists.txt b/examples/appsink-src/CMakeLists.txt
index 9985a38..c509693 100644
--- a/examples/appsink-src/CMakeLists.txt
+++ b/examples/appsink-src/CMakeLists.txt
@@ -1,9 +1,15 @@
# This file serves as an example of how to use cmake with QtGStreamer.
# It can be used for building this example either in the QtGStreamer source tree or standalone.
-find_package(QtGStreamer REQUIRED)
+project(qtgst-example-appsink-src)
+
+if (NOT BUILDING_QTGSTREAMER)
+ find_package(QtGStreamer REQUIRED)
+endif()
+
include_directories(${QTGSTREAMER_INCLUDES})
add_definitions(${QTGSTREAMER_DEFINITIONS})
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${QTGSTREAMER_FLAGS}")
+
add_executable(appsink-src main.cpp)
target_link_libraries(appsink-src ${QTGSTREAMER_UTILS_LIBRARIES})
diff --git a/examples/appsink-src/appsink-src.pro b/examples/appsink-src/appsink-src.pro
index a666cee..300da80 100644
--- a/examples/appsink-src/appsink-src.pro
+++ b/examples/appsink-src/appsink-src.pro
@@ -3,11 +3,14 @@
TEMPLATE = app
TARGET = appsink-src
+# produce nice compilation output
+CONFIG += silent
+
# Tell qmake to use pkg-config to find QtGStreamer.
CONFIG += link_pkgconfig
-# Now tell qmake to link to QtGStreamerUtils-0.10 and also use its include path and Cflags.
-PKGCONFIG += QtGStreamerUtils-0.10
+# Now tell qmake to link to QtGStreamer and also use its include path and Cflags.
+PKGCONFIG += QtGStreamer-0.10 QtGStreamerUtils-0.10
# Recommended if you are using g++ 4.5 or later. Must be removed for other compilers.
#QMAKE_CXXFLAGS += -std=c++0x
diff --git a/examples/player/CMakeLists.txt b/examples/player/CMakeLists.txt
index de0665f..3deccd2 100644
--- a/examples/player/CMakeLists.txt
+++ b/examples/player/CMakeLists.txt
@@ -1,6 +1,24 @@
+project(qtgst-example-player)
+
+if (NOT BUILDING_QTGSTREAMER)
+ find_package(QtGStreamer REQUIRED)
+
+ if (${CMAKE_VERSION} VERSION_LESS "2.8.6")
+ find_package(Automoc4 REQUIRED)
+ else()
+ set(CMAKE_AUTOMOC TRUE)
+
+ macro(automoc4_add_executable)
+ add_executable(${ARGV})
+ endmacro()
+ endif()
+endif()
+
include_directories(${QTGSTREAMER_INCLUDES} ${CMAKE_CURRENT_BINARY_DIR})
add_definitions(${QTGSTREAMER_DEFINITIONS})
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${QTGSTREAMER_FLAGS}")
+
set(player_SOURCES main.cpp player.cpp mediaapp.cpp)
+
automoc4_add_executable(player ${player_SOURCES})
target_link_libraries(player ${QTGSTREAMER_UI_LIBRARIES})
diff --git a/examples/player/player.pro b/examples/player/player.pro
index 6f1d967..3adde0b 100644
--- a/examples/player/player.pro
+++ b/examples/player/player.pro
@@ -3,10 +3,13 @@
TEMPLATE = app
TARGET = player
+# produce nice compilation output
+CONFIG += silent
+
# Tell qmake to use pkg-config to find QtGStreamer.
CONFIG += link_pkgconfig
-# Now tell qmake to link to QtGStreamer-0.10 and also use its include path and Cflags.
+# Now tell qmake to link to QtGStreamer and also use its include path and Cflags.
PKGCONFIG += QtGStreamer-0.10 QtGStreamerUi-0.10
# Recommended if you are using g++ 4.5 or later. Must be removed for other compilers.
@@ -16,9 +19,6 @@ PKGCONFIG += QtGStreamer-0.10 QtGStreamerUi-0.10
# You can otherwise also define QT_NO_EMIT, but notice that this is not a documented Qt macro.
DEFINES += QT_NO_KEYWORDS
-# This example has no GUI
-QT -= gui
-
# Input
HEADERS += mediaapp.h player.h
SOURCES += main.cpp mediaapp.cpp player.cpp
diff --git a/examples/qmlplayer/CMakeLists.txt b/examples/qmlplayer/CMakeLists.txt
index 8ebda56..80781da 100644
--- a/examples/qmlplayer/CMakeLists.txt
+++ b/examples/qmlplayer/CMakeLists.txt
@@ -1,20 +1,43 @@
+project(qtgst-example-qmlplayer)
+
+if (NOT BUILDING_QTGSTREAMER)
+ find_package(Qt4 COMPONENTS QtCore QtGui QtDeclarative REQUIRED)
+ find_package(QtGStreamer REQUIRED)
+
+ if (${CMAKE_VERSION} VERSION_LESS "2.8.6")
+ find_package(Automoc4 REQUIRED)
+ else()
+ set(CMAKE_AUTOMOC TRUE)
+
+ macro(automoc4_add_executable)
+ add_executable(${ARGV})
+ endmacro()
+ endif()
+else()
+ # allow the example to run from the build tree without installing QtGStreamer
+ add_definitions(
+ -DQTVIDEOSINK_PATH="${QtGStreamer_BINARY_DIR}/elements/gstqtvideosink"
+ -DUNINSTALLED_IMPORTS_DIR="${QtGStreamer_BINARY_DIR}/src/qml"
+ )
+endif()
+
include_directories(${QTGSTREAMER_INCLUDES} ${CMAKE_CURRENT_BINARY_DIR})
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${QTGSTREAMER_FLAGS}")
+add_definitions(${QTGSTREAMER_DEFINITIONS})
-add_definitions(
- ${QTGSTREAMER_DEFINITIONS}
- -DCMAKE_CURRENT_SOURCE_DIR="${CMAKE_CURRENT_SOURCE_DIR}"
- -DUNINSTALLED_IMPORTS_DIR="${CMAKE_BINARY_DIR}/src/qml"
-)
-
-if (${QT_QTOPENGL_FOUND})
+if (QT_QTOPENGL_FOUND)
set(qmlplayer_gl_libs ${QT_QTOPENGL_LIBRARY})
else()
add_definitions(-DQMLPLAYER_NO_OPENGL)
endif()
set(qmlplayer_SOURCES main.cpp player.cpp)
-automoc4_add_executable(qmlplayer ${qmlplayer_SOURCES})
+qt4_add_resources(qmlplayer_rcc_SOURCES qmlplayer.qrc)
+
+automoc4_add_executable(qmlplayer
+ ${qmlplayer_SOURCES}
+ ${qmlplayer_rcc_SOURCES}
+)
target_link_libraries(qmlplayer
${QTGSTREAMER_UI_LIBRARIES}
${QT_QTDECLARATIVE_LIBRARY}
diff --git a/examples/qmlplayer/main.cpp b/examples/qmlplayer/main.cpp
index 88cb36b..a6c8cab 100644
--- a/examples/qmlplayer/main.cpp
+++ b/examples/qmlplayer/main.cpp
@@ -16,6 +16,7 @@
along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#include "player.h"
+#include <cstdlib>
#include <QtGui/QApplication>
#include <QtDeclarative/QDeclarativeView>
#include <QtDeclarative/QDeclarativeContext>
@@ -29,12 +30,17 @@
int main(int argc, char **argv)
{
+#if defined(QTVIDEOSINK_PATH)
+ //this allows the example to run from the QtGStreamer build tree without installing QtGStreamer
+ setenv("GST_PLUGIN_PATH", QTVIDEOSINK_PATH, 0);
+#endif
+
QApplication app(argc, argv);
QGst::init(&argc, &argv);
QDeclarativeView view;
-#ifndef QMLPLAYER_NO_OPENGL
+#if !defined(QMLPLAYER_NO_OPENGL)
/*
* Setting a QGLWidget as the viewport is highly recommended as
* it enables hardware scaling & color conversion on the video sink
@@ -49,8 +55,12 @@ int main(int argc, char **argv)
player->setVideoSink(surface->videoSink());
view.rootContext()->setContextProperty(QLatin1String("player"), player);
+#if defined(UNINSTALLED_IMPORTS_DIR)
+ //this allows the example to run from the QtGStreamer build tree without installing QtGStreamer
view.engine()->addImportPath(QLatin1String(UNINSTALLED_IMPORTS_DIR));
- view.setSource(QUrl::fromLocalFile(QLatin1String(CMAKE_CURRENT_SOURCE_DIR "/qmlplayer.qml")));
+#endif
+
+ view.setSource(QUrl(QLatin1String("qrc:///qmlplayer.qml")));
view.show();
return app.exec();
diff --git a/examples/qmlplayer/qmlplayer.pro b/examples/qmlplayer/qmlplayer.pro
new file mode 100644
index 0000000..4d7bfd6
--- /dev/null
+++ b/examples/qmlplayer/qmlplayer.pro
@@ -0,0 +1,28 @@
+# This is a qmake project file, provided as an example on how to use qmake with QtGStreamer.
+
+TEMPLATE = app
+TARGET = qmlplayer
+
+# produce nice compilation output
+CONFIG += silent
+
+# Tell qmake to use pkg-config to find QtGStreamer.
+CONFIG += link_pkgconfig
+
+# Now tell qmake to link to QtGStreamer and also use its include path and Cflags.
+PKGCONFIG += QtGStreamer-0.10 QtGStreamerUi-0.10
+
+# Recommended if you are using g++ 4.5 or later. Must be removed for other compilers.
+#QMAKE_CXXFLAGS += -std=c++0x
+
+# Recommended, to avoid possible issues with the "emit" keyword
+# You can otherwise also define QT_NO_EMIT, but notice that this is not a documented Qt macro.
+DEFINES += QT_NO_KEYWORDS
+
+# link against QtDeclarative and QtOpenGL
+QT += declarative opengl
+
+# Input
+HEADERS += player.h
+SOURCES += main.cpp player.cpp
+RESOURCES += qmlplayer.qrc
diff --git a/examples/qmlplayer/qmlplayer.qrc b/examples/qmlplayer/qmlplayer.qrc
new file mode 100644
index 0000000..ebbb493
--- /dev/null
+++ b/examples/qmlplayer/qmlplayer.qrc
@@ -0,0 +1,6 @@
+<!DOCTYPE RCC>
+<RCC version="1.0">
+ <qresource>
+ <file>qmlplayer.qml</file>
+ </qresource>
+</RCC>
diff --git a/examples/recorder/CMakeLists.txt b/examples/recorder/CMakeLists.txt
index 8352a3f..96937b9 100644
--- a/examples/recorder/CMakeLists.txt
+++ b/examples/recorder/CMakeLists.txt
@@ -1,6 +1,23 @@
+project(qtgst-example-recorder)
+
+if (NOT BUILDING_QTGSTREAMER)
+ find_package(QtGStreamer REQUIRED)
+
+ if (${CMAKE_VERSION} VERSION_LESS "2.8.6")
+ find_package(Automoc4 REQUIRED)
+ else()
+ set(CMAKE_AUTOMOC TRUE)
+
+ macro(automoc4_add_executable)
+ add_executable(${ARGV})
+ endmacro()
+ endif()
+endif()
+
include_directories(${QTGSTREAMER_INCLUDES} ${CMAKE_CURRENT_BINARY_DIR})
add_definitions(${QTGSTREAMER_DEFINITIONS})
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${QTGSTREAMER_FLAGS}")
+
qt4_wrap_ui(recorder_UI_SRCS recorder.ui)
automoc4_add_executable(recorder main.cpp ${recorder_UI_SRCS})
target_link_libraries(recorder ${QTGSTREAMER_LIBRARIES} ${QT_QTGUI_LIBRARY})
diff --git a/examples/recorder/recorder.pro b/examples/recorder/recorder.pro
new file mode 100644
index 0000000..e31c7e4
--- /dev/null
+++ b/examples/recorder/recorder.pro
@@ -0,0 +1,24 @@
+# This is a qmake project file, provided as an example on how to use qmake with QtGStreamer.
+
+TEMPLATE = app
+TARGET = recorder
+
+# produce nice compilation output
+CONFIG += silent
+
+# Tell qmake to use pkg-config to find QtGStreamer.
+CONFIG += link_pkgconfig
+
+# Now tell qmake to link to QtGStreamer and also use its include path and Cflags.
+PKGCONFIG += QtGStreamer-0.10
+
+# Recommended if you are using g++ 4.5 or later. Must be removed for other compilers.
+#QMAKE_CXXFLAGS += -std=c++0x
+
+# Recommended, to avoid possible issues with the "emit" keyword
+# You can otherwise also define QT_NO_EMIT, but notice that this is not a documented Qt macro.
+DEFINES += QT_NO_KEYWORDS
+
+# Input
+FORMS += recorder.ui
+SOURCES += main.cpp
diff --git a/examples/voip/CMakeLists.txt b/examples/voip/CMakeLists.txt
index ef8dacf..48705a3 100644
--- a/examples/voip/CMakeLists.txt
+++ b/examples/voip/CMakeLists.txt
@@ -1,6 +1,23 @@
+project(qtgst-example-voip)
+
+if (NOT BUILDING_QTGSTREAMER)
+ find_package(QtGStreamer REQUIRED)
+
+ if (${CMAKE_VERSION} VERSION_LESS "2.8.6")
+ find_package(Automoc4 REQUIRED)
+ else()
+ set(CMAKE_AUTOMOC TRUE)
+
+ macro(automoc4_add_executable)
+ add_executable(${ARGV})
+ endmacro()
+ endif()
+endif()
+
include_directories(${QTGSTREAMER_INCLUDES} ${CMAKE_CURRENT_BINARY_DIR})
add_definitions(${QTGSTREAMER_DEFINITIONS})
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${QTGSTREAMER_FLAGS}")
+
qt4_wrap_ui(voip_UI_SRCS voip.ui)
automoc4_add_executable(voip main.cpp ${voip_UI_SRCS})
target_link_libraries(voip ${QTGSTREAMER_UI_LIBRARIES})
diff --git a/examples/voip/voip.pro b/examples/voip/voip.pro
new file mode 100644
index 0000000..07169e5
--- /dev/null
+++ b/examples/voip/voip.pro
@@ -0,0 +1,24 @@
+# This is a qmake project file, provided as an example on how to use qmake with QtGStreamer.
+
+TEMPLATE = app
+TARGET = voip
+
+# produce nice compilation output
+CONFIG += silent
+
+# Tell qmake to use pkg-config to find QtGStreamer.
+CONFIG += link_pkgconfig
+
+# Now tell qmake to link to QtGStreamer and also use its include path and Cflags.
+PKGCONFIG += QtGStreamer-0.10 QtGStreamerUi-0.10
+
+# Recommended if you are using g++ 4.5 or later. Must be removed for other compilers.
+#QMAKE_CXXFLAGS += -std=c++0x
+
+# Recommended, to avoid possible issues with the "emit" keyword
+# You can otherwise also define QT_NO_EMIT, but notice that this is not a documented Qt macro.
+DEFINES += QT_NO_KEYWORDS
+
+# Input
+FORMS += voip.ui
+SOURCES += main.cpp