--- /dev/null
+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)
-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}