mindspore/predict/CMakeLists.txt

79 lines
3.1 KiB
CMake
Executable File

cmake_minimum_required(VERSION 3.12.1)
project (mindspore-predict)
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -g")
set(CMAKE_BUILD_TYPE "Release")
set(CMAKE_CXX_STANDARD 11)
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -fvisibility=hidden")
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fvisibility=hidden")
option(ENABLE_ASAN "Enable Google Sanitizer to find memory bugs" OFF)
option(ENABLE_PREDICT_ARM64 "predict arm64" OFF)
option(ENABLE_PREDICT_ARM32 "predict arm32" OFF)
set(PREDICT_DIR ${CMAKE_CURRENT_SOURCE_DIR})
set(PREDICT_BUILD_DIR ${CMAKE_CURRENT_SOURCE_DIR}/build)
set(3RD_DIR ${CMAKE_CURRENT_SOURCE_DIR}/../third_party)
set(DOTEST_DIR ${PREDICT_BUILD_DIR}/test/doTest)
include_directories(${3RD_DIR})
include_directories(${3RD_DIR}/flatbuffers/include/)
include_directories(${3RD_DIR}/protobuf/build/include/)
include_directories(${3RD_DIR}/googletest/googletest/include/)
include_directories(${3RD_DIR}/googletest/googlemock/include/)
include_directories(${CMAKE_CURRENT_SOURCE_DIR}/module/tvm_kernel/lite/include/)
include_directories(${PREDICT_DIR}/module/tvm_kernel/incubator-tvm/3rdparty/dlpack/include)
include_directories(common)
if(ENABLE_PREDICT_ARM64 OR ENABLE_PREDICT_ARM32)
message("*********************predict compile arm*********************")
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -DMS_USE_ARM=1")
set(ANDROID_NDK $ENV{ANDROID_NDK})
if(ANDROID_NDK)
add_subdirectory(${3RD_DIR}/googletest ${CMAKE_BINARY_DIR}/googletest)
link_directories(${PREDICT_BUILD_DIR}/googletest/googlemock/gtest)
add_subdirectory(${3RD_DIR}/securec ${CMAKE_BINARY_DIR}/securec)
link_directories(${PREDICT_BUILD_DIR}/securec/src)
else()
message(FATAL_ERROR "please set ANDROID_NDK in environment variable for example: export ANDROID_NDK=/root/usr/android-ndk-r16b/")
endif()
include_directories(${ANDROID_SYSROOT}/usr/include/)
if(${ANDROID_ABI} STREQUAL "armeabi-v7a")
include_directories(${ANDROID_SYSROOT}/usr/include/arm-linux-androideabi)
elseif(${ANDROID_ABI} STREQUAL "arm64-v8a")
include_directories(${ANDROID_SYSROOT}/usr/include/aarch64-linux-android)
else()
include_directories(${ANDROID_SYSROOT}/usr/include/arm-linux-androideabi)
endif()
else()
# include libsecurec.a x86
message("*********************predict compile x86*********************")
if(EXISTS "${PREDICT_DIR}/../build/mindspore/securec/src/libsecurec.a")
link_directories(${PREDICT_DIR}/../build/mindspore/securec/src)
else()
include(${PREDICT_DIR}/../cmake/dependency_securec.cmake)
link_directories(${PREDICT_BUILD_DIR}/securec/src)
endif()
# include libgtest.so x86
if(EXISTS "${PREDICT_DIR}/../build/googletest/googlemock/gtest/libgtest.so")
link_directories(${PREDICT_DIR}/../build/googletest/googlemock/gtest)
else()
include(${PREDICT_DIR}/../cmake/dependency_gtest.cmake)
link_directories(${PREDICT_BUILD_DIR}/googletest/googlemock/gtest)
endif()
endif()
if (CODE_COVERAGE)
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fprofile-arcs -ftest-coverage -O0")
endif()
add_subdirectory(common)
add_subdirectory(src)
add_subdirectory(benchmark)
add_subdirectory(test)
add_subdirectory(module)