summaryrefslogtreecommitdiff
path: root/infra/nncc/cmake/packages/TensorFlowConfig.cmake
diff options
context:
space:
mode:
authorChunseok Lee <chunseok.lee@samsung.com>2020-03-05 15:10:09 +0900
committerChunseok Lee <chunseok.lee@samsung.com>2020-03-05 15:22:53 +0900
commitd91a039e0eda6fd70dcd22672b8ce1817c1ca50e (patch)
tree62668ec548cf31fadbbf4e99522999ad13434a25 /infra/nncc/cmake/packages/TensorFlowConfig.cmake
parentbd11b24234d7d43dfe05a81c520aa01ffad06e42 (diff)
downloadnnfw-d91a039e0eda6fd70dcd22672b8ce1817c1ca50e.tar.gz
nnfw-d91a039e0eda6fd70dcd22672b8ce1817c1ca50e.tar.bz2
nnfw-d91a039e0eda6fd70dcd22672b8ce1817c1ca50e.zip
catch up to tizen_5.5 and remove unness dir
- update to tizen_5.5 - remove dirs
Diffstat (limited to 'infra/nncc/cmake/packages/TensorFlowConfig.cmake')
-rw-r--r--infra/nncc/cmake/packages/TensorFlowConfig.cmake53
1 files changed, 53 insertions, 0 deletions
diff --git a/infra/nncc/cmake/packages/TensorFlowConfig.cmake b/infra/nncc/cmake/packages/TensorFlowConfig.cmake
new file mode 100644
index 000000000..14d2fdf26
--- /dev/null
+++ b/infra/nncc/cmake/packages/TensorFlowConfig.cmake
@@ -0,0 +1,53 @@
+set(TENSORFLOW_PREFIX "/usr" CACHE PATH "The location of pre-installed TensorFlow library")
+set(TENSORFLOW_VERSION_REQUIRED "1.12.0")
+
+# TODO Build TensorFlow from the (downloaded) source
+
+function(_TensorFlow_import)
+ # Find the header & lib
+ find_library(TensorFlow_LIB NAMES tensorflow PATHS "${TENSORFLOW_PREFIX}/lib")
+ find_path(TensorFlow_INCLUDE_DIR NAMES tensorflow/c/c_api.h PATHS "${TENSORFLOW_PREFIX}/include")
+
+ if(NOT TensorFlow_LIB OR NOT TensorFlow_INCLUDE_DIR)
+ message(STATUS "Found TensorFlow: FALSE")
+
+ set(TensorFlow_FOUND FALSE PARENT_SCOPE)
+ return()
+ endif(NOT TensorFlow_LIB OR NOT TensorFlow_INCLUDE_DIR)
+
+ # Check TensorFlow version
+ try_run(RUN_RESULT_VAR COMPILE_RESULT_VAR
+ ${CMAKE_BINARY_DIR}
+ ${CMAKE_CURRENT_LIST_DIR}/TensorFlowVersionChecker.c
+ COMPILE_DEFINITIONS -I${TensorFlow_INCLUDE_DIR}
+ LINK_LIBRARIES ${TensorFlow_LIB}
+ ARGS ${TENSORFLOW_VERSION_REQUIRED})
+
+ if(NOT COMPILE_RESULT_VAR)
+ message(STATUS "Failed to build TensorFlowVersionChecker. Your libtensorflow may be built on different version of Ubuntu.")
+ message(STATUS "Found TensorFlow: FALSE")
+ set(TensorFlow_FOUND FALSE PARENT_SCOPE)
+ return()
+ endif(NOT COMPILE_RESULT_VAR)
+
+ if(NOT RUN_RESULT_VAR EQUAL 0)
+ message(STATUS "you need tensorflow version ${TENSORFLOW_VERSION_REQUIRED}")
+ message(STATUS "Found TensorFlow: FALSE")
+ set(TensorFlow_FOUND FALSE PARENT_SCOPE)
+ return()
+ endif(NOT RUN_RESULT_VAR EQUAL 0)
+
+ # Add tensorflow target (if necessary)
+ if(NOT TARGET tensorflow)
+ message(STATUS "Found TensorFlow (include: ${TensorFlow_INCLUDE_DIR}, library: ${TensorFlow_LIB})")
+
+ # NOTE IMPORTED target may be more appropriate for this case
+ add_library(tensorflow INTERFACE)
+ target_link_libraries(tensorflow INTERFACE ${TensorFlow_LIB})
+ target_include_directories(tensorflow INTERFACE ${TensorFlow_INCLUDE_DIR})
+ endif(NOT TARGET tensorflow)
+
+ set(TensorFlow_FOUND TRUE PARENT_SCOPE)
+endfunction(_TensorFlow_import)
+
+_TensorFlow_import()