Last active
October 8, 2019 13:00
-
-
Save pepijndevos/60a6b76e1f00b80a4826f157a24adce7 to your computer and use it in GitHub Desktop.
Assorted build files
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
cmake_minimum_required(VERSION 3.10.2) | |
project(MyFancyProject) | |
set(CMAKE_MODULE_PATH ${CMAKE_CURRENT_SOURCE_DIR}) | |
# 3rd party tools | |
find_package(Qt5 COMPONENTS | |
Widgets Network Qml Quick | |
Gamepad QuickControls2 REQUIRED) | |
find_package(RTI REQUIRED) | |
find_package(PkgConfig) | |
pkg_check_modules(GST REQUIRED | |
gstreamer-1.0 | |
gstreamer-base-1.0 | |
gstreamer-plugins-base-1.0 | |
gstreamer-video-1.0 | |
gstreamer-app-1.0 | |
) | |
if(ANDROID) | |
find_package(Qt5 COMPONENTS | |
AndroidExtras Svg REQUIRED) | |
pkg_check_modules(GST REQUIRED | |
gstreamer-app-1.0 | |
gstreamer-audio-1.0 | |
gstreamer-gl-1.0 | |
gstreamer-rtp-1.0 | |
gstreamer-controller-1.0 | |
gstreamer-pbutils-1.0 | |
gstreamer-net-1.0 | |
gstreamer-tag-1.0 | |
gio-2.0 | |
#egl | |
graphene-1.0 | |
libpng16 | |
#zlib | |
) | |
endif() | |
INCLUDE_DIRECTORIES( | |
"include" | |
${RTI_INCLUDE_DIRS} | |
${Qt5Widgets_INCLUDE_DIRS} | |
${Qt5Network_INCLUDE_DIRS} | |
${QtQml_INCLUDE_DIRS} | |
${Qt5QuickControls2_INCLUDE_DIRS} | |
${Qt5Gamepad_INCLUDE_DIRS} | |
${Qt5AndroidExtras_INCLUDE_DIRS} | |
${Qt5Svg_INCLUDE_DIRS} | |
${GST_INCLUDE_DIRS} | |
) | |
link_directories ( | |
${GST_LIBRARY_DIRS} | |
$ENV{GSTREAMER_ROOT}/lib/gstreamer-1.0 | |
) | |
IF (WIN32) | |
INCLUDE_DIRECTORIES( | |
"C:\\Program Files\\MyFancyProject\\Include" | |
) | |
link_directories ( | |
"C:\\Program Files\\MyFancyProject\\lib" | |
) | |
set(CMAKE_INSTALL_PREFIX | |
"C:/Program Files/MyFancyProject" | |
) | |
ENDIF() | |
add_definitions( | |
${Qt5Widgets_DEFINITIONS} | |
${QtQml_DEFINITIONS} | |
${Qt5Quick_DEFINITIONS} | |
${Qt5Network_DEFINITIONS} | |
${Qt5QuickControls2_DEFINITIONS} | |
${Qt5Gamepad_DEFINITIONS} | |
${Qt5AndroidExtras_DEFINITIONS} | |
${Qt5Svg_DEFINITIONS} | |
${RTI_DEFINITIONS} | |
) | |
# Directory with the source code | |
add_subdirectory(src) | |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
############################################################################## | |
# Try to find RTI | |
# Once done this will define: | |
# | |
# RTI_FOUND - system has RTI. | |
# RTI_INCLUDE_DIRS - the RTI include directory. | |
# RTI_LIBRARIES - Link these to use RTI. | |
# RTI_IDLGEN_BINARY - Binary for the IDL compiler. | |
# | |
# You need the environment variable $NDDSHOME to be set to your RTI | |
# installation directory. | |
# This script also includes the MacroRTI.cmake script, which is useful | |
# for generating code from your idl. | |
# | |
############################################################################## | |
# Courtesy of Ivan Galvez Junquera <ivgalvez@gmail.com> | |
############################################################################## | |
SET(RTI_TARGET_ARCH "x64Linux3gcc5.4.0" CACHE STRING "DDS target") | |
# x64Linux3gcc5.4.0 | |
# armv6vfphLinux3.xgcc4.7.2 | |
# armv7aAndroid5.0gcc4.9ndkr10e | |
SET(RTI_INCLUDE_DIRS | |
$ENV{NDDSHOME}/include | |
$ENV{NDDSHOME}/include/ndds | |
$ENV{NDDSHOME}/include/ndds/hpp | |
) | |
# Find libraries | |
FIND_LIBRARY(KERNEL_LIBRARY | |
NAMES | |
nddscore | |
PATHS | |
$ENV{NDDSHOME}/lib/${RTI_TARGET_ARCH} | |
) | |
FIND_LIBRARY(DCPSISOC_LIBRARY | |
NAMES | |
nddsc | |
PATHS | |
$ENV{NDDSHOME}/lib/${RTI_TARGET_ARCH} | |
) | |
FIND_LIBRARY(DCPSISOCPP_LIBRARY | |
NAMES | |
nddscpp2 | |
PATHS | |
$ENV{NDDSHOME}/lib/${RTI_TARGET_ARCH} | |
) | |
SET(RTI_LIBRARIES | |
${KERNEL_LIBRARY} | |
${DCPSISOCPP_LIBRARY} | |
${DCPSISOC_LIBRARY}) | |
IF(RTI_TARGET_ARCH STREQUAL "x64Linux3gcc5.4.0") | |
SET(RTI_DEFINITIONS | |
-DRTI_UNIX | |
-DRTI_LINUX | |
-DRTI_64BIT) | |
ELSEIF(RTI_TARGET_ARCH STREQUAL "armv6vfphLinux3.xgcc4.7.2") | |
SET(RTI_DEFINITIONS | |
-fpic | |
-DRTI_UNIX | |
-DRTI_LINUX | |
-march=armv6 | |
-mfpu=vfp | |
-mfloat-abi=hard | |
-mlong-calls) | |
ELSEIF(RTI_TARGET_ARCH STREQUAL "armv7aAndroid5.0gcc4.9ndkr10e") | |
SET(RTI_DEFINITIONS | |
-fpic | |
-DRTI_UNIX | |
-DLINUX | |
-DRTI_LINUX | |
-DRTI_ANDROID) | |
ELSE() | |
MESSAGE(FATAL_ERROR "Unsupported target") | |
ENDIF() | |
# Binary for the IDL compiler | |
SET (RTI_IDLGEN_BINARY $ENV{NDDSHOME}/bin/rtiddsgen) | |
IF (RTI_LIBRARIES) | |
SET(RTI_FOUND TRUE) | |
ENDIF (RTI_LIBRARIES) | |
IF (RTI_FOUND) | |
MESSAGE(STATUS "Found RTI DDS libraries: ${RTI_LIBRARIES}") | |
ELSE (RTI_FOUND) | |
MESSAGE(FATAL_ERROR "Could not find RTI DDS") | |
ENDIF (RTI_FOUND) | |
MARK_AS_ADVANCED(RTI_INCLUDE_DIRS RTI_LIBRARIES RTI_IDLGEN_BINARY) | |
INCLUDE (MacroRTI) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#ifndef GSTREAMER_ANDROID_H | |
#define GSTREAMER_ANDROID_H | |
#include <QtAndroid> | |
#include <QAndroidJniEnvironment> | |
#include <gst/gst.h> | |
G_BEGIN_DECLS | |
void gst_android_init (JNIEnv * env, jobject context); | |
gboolean gst_qt_android_init (GError ** error); | |
G_END_DECLS | |
#endif // GSTREAMER_ANDROID_H |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Macro to create a list with all the generated source files for a given .idl filename | |
MACRO (DEFINE_RTI_SOURCES idlfilename) | |
SET(outsources) | |
SET(outheaders) | |
GET_FILENAME_COMPONENT(it ${idlfilename} ABSOLUTE) | |
GET_FILENAME_COMPONENT(nfile ${idlfilename} NAME_WE) | |
SET(outsources ${outsources} ${nfile}.cxx ${nfile}Impl.cxx ${nfile}ImplPlugin.cxx) | |
SET(outheaders ${outheaders} ${nfile}.hpp ${nfile}Impl.h ${nfile}ImplPlugin.h) | |
ENDMACRO(DEFINE_RTI_SOURCES) | |
MACRO (RTI_IDLGEN idlfilename) | |
GET_FILENAME_COMPONENT(it ${idlfilename} ABSOLUTE) | |
GET_FILENAME_COMPONENT(idlfilename ${idlfilename} NAME) | |
DEFINE_RTI_SOURCES(${ARGV}) | |
ADD_CUSTOM_COMMAND ( | |
OUTPUT ${outsources} ${outheaders} | |
COMMAND ${RTI_IDLGEN_BINARY} | |
ARGS -language c++11 -update typefiles -d . ${it} | |
DEPENDS ${it} | |
) | |
ENDMACRO (RTI_IDLGEN) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include "gstreamer_android.h" | |
extern "C" | |
gboolean | |
gst_qt_android_init (GError ** error) | |
{ | |
QAndroidJniEnvironment jniEnv; | |
JNIEnv *env = jniEnv; | |
QAndroidJniObject QJObj = QtAndroid::androidActivity(); | |
jobject context = QJObj.object<jobject> (); | |
gst_android_init (jniEnv, context); | |
if (env->ExceptionCheck()) { | |
jclass throwable_class = env->FindClass("java/lang/Throwable"); | |
jmethodID throwable_to_string_id = env->GetMethodID(throwable_class, "toString", "()Ljava/lang/String;"); | |
jstring msg_obj = (jstring) env->CallObjectMethod (context, throwable_to_string_id); | |
const char* msg_str = env->GetStringUTFChars (msg_obj, 0); | |
g_set_error (error, GST_LIBRARY_ERROR, GST_LIBRARY_ERROR_INIT, "%s", msg_str); | |
env->ReleaseStringUTFChars (msg_obj, msg_str); | |
env->DeleteLocalRef (throwable_class); | |
env->DeleteLocalRef (msg_obj); | |
return FALSE; | |
} | |
return TRUE; | |
} | |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
TEMPLATE = lib | |
CONFIG += staticlib | |
TARGET = gstqmlgl | |
QT += qml quick widgets gui | |
QT_CONFIG -= no-pkg-config | |
CONFIG += link_pkgconfig debug plugin | |
PKGCONFIG = \ | |
gstreamer-1.0 \ | |
gstreamer-video-1.0 \ | |
gstreamer-gl-1.0 | |
DEFINES += \ | |
GST_USE_UNSTABLE_API \ | |
HAVE_QT_EGLFS | |
SOURCES += \ | |
gstplugin.cc \ | |
gstqtglutility.cc \ | |
gstqsgtexture.cc \ | |
gstqtsink.cc \ | |
gstqtsrc.cc \ | |
qtwindow.cc \ | |
qtitem.cc | |
HEADERS += \ | |
gstqsgtexture.h \ | |
gstqtgl.h \ | |
gstqtglutility.h \ | |
gstqtsink.h \ | |
gstqtsrc.h \ | |
qtwindow.h \ | |
qtitem.h | |
INCLUDEPATH += \ | |
$$(GSTREAMER_ROOT)/include \ | |
$$[QT_INSTALL_PREFIX]/include/QtGui/$$[QT_VERSION]/QtGui/ | |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
qt5_add_resources(QT_RESOURCES ../resources/qml.qrc) | |
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${Qt5Widgets_EXECUTABLE_COMPILE_FLAGS}") | |
set(CMAKE_AUTOMOC ON) | |
set(CMAKE_AUTORCC ON) | |
set(CMAKE_AUTOUIC ON) | |
set(PROJECT "RoVeController") | |
project(${PROJECT}) | |
set(CMAKE_CXX_STANDARD 14) | |
set(SOURCES | |
"main.cpp" | |
"more code" | |
) | |
set(HEADERS | |
"../include/headers.h | |
) | |
set(ANDROID_SOURCES | |
"gstreamer_android-1.0.c" | |
"qt_gstreamer_android-1.0.cpp" | |
) | |
set(ANDROID_HEADERS | |
"../include/gstreamer_android.h" | |
) | |
# Hackety hack, on Android I copied the libraries into NDDS | |
# If it's stupid but it works, it's still kinda stupid. | |
# at least it works... | |
FIND_LIBRARY(OPERATOR_LIBRARY | |
NAMES Operator | |
PATHS $ENV{NDDSHOME}/lib/${RTI_TARGET_ARCH} | |
) | |
FIND_LIBRARY(MULTIMEDIA_LIBRARY | |
NAMES Multimedia | |
PATHS $ENV{NDDSHOME}/lib/${RTI_TARGET_ARCH} | |
) | |
if(ANDROID) | |
add_library(${PROJECT} SHARED | |
${HEADERS} ${ANDROID_HEADERS} | |
${SOURCES} ${ANDROID_SOURCES} | |
${QT_RESOURCES} | |
) | |
else() | |
add_executable(${PROJECT} ${HEADERS} ${SOURCES} ${QT_RESOURCES}) | |
endif() | |
target_link_libraries(${PROJECT} | |
Qt5::Widgets | |
Qt5::Network | |
Qt5::Qml | |
Qt5::Quick | |
Qt5::QuickControls2 | |
Qt5::Gamepad | |
${OPERATOR_LIBRARY} | |
${MULTIMEDIA_LIBRARY} | |
${RTI_LIBRARIES} | |
${GST_LIBRARIES} | |
) | |
if(ANDROID) | |
target_link_libraries(${PROJECT} | |
Qt5::AndroidExtras | |
Qt5::Svg | |
#gst plugins | |
gstapp | |
gstrtpmanager | |
gstrtp | |
gstvideoscale | |
gstvideoconvert | |
gstvideofilter | |
gstqmlgl | |
gstopengl | |
gstlibav | |
#gst plugin deps | |
avformat | |
avcodec | |
avfilter | |
avutil | |
swresample | |
bz2 | |
jpeg | |
EGL | |
GLESv2 | |
log | |
#gst libraries | |
${GST_STATIC_LIBRARIES} | |
) | |
endif() | |
install(TARGETS ${PROJECT} | |
DESTINATION bin) | |
if(ANDROID) | |
include(../../qt-android-cmake/AddQtAndroidApk.cmake) | |
add_qt_android_apk(${PROJECT}_apk ${PROJECT} | |
BUILDTOOLS_REVISION "28.0.2" | |
DEPENDS ${RTI_LIBRARIES} ${OPERATOR_LIBRARY} ${MULTIMEDIA_LIBRARY} | |
) | |
endif() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment