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.4 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
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279
  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. if (USE_GLOG)
  51. file(GLOB_RECURSE GLOG_LIB_LIST ${glog_LIBPATH}/libglog*)
  52. install(
  53. FILES ${GLOG_LIB_LIST}
  54. DESTINATION ${INSTALL_LIB_DIR}
  55. COMPONENT mindspore
  56. )
  57. endif ()
  58. if (ENABLE_MINDDATA)
  59. install(
  60. TARGETS _c_dataengine _c_mindrecord
  61. DESTINATION ${INSTALL_BASE_DIR}
  62. COMPONENT mindspore
  63. )
  64. file(GLOB_RECURSE OPENCV_LIB_LIST
  65. ${opencv_LIBPATH}/libopencv_core*
  66. ${opencv_LIBPATH}/libopencv_imgcodecs*
  67. ${opencv_LIBPATH}/libopencv_imgproc*
  68. )
  69. install(
  70. FILES ${OPENCV_LIB_LIST}
  71. DESTINATION ${INSTALL_LIB_DIR}
  72. COMPONENT mindspore
  73. )
  74. file(GLOB_RECURSE TINYXML2_LIB_LIST
  75. ${tinyxml2_LIBPATH}/libtinyxml2*
  76. )
  77. install(
  78. FILES ${TINYXML2_LIB_LIST}
  79. DESTINATION ${INSTALL_LIB_DIR}
  80. COMPONENT mindspore
  81. )
  82. file(GLOB_RECURSE SENTENCEPIECE_LIB_LIST
  83. ${sentencepiece_LIBPATH}/libsentencepiece*
  84. )
  85. install(
  86. FILES ${SENTENCEPIECE_LIB_LIST}
  87. DESTINATION ${INSTALL_LIB_DIR}
  88. COMPONENT mindspore
  89. )
  90. if (CMAKE_SYSTEM_NAME MATCHES "Windows")
  91. message("icu4c does not support windows system temporarily")
  92. else()
  93. file(GLOB_RECURSE ICU4C_LIB_LIST
  94. ${icu4c_LIBPATH}/libicuuc*
  95. ${icu4c_LIBPATH}/libicudata*
  96. ${icu4c_LIBPATH}/libicui18n*
  97. )
  98. install(
  99. FILES ${ICU4C_LIB_LIST}
  100. DESTINATION ${INSTALL_LIB_DIR}
  101. COMPONENT mindspore
  102. )
  103. endif()
  104. endif ()
  105. if (ENABLE_CPU)
  106. if (CMAKE_SYSTEM_NAME MATCHES "Linux")
  107. file(GLOB_RECURSE DNNL_LIB_LIST ${onednn_LIBPATH}/libdnnl${CMAKE_SHARED_LIBRARY_SUFFIX}*)
  108. elseif (CMAKE_SYSTEM_NAME MATCHES "Darwin")
  109. file(GLOB_RECURSE DNNL_LIB_LIST ${onednn_LIBPATH}/libdnnl*${CMAKE_SHARED_LIBRARY_SUFFIX}*)
  110. elseif (CMAKE_SYSTEM_NAME MATCHES "Windows")
  111. file(GLOB_RECURSE DNNL_LIB_LIST ${onednn_LIBPATH}/dnnl.dll)
  112. endif ()
  113. install(
  114. FILES ${DNNL_LIB_LIST}
  115. DESTINATION ${INSTALL_LIB_DIR}
  116. COMPONENT mindspore
  117. )
  118. endif ()
  119. if (ENABLE_MPI)
  120. if (ENABLE_GPU)
  121. install(
  122. TARGETS _ms_mpi
  123. DESTINATION ${INSTALL_BASE_DIR}
  124. COMPONENT mindspore
  125. )
  126. endif ()
  127. if (ENABLE_CPU)
  128. install(
  129. TARGETS mpi_adapter
  130. DESTINATION ${INSTALL_LIB_DIR}
  131. COMPONENT mindspore
  132. )
  133. endif ()
  134. file(GLOB_RECURSE MPI_LIB_LIST
  135. ${ompi_LIBPATH}/libmpi${CMAKE_SHARED_LIBRARY_SUFFIX}*
  136. ${ompi_LIBPATH}/libopen*${CMAKE_SHARED_LIBRARY_SUFFIX}*
  137. )
  138. install(
  139. FILES ${MPI_LIB_LIST}
  140. DESTINATION ${INSTALL_LIB_DIR}
  141. COMPONENT mindspore
  142. )
  143. endif ()
  144. if (ENABLE_GPU)
  145. if (ENABLE_MPI)
  146. install(
  147. TARGETS gpu_collective
  148. DESTINATION ${INSTALL_LIB_DIR}
  149. COMPONENT mindspore
  150. )
  151. endif ()
  152. install(
  153. TARGETS gpu_queue
  154. DESTINATION ${INSTALL_LIB_DIR}
  155. COMPONENT mindspore
  156. )
  157. endif ()
  158. if (NOT ENABLE_GE)
  159. if (ENABLE_D)
  160. if (DEFINED ENV{ASCEND_CUSTOM_PATH})
  161. set(ASCEND_PATH $ENV{ASCEND_CUSTOM_PATH})
  162. else ()
  163. set(ASCEND_PATH /usr/local/Ascend)
  164. endif ()
  165. set(ASCEND_DRIVER_PATH ${ASCEND_PATH}/driver/lib64/common)
  166. set(ASCEND_FWK_PATH ${ASCEND_PATH}/fwkacllib/lib64)
  167. install(
  168. FILES
  169. ${CMAKE_BINARY_DIR}/graphengine/src/common/graph/libgraph.so
  170. ${CMAKE_BINARY_DIR}/graphengine/src/ge/common/libge_common.so
  171. ${CMAKE_BINARY_DIR}/graphengine/src/ge/ge_runtime/libge_runtime.so
  172. ${ASCEND_DRIVER_PATH}/libslog.so
  173. ${ASCEND_DRIVER_PATH}/libc_sec.so
  174. ${ASCEND_FWK_PATH}/liberror_manager.so
  175. DESTINATION ${INSTALL_LIB_DIR}
  176. COMPONENT mindspore
  177. )
  178. elseif (ENABLE_TESTCASES)
  179. install(
  180. FILES
  181. ${CMAKE_BINARY_DIR}/graphengine/src/common/graph/libgraph.so
  182. ${CMAKE_SOURCE_DIR}/graphengine/third_party/prebuild/${CMAKE_HOST_SYSTEM_PROCESSOR}/libslog.so
  183. ${CMAKE_SOURCE_DIR}/graphengine/third_party/prebuild/${CMAKE_HOST_SYSTEM_PROCESSOR}/liberror_manager.so
  184. ${CMAKE_SOURCE_DIR}/build/graphengine/libc_sec.so
  185. DESTINATION ${INSTALL_LIB_DIR}
  186. COMPONENT mindspore
  187. )
  188. endif ()
  189. endif ()
  190. if (CMAKE_SYSTEM_NAME MATCHES "Windows")
  191. get_filename_component(CXX_DIR ${CMAKE_CXX_COMPILER} PATH)
  192. file(GLOB CXX_LIB_LIST ${CXX_DIR}/*.dll)
  193. string(REPLACE "\\" "/" SystemRoot $ENV{SystemRoot})
  194. file(GLOB VC_LIB_LIST ${SystemRoot}/System32/msvcp140.dll ${SystemRoot}/System32/vcomp140.dll)
  195. file(GLOB JPEG_LIB_LIST ${jpeg_turbo_LIBPATH}/*.dll)
  196. file(GLOB SQLITE_LIB_LIST ${sqlite_LIBPATH}/*.dll)
  197. install(
  198. FILES ${CXX_LIB_LIST} ${JPEG_LIB_LIST} ${SQLITE_LIB_LIST} ${VC_LIB_LIST}
  199. DESTINATION ${INSTALL_LIB_DIR}
  200. COMPONENT mindspore
  201. )
  202. endif ()
  203. # set python files
  204. file(GLOB MS_PY_LIST ${CMAKE_SOURCE_DIR}/mindspore/*.py)
  205. install(
  206. FILES ${MS_PY_LIST}
  207. DESTINATION ${INSTALL_PY_DIR}
  208. COMPONENT mindspore
  209. )
  210. install(
  211. DIRECTORY
  212. ${CMAKE_SOURCE_DIR}/mindspore/nn
  213. ${CMAKE_SOURCE_DIR}/mindspore/_extends
  214. ${CMAKE_SOURCE_DIR}/mindspore/parallel
  215. ${CMAKE_SOURCE_DIR}/mindspore/mindrecord
  216. ${CMAKE_SOURCE_DIR}/mindspore/train
  217. ${CMAKE_SOURCE_DIR}/mindspore/common
  218. ${CMAKE_SOURCE_DIR}/mindspore/ops
  219. ${CMAKE_SOURCE_DIR}/mindspore/communication
  220. ${CMAKE_SOURCE_DIR}/mindspore/profiler
  221. DESTINATION ${INSTALL_PY_DIR}
  222. COMPONENT mindspore
  223. )
  224. if ((ENABLE_D OR ENABLE_GPU) AND ENABLE_AKG)
  225. set (AKG_PATH ${CMAKE_SOURCE_DIR}/build/mindspore/akg)
  226. install(
  227. DIRECTORY
  228. ${AKG_PATH}/akg
  229. DESTINATION ${INSTALL_PY_DIR}/..
  230. COMPONENT mindspore
  231. )
  232. endif ()
  233. if (EXISTS ${CMAKE_SOURCE_DIR}/mindspore/dataset)
  234. install(
  235. DIRECTORY ${CMAKE_SOURCE_DIR}/mindspore/dataset
  236. DESTINATION ${INSTALL_PY_DIR}
  237. COMPONENT mindspore
  238. )
  239. endif ()
  240. if (ENABLE_SERVING)
  241. install(
  242. TARGETS ms_serving
  243. DESTINATION ${INSTALL_BASE_DIR}
  244. COMPONENT mindspore
  245. )
  246. install(
  247. FILES ${CMAKE_SOURCE_DIR}/build/mindspore/serving/ms_service_pb2.py
  248. ${CMAKE_SOURCE_DIR}/build/mindspore/serving/ms_service_pb2_grpc.py
  249. DESTINATION ${INSTALL_PY_DIR}
  250. COMPONENT mindspore
  251. )
  252. install(
  253. TARGETS inference
  254. DESTINATION ${INSTALL_LIB_DIR}
  255. COMPONENT mindspore
  256. )
  257. endif ()