From 6bc8caab5bfe57933e8ff365b04e139a22721253 Mon Sep 17 00:00:00 2001 From: MyungJoo Ham Date: Wed, 18 Jul 2018 17:08:55 +0900 Subject: [PATCH] [Example Apps] Build example apps out of nnstreamer context Build example_* apps in tizen build environment without nnstreamer build environment as if nnstreamer is already in Tizen and the apps are regular Tizen apps. In order to do this: - Add nnstreamer_testapp.spec: try gbs build --spec nnstreamer_testapp.spec to build test apps only - Add INSTALL_EXAMPLE_APP option to install example apps optionally. - Add tizen_app_build_example CMakeLists.txt to build example apps seperatedly. - Added format dependencies on gstreamer-app-1.0 With this we can ensure that nnstreamer-based apps can be built completely without nnstreamer source codes and we can verify packaging of nnstreamer-devel. Fixes #262 for Tizen. Signed-off-by: MyungJoo Ham --- CMakeLists.txt | 1 + nnstreamer_example/CMakeLists.txt | 12 +++++ nnstreamer_example/example_cam/CMakeLists.txt | 11 +++-- nnstreamer_example/example_filter/CMakeLists.txt | 11 +++-- nnstreamer_example/example_sink/CMakeLists.txt | 17 +++---- .../tizen_app_build_example/CMakeLists.txt | 28 +++++++++++ packaging/nnstreamer_testapp.spec | 54 ++++++++++++++++++++++ 7 files changed, 116 insertions(+), 18 deletions(-) create mode 100644 nnstreamer_example/tizen_app_build_example/CMakeLists.txt create mode 100644 packaging/nnstreamer_testapp.spec diff --git a/CMakeLists.txt b/CMakeLists.txt index 4c89cd6..e12c99e 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -4,6 +4,7 @@ PROJECT(nnstreamer C CXX) OPTION(TIZEN "Enable Tizen build mode" OFF) OPTION(DISABLE_TENSORFLOW_LITE "Disable tensorflow-lite support" OFF) +OPTION(INSTALL_EXAMPLE_APP "Install example applications" OFF) ADD_DEFINITIONS(-DVERSION="0.0.0") diff --git a/nnstreamer_example/CMakeLists.txt b/nnstreamer_example/CMakeLists.txt index b6432c4..415ef44 100644 --- a/nnstreamer_example/CMakeLists.txt +++ b/nnstreamer_example/CMakeLists.txt @@ -3,6 +3,18 @@ CMAKE_MINIMUM_REQUIRED(VERSION 2.8) ADD_SUBDIRECTORY(custom_example_passthrough) ADD_SUBDIRECTORY(custom_example_scaler) ADD_SUBDIRECTORY(custom_example_average) + +# Example App build requires a few additional attention if tizen_app_build_example is not used. + +SET(PKGAPP_MODULES + gstreamer-1.0 + gstreamer-base-1.0 + gstreamer-controller-1.0 + gstreamer-video-1.0 + gstreamer-app-1.0 +) +pkg_check_modules(apppkgs REQUIRED ${PKGAPP_MODULES}) + ADD_SUBDIRECTORY(example_cam) ADD_SUBDIRECTORY(example_sink) ADD_SUBDIRECTORY(example_filter) diff --git a/nnstreamer_example/example_cam/CMakeLists.txt b/nnstreamer_example/example_cam/CMakeLists.txt index ef4e945..9516f32 100644 --- a/nnstreamer_example/example_cam/CMakeLists.txt +++ b/nnstreamer_example/example_cam/CMakeLists.txt @@ -3,9 +3,10 @@ CMAKE_MINIMUM_REQUIRED(VERSION 2.8) # example app for webcam ADD_EXECUTABLE(nnstreamer_example_cam nnstreamer_example_cam.c) -TARGET_LINK_LIBRARIES(nnstreamer_example_cam ${pkgs_LIBRARIES}) -TARGET_INCLUDE_DIRECTORIES(nnstreamer_example_cam PUBLIC ${pkgs_INCLUDE_DIRS}) -TARGET_COMPILE_OPTIONS(nnstreamer_example_cam PUBLIC ${pkgs_CFLAGS_OTHER}) +TARGET_LINK_LIBRARIES(nnstreamer_example_cam ${apppkgs_LIBRARIES}) +TARGET_INCLUDE_DIRECTORIES(nnstreamer_example_cam PUBLIC ${apppkgs_INCLUDE_DIRS}) +TARGET_COMPILE_OPTIONS(nnstreamer_example_cam PUBLIC ${apppkgs_CFLAGS_OTHER}) -# do not install example app -# INSTALL(TARGETS nnstreamer_example_cam RUNTIME DESTINATION ${EXEC_PREFIX}) +IF (INSTALL_EXAMPLE_APP) + INSTALL(TARGETS nnstreamer_example_cam RUNTIME DESTINATION ${EXEC_PREFIX}) +ENDIF (INSTALL_EXAMPLE_APP) diff --git a/nnstreamer_example/example_filter/CMakeLists.txt b/nnstreamer_example/example_filter/CMakeLists.txt index f1e710f..25e00ae 100644 --- a/nnstreamer_example/example_filter/CMakeLists.txt +++ b/nnstreamer_example/example_filter/CMakeLists.txt @@ -3,9 +3,10 @@ CMAKE_MINIMUM_REQUIRED(VERSION 2.8) # demo app ADD_EXECUTABLE(nnstreamer_example_filter nnstreamer_example_filter.c) -TARGET_LINK_LIBRARIES(nnstreamer_example_filter ${pkgs_LIBRARIES}) -TARGET_INCLUDE_DIRECTORIES(nnstreamer_example_filter PUBLIC ${pkgs_INCLUDE_DIRS}) -TARGET_COMPILE_OPTIONS(nnstreamer_example_filter PUBLIC ${pkgs_CFLAGS_OTHER}) +TARGET_LINK_LIBRARIES(nnstreamer_example_filter ${apppkgs_LIBRARIES}) +TARGET_INCLUDE_DIRECTORIES(nnstreamer_example_filter PUBLIC ${apppkgs_INCLUDE_DIRS}) +TARGET_COMPILE_OPTIONS(nnstreamer_example_filter PUBLIC ${apppkgs_CFLAGS_OTHER}) -# do not install example app -# INSTALL(TARGETS nnstreamer_example_filter RUNTIME DESTINATION ${EXEC_PREFIX}) +IF (INSTALL_EXAMPLE_APP) + INSTALL(TARGETS nnstreamer_example_filter RUNTIME DESTINATION ${EXEC_PREFIX}) +ENDIF (INSTALL_EXAMPLE_APP) diff --git a/nnstreamer_example/example_sink/CMakeLists.txt b/nnstreamer_example/example_sink/CMakeLists.txt index 74d2f5a..089f52f 100644 --- a/nnstreamer_example/example_sink/CMakeLists.txt +++ b/nnstreamer_example/example_sink/CMakeLists.txt @@ -3,16 +3,17 @@ CMAKE_MINIMUM_REQUIRED(VERSION 2.8) # example 1 ADD_EXECUTABLE(nnstreamer_sink_example nnstreamer_sink_example.c) -TARGET_LINK_LIBRARIES(nnstreamer_sink_example ${pkgs_LIBRARIES}) -TARGET_INCLUDE_DIRECTORIES(nnstreamer_sink_example PUBLIC ${pkgs_INCLUDE_DIRS}) -TARGET_COMPILE_OPTIONS(nnstreamer_sink_example PUBLIC ${pkgs_CFLAGS_OTHER}) +TARGET_LINK_LIBRARIES(nnstreamer_sink_example ${apppkgs_LIBRARIES}) +TARGET_INCLUDE_DIRECTORIES(nnstreamer_sink_example PUBLIC ${apppkgs_INCLUDE_DIRS}) +TARGET_COMPILE_OPTIONS(nnstreamer_sink_example PUBLIC ${apppkgs_CFLAGS_OTHER}) # example 2 ADD_EXECUTABLE(nnstreamer_sink_example_play nnstreamer_sink_example_play.c) -TARGET_LINK_LIBRARIES(nnstreamer_sink_example_play gstapp-1.0 ${pkgs_LIBRARIES}) -TARGET_INCLUDE_DIRECTORIES(nnstreamer_sink_example_play PUBLIC ${pkgs_INCLUDE_DIRS}) -TARGET_COMPILE_OPTIONS(nnstreamer_sink_example_play PUBLIC ${pkgs_CFLAGS_OTHER}) +TARGET_LINK_LIBRARIES(nnstreamer_sink_example_play ${apppkgs_LIBRARIES}) +TARGET_INCLUDE_DIRECTORIES(nnstreamer_sink_example_play PUBLIC ${apppkgs_INCLUDE_DIRS}) +TARGET_COMPILE_OPTIONS(nnstreamer_sink_example_play PUBLIC ${apppkgs_CFLAGS_OTHER}) -# do not install sample app -# INSTALL(TARGETS nnstreamer_sink_example nnstreamer_sink_example_play RUNTIME DESTINATION ${EXEC_PREFIX}) +IF (INSTALL_EXAMPLE_APP) + INSTALL(TARGETS nnstreamer_sink_example nnstreamer_sink_example_play RUNTIME DESTINATION ${EXEC_PREFIX}) +ENDIF (INSTALL_EXAMPLE_APP) diff --git a/nnstreamer_example/tizen_app_build_example/CMakeLists.txt b/nnstreamer_example/tizen_app_build_example/CMakeLists.txt new file mode 100644 index 0000000..4534102 --- /dev/null +++ b/nnstreamer_example/tizen_app_build_example/CMakeLists.txt @@ -0,0 +1,28 @@ +CMAKE_MINIMUM_REQUIRED(VERSION 2.8) + +PROJECT(nnstreamer_testapp C) + +OPTION(INSTALL_EXAMPLE_APP "Install example applications" ON) + +SET(PREFIX ${CMAKE_INSTALL_PREFIX}) +SET(EXEC_PREFIX "${PREFIX}/bin") +SET(INCLUDEDIR "${PREFIX}/include/${PROJECT_NAME}") +IF(LIB_INSTALL_DIR) +ELSE(LIB_INSTALL_DIR) + SET(LIB_INSTALL_DIR "${PREFIX}/lib") +ENDIF(LIB_INSTALL_DIR) + +FIND_PACKAGE(PkgConfig REQUIRED) +SET(PKGAPP_MODULES + nnstreamer + gstreamer-1.0 + gstreamer-base-1.0 + gstreamer-controller-1.0 + gstreamer-video-1.0 + gstreamer-app-1.0 +) +pkg_check_modules(apppkgs REQUIRED ${PKGAPP_MODULES}) + +ADD_SUBDIRECTORY(../example_sink ${CMAKE_CURRENT_BINARY_DIR}/example_Sink) +ADD_SUBDIRECTORY(../example_cam ${CMAKE_CURRENT_BINARY_DIR}/example_cam) +ADD_SUBDIRECTORY(../example_filter ${CMAKE_CURRENT_BINARY_DIR}/example_filter) diff --git a/packaging/nnstreamer_testapp.spec b/packaging/nnstreamer_testapp.spec new file mode 100644 index 0000000..7f424ff --- /dev/null +++ b/packaging/nnstreamer_testapp.spec @@ -0,0 +1,54 @@ +Name: nnstreamer_testapp +Summary: test app for gstremaer plugins for neural networks +Version: 0.0.1 +Release: 1 +Group: Applications/Multimedia +Packager: MyungJoo Ham +License: LGPL-2.1 +Source0: nnstreamer_testapp-%{version}.tar.gz +Source1001: nnstreamer.manifest + +Requires: gstreamer >= 1.8.0 +Requires: nnstreamer +Requires: gst-plugins-good +Requires: gst-plugins-good-extra +Requires: gst-plugins-base +BuildRequires: pkg-config +BuildRequires: pkgconfig(nnstreamer) +BuildRequires: pkgconfig(gstreamer-1.0) +BuildRequires: pkgconfig(gstreamer-video-1.0) +BuildRequires: pkgconfig(gstreamer-app-1.0) +BuildRequires: cmake + +%description +NNStreamer is a set of gstreamer plugins to support general neural networks +and their plugins in a gstreamer stream. + +%prep +%setup -q +cp %{SOURCE1001} . + +%build +pushd nnstreamer_example/tizen_app_build_example +mkdir -p build +pushd build +%cmake .. +make %{?_smp_mflags} +popd +popd + +%install +pushd nnstreamer_example/tizen_app_build_example +pushd build +%make_install +popd +popd + +%files +%manifest nnstreamer.manifest +%defattr(-,root,root,-) +%{_bindir}/* + +%changelog +* Wed Jul 18 2018 MyungJoo Ham +- Tizen Test App Project Started -- 2.7.4