1# 2# Copyright (C) 2016 The Android Open Source Project 3# 4# Licensed under the Apache License, Version 2.0 (the "License"); 5# you may not use this file except in compliance with the License. 6# You may obtain a copy of the License at 7# 8# http://www.apache.org/licenses/LICENSE-2.0 9# 10# Unless required by applicable law or agreed to in writing, software 11# distributed under the License is distributed on an "AS IS" BASIS, 12# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13# See the License for the specific language governing permissions and 14# limitations under the License. 15# 16 17project(TENSORFLOW_DEMO) 18cmake_minimum_required(VERSION 3.4.1) 19 20set(CMAKE_VERBOSE_MAKEFILE on) 21 22get_filename_component(TF_SRC_ROOT ${CMAKE_SOURCE_DIR}/../../../.. ABSOLUTE) 23get_filename_component(SAMPLE_SRC_DIR ${CMAKE_SOURCE_DIR}/.. ABSOLUTE) 24 25if (ANDROID_ABI MATCHES "^armeabi-v7a$") 26 set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -mfloat-abi=softfp -mfpu=neon") 27elseif(ANDROID_ABI MATCHES "^arm64-v8a") 28 set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -O2 -ftree-vectorize") 29endif() 30 31set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -DSTANDALONE_DEMO_LIB \ 32 -std=c++11 -fno-exceptions -fno-rtti -O2 -Wno-narrowing \ 33 -fPIE") 34set(CMAKE_SHARED_LINKER_FLAGS "${CMAKE_SHARED_LINKER_FLAGS} \ 35 -Wl,--allow-multiple-definition \ 36 -Wl,--whole-archive -fPIE -v") 37 38file(GLOB_RECURSE tensorflow_demo_sources ${SAMPLE_SRC_DIR}/jni/*.*) 39add_library(tensorflow_demo SHARED 40 ${tensorflow_demo_sources}) 41target_include_directories(tensorflow_demo PRIVATE 42 ${TF_SRC_ROOT} 43 ${CMAKE_SOURCE_DIR}) 44 45target_link_libraries(tensorflow_demo 46 android 47 log 48 jnigraphics 49 m 50 atomic 51 z) 52