You can not select more than 25 topics Topics must start with a chinese character,a letter or number, can include dashes ('-') and can be up to 35 characters long.

CMakeLists.txt 2.7 kB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061
  1. cmake_minimum_required(VERSION 3.14.1)
  2. project (MindSpore_Serving)
  3. if (CMAKE_CXX_COMPILER_ID STREQUAL "GNU" AND CMAKE_CXX_COMPILER_VERSION VERSION_LESS 7.3.0)
  4. message(FATAL_ERROR "GCC vesion ${CMAKE_CXX_COMPILER_VERSION} must not be less than 7.3.0")
  5. endif ()
  6. include(${CMAKE_SOURCE_DIR}/cmake/options.cmake) # set compile options
  7. include(${CMAKE_SOURCE_DIR}/cmake/check_requirements.cmake) # check require party, like OpenSSL
  8. set(CMAKE_CXX_FLAGS_RELEASE "$ENV{CXXFLAGS} -O2 -Wl,--allow-shlib-undefined -DHALF_ENABLE_CPP11_USER_LITERALS=0 -D_FORTIFY_SOURCE=2")
  9. if (NOT CMAKE_SYSTEM_NAME MATCHES "Windows")
  10. add_compile_definitions(_GLIBCXX_USE_CXX11_ABI=0)
  11. endif ()
  12. if (ENABLE_PYTHON)
  13. add_compile_definitions(ENABLE_PYTHON)
  14. endif()
  15. set(CMAKE_CXX_FLAGS_DEBUG "$ENV{CXXFLAGS} -O0 -g2 -ggdb -fno-inline-functions -fno-omit-frame-pointer -Wl,--allow-shlib-undefined -D_LIBCPP_INLINE_VISIBILITY='' -D_LIBCPP_DISABLE_EXTERN_TEMPLATE=1 -DHALF_ENABLE_CPP11_USER_LITERALS=0 -D_FORTIFY_SOURCE=2 -Wno-cpp")
  16. set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -I/usr/local/include -std=c++17 -Werror -Wall -fPIC")
  17. set(CMAKE_EXPORT_COMPILE_COMMANDS ON)
  18. set(PYBIND11_CPP_STANDARD -std=c++17)
  19. set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${OPTION_CXX_FLAGS}")
  20. # compile third party: grpc, libevent, gtest, onnx
  21. include(${CMAKE_SOURCE_DIR}/cmake/mind_expression.cmake)
  22. include_directories(${CMAKE_CURRENT_SOURCE_DIR})
  23. include_directories(${CMAKE_CURRENT_SOURCE_DIR}/third_party/securec/include)
  24. # find python3 packages
  25. include(${CMAKE_SOURCE_DIR}/cmake/dependency_utils.cmake)
  26. find_package(Python3 3.7 COMPONENTS Interpreter Development)
  27. if(Python3_FOUND)
  28. set(PYTHON_INCLUDE_DIRS "${Python3_INCLUDE_DIRS}")
  29. set(PYTHON_LIBRARIES "${Python3_LIBRARIES}")
  30. if (WIN32)
  31. if (Python3_DIR)
  32. message("Python3_DIR set already: " ${Python3_DIR})
  33. else()
  34. string(LENGTH ${PYTHON_LIBRARIES} PYTHON_LIBRARIES_LEN)
  35. string(LENGTH "libpythonxx.a" Python3_NAME_LEN)
  36. math(EXPR Python3_DIR_LEN ${PYTHON_LIBRARIES_LEN}-${Python3_NAME_LEN})
  37. string(SUBSTRING ${Python3_LIBRARIES} 0 ${Python3_DIR_LEN} Python3_DIR)
  38. message("Python3_DIR: " ${Python3_DIR})
  39. endif()
  40. link_directories(${Python3_DIR})
  41. endif()
  42. else()
  43. find_python_package(py_inc py_lib)
  44. set(PYTHON_INCLUDE_DIRS "${py_inc}")
  45. set(PYTHON_LIBRARIES "${py_lib}")
  46. endif()
  47. message("PYTHON_INCLUDE_DIRS = ${PYTHON_INCLUDE_DIRS}")
  48. message("PYTHON_LIBRARIES = ${PYTHON_LIBRARIES}")
  49. include_directories(${PYTHON_INCLUDE_DIRS})
  50. set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fvisibility=hidden")
  51. find_package(Threads REQUIRED)
  52. add_subdirectory(mindspore_serving)
  53. include(cmake/package.cmake)

A lightweight and high-performance service module that helps MindSpore developers efficiently deploy online inference services in the production environment.