[Build] Make a central CMake file for all plugins
authorMyungJoo Ham <myungjoo.ham@samsung.com>
Wed, 23 May 2018 11:05:48 +0000 (20:05 +0900)
committer함명주/동작제어Lab(SR)/Principal Engineer/삼성전자 <myungjoo.ham@samsung.com>
Fri, 25 May 2018 02:43:40 +0000 (11:43 +0900)
Let's build from a single point. This make it faster to build as well as having the common configuration across all the plugins.

Fixes #19

Signed-off-by: MyungJoo Ham <myungjoo.ham@samsung.com>
CMakeLists.txt [new file with mode: 0644]
tensor_converter/CMakeLists.txt
tensor_converter/test/testcase01.sh

diff --git a/CMakeLists.txt b/CMakeLists.txt
new file mode 100644 (file)
index 0000000..3a14853
--- /dev/null
@@ -0,0 +1,45 @@
+CMAKE_MINIMUM_REQUIRED(VERSION 2.8)
+
+PROJECT(nnstreamer C)
+
+OPTION(TIZEN "Enable Tizen build mode" OFF)
+
+ADD_DEFINITIONS(-DVERSION="0.0.0")
+
+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(PKG_MODULES
+       gstreamer-1.0
+       gstreamer-base-1.0
+       gstreamer-controller-1.0
+       gstreamer-video-1.0
+       gstreamer-audio-1.0
+       glib-2.0
+)
+IF(TIZEN)
+       # Enable dlog of Tizen.
+       ADD_DEFINITIONS(-DTIZEN=1)
+       SET(PKG_MODULES ${PKG_MODULES} dlog)
+ENDIF(TIZEN)
+       
+pkg_check_modules(pkgs REQUIRED ${PKG_MODULES})
+
+INCLUDE_DIRECTORIES(
+       ${pkgs_INCLUDE_DIRS}
+       ${CMAKE_SOURCE_DIR}/include
+)
+LINK_DIRECTORIES(${pkgs_LIBRARY_DIRS})
+FOREACH(flag ${pkgs_CFALGS})
+       SET(EXTRA_CFLAGS "${EXTRA_CFLAGS} ${flag}")
+ENDFOREACH(flag)
+SET(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} ${EXTRA_CFLAGS}")
+
+ADD_SUBDIRECTORY(tensor_converter)
index 17e63ae..5f6ecd9 100644 (file)
@@ -1,33 +1,16 @@
-cmake_minimum_required(VERSION 2.8)
+CMAKE_MINIMUM_REQUIRED(VERSION 2.8)
 
-project(tensor_converter C)
+ADD_LIBRARY(tensor_converter SHARED tensor_converter.c)
+ADD_LIBRARY(tensor_converterStatic STATIC tensor_converter.c)
 
-add_definitions(-DVERSION="0.0.0")
+TARGET_LINK_LIBRARIES(tensor_converter ${pkgs_LIBRARIES})
+TARGET_INCLUDE_DIRECTORIES(tensor_converter PUBLIC ${pkgs_INCLUDE_DIRS})
+TARGET_COMPILE_OPTIONS(tensor_converter PUBLIC ${pkgs_CFLAGS_OTHER})
+TARGET_LINK_LIBRARIES(tensor_converterStatic ${pkgs_LIBRARIES})
+TARGET_INCLUDE_DIRECTORIES(tensor_converterStatic PUBLIC ${pkgs_INCLUDE_DIRS})
+TARGET_COMPILE_OPTIONS(tensor_converterStatic PUBLIC ${pkgs_CFLAGS_OTHER})
 
-set(PREFIX ${CMAKE_INSTALL_PREFIX})
-set(EXEC_PREFIX "${PREFIX}/bin")
-if(LIB_INSTALL_DIR)
-else(LIB_INSTALL_DIR)
-    set(LIB_INSTALL_DIR "${PREFIX}/lib")
-endif(LIB_INSTALL_DIR)
-
-find_package(PkgConfig REQUIRED)
-pkg_check_modules(GST REQUIRED gstreamer-1.0 gstreamer-base-1.0 gstreamer-controller-1.0 gstreamer-video-1.0 gstreamer-audio-1.0 glib-2.0)
-INCLUDE_DIRECTORIES(${GST_INCLUDE_DIRS})
-LINK_DIRECTORIES(${GST_LIBRARY_DIRS})
-
-set(PACKAGE convert2tensor)
-
-add_library(tensor_converter SHARED tensor_converter.c)
-add_library(tensor_converterStatic STATIC tensor_converter.c)
-target_link_libraries(tensor_converter ${GST_LIBRARIES})
-target_include_directories(tensor_converter PUBLIC ${GST_INCLUDE_DIRS})
-target_compile_options(tensor_converter PUBLIC ${GST_CFLAGS_OTHER})
-target_link_libraries(tensor_converterStatic ${GST_LIBRARIES})
-target_include_directories(tensor_converterStatic PUBLIC ${GST_INCLUDE_DIRS})
-target_compile_options(tensor_converterStatic PUBLIC ${GST_CFLAGS_OTHER})
-
-install(TARGETS tensor_converter tensor_converterStatic
+INSTALL(TARGETS tensor_converter tensor_converterStatic
        RUNTIME DESTINATION ${EXEC_PREFIX}
        LIBRARY DESTINATION ${LIB_INSTALL_DIR}
        ARCHIVE DESTINATION ${LIB_INSTALL_DIR}
index bee6ae8..43f581a 100755 (executable)
@@ -1,7 +1,7 @@
 #!/usr/bin/env bash
 if [ $# -eq 0 ]
 then
-  PATH_TO_PLUGIN="$PWD/../build"
+  PATH_TO_PLUGIN="$PWD/../../build"
 else
   PATH_TO_PLUGIN="$1"
 fi