Remove "externals/CMakeLists.txt" (#4777)
author박종현/On-Device Lab(SR)/Staff Engineer/삼성전자 <jh1302.park@samsung.com>
Tue, 19 Mar 2019 00:35:20 +0000 (09:35 +0900)
committer이춘석/On-Device Lab(SR)/Staff Engineer/삼성전자 <chunseok.lee@samsung.com>
Tue, 19 Mar 2019 00:35:20 +0000 (09:35 +0900)
This commit moves all the scripts related android support into contrib/
directory, and removes "externals/CMakeLists.txt" from the repo.

Signed-off-by: Jonghyun Park <jh1302.park@samsung.com>
CMakeLists.txt
contrib/android_tflite/CMakeLists.txt [new file with mode: 0644]
externals/CMakeLists.txt [deleted file]

index 38ff696..0d37eb3 100644 (file)
@@ -69,6 +69,11 @@ option(BUILD_BOOST "Build boost source" OFF)
 
 # Project configuration
 option(BUILD_TOOLS "Bulid nnfw projects under tools/" ON)
+CMAKE_DEPENDENT_OPTION(BUILD_ANDROID_TFLITE "Enable android support for TensorFlow Lite"
+                       # Enable android support for android build
+                       ON "${TARGET_OS} STREQUAL android"
+                       # Disable android support otherwise
+                       OFF)
 
 # GTest support
 option(BUILD_GTEST "Download and build Google Test" ON)
@@ -86,14 +91,12 @@ target_include_directories(nnapi-header INTERFACE include)
 # The original android build script (for future reference)
 #
 # add_subdirectory(libs)
-# add_subdirectory(externals)
 # add_subdirectory(tests/tools/nnapi_test)
 # add_subdirectory(tests/tools/tflite_benchmark)
 # add_subdirectory(tests/nnapi)
 #
 # add_subdirectory(runtimes)
 
-add_subdirectory(externals)
 add_subdirectory(contrib)
 add_subdirectory(libs)
 add_subdirectory(runtimes)
diff --git a/contrib/android_tflite/CMakeLists.txt b/contrib/android_tflite/CMakeLists.txt
new file mode 100644 (file)
index 0000000..7e8d211
--- /dev/null
@@ -0,0 +1,45 @@
+if(NOT BUILD_ANDROID_TFLITE)
+  return()
+endif(NOT BUILD_ANDROID_TFLITE)
+
+nnfw_find_package(TensorFlowLite REQUIRED)
+
+# TODO Set this as system-level global configuration on android build
+if(NOT DEFINED NDK_DIR)
+  file(GLOB NDK_DIRS "${CMAKE_SOURCE_DIR}/tools/cross/ndk/*")
+  list(LENGTH NDK_DIRS NDK_DIRS_COUNT)
+  if (NDK_DIRS_COUNT EQUAL 1)
+    set(NDK_DIR "${NDK_DIRS}")
+  endif(NDK_DIRS_COUNT EQUAL 1)
+endif(NOT DEFINED NDK_DIR)
+
+if(NOT DEFINED NDK_DIR)
+  message(FATAL_ERROR "NDK_DIR should be specified via environment variable")
+endif()
+message(STATUS "Found NDK: ${NDK_DIR}")
+target_include_directories(tensorflow-lite SYSTEM PUBLIC "${NDK_DIR}")
+target_link_libraries(tensorflow-lite log)
+
+#
+# Tensorflow Lite JNI library
+#
+set(TFLITE_JNI_BASE ${TENSORFLOW_LITE_BASE}/java/src/main/native)
+set(TFLITE_JNI_SRCS ${TFLITE_JNI_BASE}/duration_utils_jni.cc
+                    ${TFLITE_JNI_BASE}/exception_jni.cc
+                    ${TFLITE_JNI_BASE}/nativeinterpreterwrapper_jni.cc
+                    ${TFLITE_JNI_BASE}/tensor_jni.cc
+                    ${TFLITE_JNI_BASE}/tensorflow_lite_jni.cc
+                    ${TFLITE_JNI_BASE}/builtin_ops_jni.cc
+                    )
+set(TFLITE_JNI_INCLUDES ${TENSORFLOW_LITE_BASE}/java/src/native)
+
+# We need this for running vanilla tflite
+# TODO remove this when nnfw is used
+set(TFLITE_SRCS_V ${TENSORFLOW_LITE_BASE}/kernels/register.cc)
+
+# TODO use tensorflow-lite static library instead of compiling all the sources again
+add_library(tensorflowlite_jni SHARED ${TFLITE_JNI_SRCS} ${TFLITE_SRCS} ${TFLITE_SRCS_V})
+target_include_directories(tensorflowlite_jni PUBLIC ${TFLITE_JNI_INCLUDES} ${TFLITE_INCLUDES})
+target_link_libraries(tensorflowlite_jni eigen ${LIB_PTHREAD} dl)
+target_link_libraries(tensorflowlite_jni log)
+install(TARGETS tensorflowlite_jni DESTINATION lib)
diff --git a/externals/CMakeLists.txt b/externals/CMakeLists.txt
deleted file mode 100644 (file)
index cb4073f..0000000
+++ /dev/null
@@ -1,48 +0,0 @@
-nnfw_find_package(TensorFlowLite QUIET)
-
-if(NOT TensorFlowLite_FOUND)
-  return()
-endif(NOT TensorFlowLite_FOUND)
-
-if("${TARGET_OS}" STREQUAL "android")
-  if(NOT DEFINED NDK_DIR)
-    file(GLOB NDK_DIRS "${CMAKE_SOURCE_DIR}/tools/cross/ndk/*")
-    list(LENGTH NDK_DIRS NDK_DIRS_COUNT)
-    if (NDK_DIRS_COUNT EQUAL 1)
-      set(NDK_DIR "${NDK_DIRS}")
-    endif(NDK_DIRS_COUNT EQUAL 1)
-  endif(NOT DEFINED NDK_DIR)
-
-  if(NOT DEFINED NDK_DIR)
-    message(FATAL_ERROR "NDK_DIR should be specified via environment variable")
-  endif()
-  message(STATUS "Found NDK: ${NDK_DIR}")
-  target_include_directories(tensorflow-lite SYSTEM PUBLIC "${NDK_DIR}")
-endif()
-
-if("${TARGET_OS}" STREQUAL "android")
-  target_link_libraries(tensorflow-lite log)
-  #
-  # Tensorflow Lite JNI library
-  #
-  set(TFLITE_JNI_BASE ${TENSORFLOW_LITE_BASE}/java/src/main/native)
-  set(TFLITE_JNI_SRCS ${TFLITE_JNI_BASE}/duration_utils_jni.cc
-                      ${TFLITE_JNI_BASE}/exception_jni.cc
-                      ${TFLITE_JNI_BASE}/nativeinterpreterwrapper_jni.cc
-                      ${TFLITE_JNI_BASE}/tensor_jni.cc
-                      ${TFLITE_JNI_BASE}/tensorflow_lite_jni.cc
-                      ${TFLITE_JNI_BASE}/builtin_ops_jni.cc
-                      )
-  set(TFLITE_JNI_INCLUDES ${TENSORFLOW_LITE_BASE}/java/src/native)
-
-  # We need this for running vanilla tflite
-  # TODO remove this when nnfw is used
-  set(TFLITE_SRCS_V ${TENSORFLOW_LITE_BASE}/kernels/register.cc)
-
-  # TODO use tensorflow-lite static library instead of compiling all the sources again
-  add_library(tensorflowlite_jni SHARED ${TFLITE_JNI_SRCS} ${TFLITE_SRCS} ${TFLITE_SRCS_V})
-  target_include_directories(tensorflowlite_jni PUBLIC ${TFLITE_JNI_INCLUDES} ${TFLITE_INCLUDES})
-  target_link_libraries(tensorflowlite_jni eigen ${LIB_PTHREAD} dl)
-  target_link_libraries(tensorflowlite_jni log)
-  install(TARGETS tensorflowlite_jni DESTINATION lib)
-endif()