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.

package.cmake 8.5 kB

5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285
  1. # include dependency
  2. include(CMakePackageConfigHelpers)
  3. include(GNUInstallDirs)
  4. # set package information
  5. set(CPACK_PACKAGE_NAME ${PROJECT_NAME})
  6. set(CPACK_GENERATOR "External")
  7. set(CPACK_EXTERNAL_PACKAGE_SCRIPT ${CMAKE_SOURCE_DIR}/cmake/package_script.cmake)
  8. set(CPACK_EXTERNAL_ENABLE_STAGING true)
  9. set(CPACK_TEMPORARY_PACKAGE_FILE_NAME ${CMAKE_SOURCE_DIR}/build/package/mindspore)
  10. set(CPACK_TEMPORARY_INSTALL_DIRECTORY ${CMAKE_SOURCE_DIR}/build/package/mindspore)
  11. if (ENABLE_GE)
  12. set(CPACK_MS_BACKEND "ge")
  13. set(CPACK_MS_PACKAGE_NAME "mindspore")
  14. elseif (ENABLE_GPU)
  15. set(CPACK_MS_BACKEND "ms")
  16. set(CPACK_MS_PACKAGE_NAME "mindspore-gpu")
  17. elseif (ENABLE_D)
  18. set(CPACK_MS_BACKEND "ms")
  19. set(CPACK_MS_PACKAGE_NAME "mindspore-ascend")
  20. elseif (ENABLE_CPU)
  21. set(CPACK_MS_BACKEND "ms")
  22. set(CPACK_MS_PACKAGE_NAME "mindspore")
  23. else ()
  24. set(CPACK_MS_BACKEND "debug")
  25. set(CPACK_MS_PACKAGE_NAME "mindspore")
  26. endif ()
  27. include(CPack)
  28. # set install path
  29. set(INSTALL_LIB_DIR ${CMAKE_INSTALL_LIBDIR} CACHE PATH "Installation directory for libraries")
  30. set(INSTALL_PY_DIR ".")
  31. set(INSTALL_BASE_DIR ".")
  32. if (CMAKE_SYSTEM_NAME MATCHES "Windows")
  33. set(INSTALL_LIB_DIR ".")
  34. set(onednn_LIBPATH ${onednn_LIBPATH}/../bin/)
  35. set(glog_LIBPATH ${glog_LIBPATH}/../bin/)
  36. set(opencv_LIBPATH ${opencv_LIBPATH}/../bin/)
  37. set(jpeg_turbo_LIBPATH ${jpeg_turbo_LIBPATH}/../bin/)
  38. set(sqlite_LIBPATH ${sqlite_LIBPATH}/../bin/)
  39. set(tinyxml2_LIBPATH ${tinyxml2_LIBPATH}/../bin/)
  40. set(sentencepiece_LIBPATH ${sentencepiece_LIBPATH}/../bin/)
  41. else ()
  42. set(INSTALL_LIB_DIR "lib")
  43. endif ()
  44. # set package files
  45. install(
  46. TARGETS _c_expression
  47. DESTINATION ${INSTALL_BASE_DIR}
  48. COMPONENT mindspore
  49. )
  50. install(
  51. TARGETS mindspore_gvar
  52. DESTINATION ${INSTALL_LIB_DIR}
  53. COMPONENT mindspore
  54. )
  55. if (USE_GLOG)
  56. file(GLOB_RECURSE GLOG_LIB_LIST ${glog_LIBPATH}/libglog*)
  57. install(
  58. FILES ${GLOG_LIB_LIST}
  59. DESTINATION ${INSTALL_LIB_DIR}
  60. COMPONENT mindspore
  61. )
  62. endif ()
  63. if (ENABLE_MINDDATA)
  64. install(
  65. TARGETS _c_dataengine _c_mindrecord
  66. DESTINATION ${INSTALL_BASE_DIR}
  67. COMPONENT mindspore
  68. )
  69. file(GLOB_RECURSE OPENCV_LIB_LIST
  70. ${opencv_LIBPATH}/libopencv_core*
  71. ${opencv_LIBPATH}/libopencv_imgcodecs*
  72. ${opencv_LIBPATH}/libopencv_imgproc*
  73. )
  74. install(
  75. FILES ${OPENCV_LIB_LIST}
  76. DESTINATION ${INSTALL_LIB_DIR}
  77. COMPONENT mindspore
  78. )
  79. file(GLOB_RECURSE TINYXML2_LIB_LIST
  80. ${tinyxml2_LIBPATH}/libtinyxml2*
  81. )
  82. install(
  83. FILES ${TINYXML2_LIB_LIST}
  84. DESTINATION ${INSTALL_LIB_DIR}
  85. COMPONENT mindspore
  86. )
  87. file(GLOB_RECURSE SENTENCEPIECE_LIB_LIST
  88. ${sentencepiece_LIBPATH}/libsentencepiece*
  89. )
  90. install(
  91. FILES ${SENTENCEPIECE_LIB_LIST}
  92. DESTINATION ${INSTALL_LIB_DIR}
  93. COMPONENT mindspore
  94. )
  95. if (CMAKE_SYSTEM_NAME MATCHES "Windows")
  96. message("icu4c does not support windows system temporarily")
  97. else()
  98. file(GLOB_RECURSE ICU4C_LIB_LIST
  99. ${icu4c_LIBPATH}/libicuuc*
  100. ${icu4c_LIBPATH}/libicudata*
  101. ${icu4c_LIBPATH}/libicui18n*
  102. )
  103. install(
  104. FILES ${ICU4C_LIB_LIST}
  105. DESTINATION ${INSTALL_LIB_DIR}
  106. COMPONENT mindspore
  107. )
  108. endif()
  109. endif ()
  110. if (ENABLE_CPU)
  111. if (CMAKE_SYSTEM_NAME MATCHES "Linux")
  112. file(GLOB_RECURSE DNNL_LIB_LIST ${onednn_LIBPATH}/libdnnl${CMAKE_SHARED_LIBRARY_SUFFIX}*)
  113. elseif (CMAKE_SYSTEM_NAME MATCHES "Darwin")
  114. file(GLOB_RECURSE DNNL_LIB_LIST ${onednn_LIBPATH}/libdnnl*${CMAKE_SHARED_LIBRARY_SUFFIX}*)
  115. elseif (CMAKE_SYSTEM_NAME MATCHES "Windows")
  116. file(GLOB_RECURSE DNNL_LIB_LIST ${onednn_LIBPATH}/dnnl.dll)
  117. endif ()
  118. install(
  119. FILES ${DNNL_LIB_LIST}
  120. DESTINATION ${INSTALL_LIB_DIR}
  121. COMPONENT mindspore
  122. )
  123. endif ()
  124. if (ENABLE_MPI)
  125. if (ENABLE_GPU)
  126. install(
  127. TARGETS _ms_mpi
  128. DESTINATION ${INSTALL_BASE_DIR}
  129. COMPONENT mindspore
  130. )
  131. endif ()
  132. if (ENABLE_CPU)
  133. install(
  134. TARGETS mpi_adapter
  135. DESTINATION ${INSTALL_LIB_DIR}
  136. COMPONENT mindspore
  137. )
  138. endif ()
  139. file(GLOB_RECURSE MPI_LIB_LIST
  140. ${ompi_LIBPATH}/libmpi${CMAKE_SHARED_LIBRARY_SUFFIX}*
  141. ${ompi_LIBPATH}/libopen*${CMAKE_SHARED_LIBRARY_SUFFIX}*
  142. )
  143. install(
  144. FILES ${MPI_LIB_LIST}
  145. DESTINATION ${INSTALL_LIB_DIR}
  146. COMPONENT mindspore
  147. )
  148. endif ()
  149. if (ENABLE_GPU)
  150. if (ENABLE_MPI)
  151. install(
  152. TARGETS gpu_collective
  153. DESTINATION ${INSTALL_LIB_DIR}
  154. COMPONENT mindspore
  155. )
  156. endif ()
  157. install(
  158. TARGETS gpu_queue
  159. DESTINATION ${INSTALL_LIB_DIR}
  160. COMPONENT mindspore
  161. )
  162. endif ()
  163. if (NOT ENABLE_GE)
  164. if (ENABLE_D)
  165. if (DEFINED ENV{ASCEND_CUSTOM_PATH})
  166. set(ASCEND_PATH $ENV{ASCEND_CUSTOM_PATH})
  167. else ()
  168. set(ASCEND_PATH /usr/local/Ascend)
  169. endif ()
  170. set(ASCEND_DRIVER_PATH ${ASCEND_PATH}/driver/lib64/common)
  171. set(ASCEND_FWK_PATH ${ASCEND_PATH}/fwkacllib/lib64)
  172. install(
  173. FILES
  174. ${CMAKE_BINARY_DIR}/graphengine/src/common/graph/libgraph.so
  175. ${CMAKE_BINARY_DIR}/graphengine/src/ge/common/libge_common.so
  176. ${CMAKE_BINARY_DIR}/graphengine/src/ge/ge_runtime/libge_runtime.so
  177. ${ASCEND_DRIVER_PATH}/libslog.so
  178. ${ASCEND_DRIVER_PATH}/libc_sec.so
  179. ${ASCEND_FWK_PATH}/liberror_manager.so
  180. DESTINATION ${INSTALL_LIB_DIR}
  181. COMPONENT mindspore
  182. )
  183. elseif (ENABLE_TESTCASES)
  184. install(
  185. FILES
  186. ${CMAKE_BINARY_DIR}/graphengine/src/common/graph/libgraph.so
  187. ${CMAKE_SOURCE_DIR}/graphengine/third_party/prebuild/${CMAKE_HOST_SYSTEM_PROCESSOR}/libslog.so
  188. ${CMAKE_SOURCE_DIR}/graphengine/third_party/prebuild/${CMAKE_HOST_SYSTEM_PROCESSOR}/liberror_manager.so
  189. ${CMAKE_SOURCE_DIR}/build/graphengine/libc_sec.so
  190. DESTINATION ${INSTALL_LIB_DIR}
  191. COMPONENT mindspore
  192. )
  193. endif ()
  194. endif ()
  195. if (CMAKE_SYSTEM_NAME MATCHES "Windows")
  196. get_filename_component(CXX_DIR ${CMAKE_CXX_COMPILER} PATH)
  197. file(GLOB CXX_LIB_LIST ${CXX_DIR}/*.dll)
  198. string(REPLACE "\\" "/" SystemRoot $ENV{SystemRoot})
  199. file(GLOB VC_LIB_LIST ${SystemRoot}/System32/msvcp140.dll ${SystemRoot}/System32/vcomp140.dll)
  200. file(GLOB JPEG_LIB_LIST ${jpeg_turbo_LIBPATH}/*.dll)
  201. file(GLOB SQLITE_LIB_LIST ${sqlite_LIBPATH}/*.dll)
  202. install(
  203. FILES ${CXX_LIB_LIST} ${JPEG_LIB_LIST} ${SQLITE_LIB_LIST} ${VC_LIB_LIST}
  204. DESTINATION ${INSTALL_LIB_DIR}
  205. COMPONENT mindspore
  206. )
  207. endif ()
  208. # set python files
  209. file(GLOB MS_PY_LIST ${CMAKE_SOURCE_DIR}/mindspore/*.py)
  210. install(
  211. FILES ${MS_PY_LIST}
  212. DESTINATION ${INSTALL_PY_DIR}
  213. COMPONENT mindspore
  214. )
  215. install(
  216. DIRECTORY
  217. ${CMAKE_SOURCE_DIR}/mindspore/nn
  218. ${CMAKE_SOURCE_DIR}/mindspore/_extends
  219. ${CMAKE_SOURCE_DIR}/mindspore/parallel
  220. ${CMAKE_SOURCE_DIR}/mindspore/mindrecord
  221. ${CMAKE_SOURCE_DIR}/mindspore/train
  222. ${CMAKE_SOURCE_DIR}/mindspore/common
  223. ${CMAKE_SOURCE_DIR}/mindspore/ops
  224. ${CMAKE_SOURCE_DIR}/mindspore/communication
  225. ${CMAKE_SOURCE_DIR}/mindspore/profiler
  226. DESTINATION ${INSTALL_PY_DIR}
  227. COMPONENT mindspore
  228. )
  229. if ((ENABLE_D OR ENABLE_GPU) AND ENABLE_AKG)
  230. set (AKG_PATH ${CMAKE_SOURCE_DIR}/build/mindspore/akg)
  231. install(
  232. DIRECTORY
  233. ${AKG_PATH}/akg
  234. DESTINATION ${INSTALL_PY_DIR}/..
  235. COMPONENT mindspore
  236. )
  237. endif ()
  238. if (EXISTS ${CMAKE_SOURCE_DIR}/mindspore/dataset)
  239. install(
  240. DIRECTORY ${CMAKE_SOURCE_DIR}/mindspore/dataset
  241. DESTINATION ${INSTALL_PY_DIR}
  242. COMPONENT mindspore
  243. )
  244. endif ()
  245. if (ENABLE_SERVING)
  246. install(
  247. TARGETS ms_serving
  248. DESTINATION ${INSTALL_BASE_DIR}
  249. COMPONENT mindspore
  250. )
  251. install(
  252. FILES ${CMAKE_SOURCE_DIR}/build/mindspore/serving/ms_service_pb2.py
  253. ${CMAKE_SOURCE_DIR}/build/mindspore/serving/ms_service_pb2_grpc.py
  254. DESTINATION ${INSTALL_PY_DIR}
  255. COMPONENT mindspore
  256. )
  257. install(
  258. TARGETS inference
  259. DESTINATION ${INSTALL_LIB_DIR}
  260. COMPONENT mindspore
  261. )
  262. endif ()