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 12 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
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
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385
  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_CMAKE_GENERATOR "Ninja")
  8. set(CPACK_EXTERNAL_PACKAGE_SCRIPT ${CMAKE_SOURCE_DIR}/cmake/package_script.cmake)
  9. set(CPACK_EXTERNAL_ENABLE_STAGING true)
  10. set(CPACK_TEMPORARY_PACKAGE_FILE_NAME ${CMAKE_SOURCE_DIR}/build/package/mindspore)
  11. set(CPACK_TEMPORARY_INSTALL_DIRECTORY ${CMAKE_SOURCE_DIR}/build/package/mindspore)
  12. if(ENABLE_GE)
  13. set(CPACK_MS_BACKEND "ge")
  14. set(CPACK_MS_TARGET "ascend or cpu")
  15. set(CPACK_MS_PACKAGE_NAME "mindspore")
  16. elseif(ENABLE_GPU)
  17. set(CPACK_MS_BACKEND "ms")
  18. set(CPACK_MS_TARGET "gpu or cpu")
  19. set(CPACK_MS_PACKAGE_NAME "mindspore-gpu")
  20. elseif(ENABLE_D)
  21. set(CPACK_MS_BACKEND "ms")
  22. set(CPACK_MS_TARGET "ascend or cpu")
  23. set(CPACK_MS_PACKAGE_NAME "mindspore-ascend")
  24. elseif(ENABLE_CPU)
  25. set(CPACK_MS_BACKEND "ms")
  26. set(CPACK_MS_TARGET "cpu")
  27. set(CPACK_MS_PACKAGE_NAME "mindspore")
  28. elseif(ENABLE_ACL)
  29. set(CPACK_MS_BACKEND "debug")
  30. set(CPACK_MS_TARGET "ascend or gpu or cpu")
  31. set(CPACK_MS_PACKAGE_NAME "mindspore-ascend")
  32. else()
  33. set(CPACK_MS_BACKEND "debug")
  34. set(CPACK_MS_TARGET "ascend or gpu or cpu")
  35. set(CPACK_MS_PACKAGE_NAME "mindspore")
  36. endif()
  37. include(CPack)
  38. # set install path
  39. set(INSTALL_LIB_DIR ${CMAKE_INSTALL_LIBDIR} CACHE PATH "Installation directory for libraries")
  40. set(INSTALL_PY_DIR ".")
  41. set(INSTALL_BASE_DIR ".")
  42. set(INSTALL_BIN_DIR "bin")
  43. set(INSTALL_CFG_DIR "config")
  44. if(CMAKE_SYSTEM_NAME MATCHES "Windows")
  45. set(INSTALL_LIB_DIR ".")
  46. set(onednn_LIBPATH ${onednn_LIBPATH}/../bin/)
  47. set(glog_LIBPATH ${glog_LIBPATH}/../bin/)
  48. set(opencv_LIBPATH ${opencv_LIBPATH}/../bin/)
  49. set(jpeg_turbo_LIBPATH ${jpeg_turbo_LIBPATH}/../bin/)
  50. set(sqlite_LIBPATH ${sqlite_LIBPATH}/../bin/)
  51. set(tinyxml2_LIBPATH ${tinyxml2_LIBPATH}/../bin/)
  52. set(sentencepiece_LIBPATH ${sentencepiece_LIBPATH}/../bin/)
  53. else()
  54. set(INSTALL_LIB_DIR "lib")
  55. endif()
  56. # set package files
  57. install(
  58. TARGETS _c_expression
  59. DESTINATION ${INSTALL_BASE_DIR}
  60. COMPONENT mindspore
  61. )
  62. if(CMAKE_SYSTEM_NAME MATCHES "Windows")
  63. message("offline debugger does not support windows system temporarily")
  64. else()
  65. install(
  66. TARGETS _mindspore_offline_debug
  67. DESTINATION ${INSTALL_BASE_DIR}
  68. COMPONENT mindspore
  69. )
  70. endif()
  71. install(
  72. TARGETS mindspore_shared_lib
  73. DESTINATION ${INSTALL_LIB_DIR}
  74. COMPONENT mindspore
  75. )
  76. install(
  77. TARGETS mindspore_gvar
  78. DESTINATION ${INSTALL_LIB_DIR}
  79. COMPONENT mindspore
  80. )
  81. if(USE_GLOG)
  82. file(GLOB_RECURSE GLOG_LIB_LIST ${glog_LIBPATH}/libmindspore_glog*)
  83. install(
  84. FILES ${GLOG_LIB_LIST}
  85. DESTINATION ${INSTALL_LIB_DIR}
  86. COMPONENT mindspore
  87. )
  88. endif()
  89. file(GLOB_RECURSE LIBEVENT_LIB_LIST
  90. ${libevent_LIBPATH}/libevent*${CMAKE_SHARED_LIBRARY_SUFFIX}*
  91. ${libevent_LIBPATH}/libevent_pthreads*${CMAKE_SHARED_LIBRARY_SUFFIX}*
  92. )
  93. install(
  94. FILES ${LIBEVENT_LIB_LIST}
  95. DESTINATION ${INSTALL_LIB_DIR}
  96. COMPONENT mindspore
  97. )
  98. if(ENABLE_MINDDATA)
  99. install(
  100. TARGETS _c_dataengine _c_mindrecord
  101. DESTINATION ${INSTALL_BASE_DIR}
  102. COMPONENT mindspore
  103. )
  104. if(CMAKE_SYSTEM_NAME MATCHES "Linux")
  105. install(
  106. TARGETS cache_admin cache_server
  107. OPTIONAL
  108. DESTINATION ${INSTALL_BIN_DIR}
  109. COMPONENT mindspore
  110. )
  111. endif()
  112. file(GLOB_RECURSE OPENCV_LIB_LIST
  113. ${opencv_LIBPATH}/libopencv_core*
  114. ${opencv_LIBPATH}/libopencv_imgcodecs*
  115. ${opencv_LIBPATH}/libopencv_imgproc*
  116. )
  117. install(
  118. FILES ${OPENCV_LIB_LIST}
  119. DESTINATION ${INSTALL_LIB_DIR}
  120. COMPONENT mindspore
  121. )
  122. file(GLOB_RECURSE TINYXML2_LIB_LIST ${tinyxml2_LIBPATH}/libtinyxml2*)
  123. install(
  124. FILES ${TINYXML2_LIB_LIST}
  125. DESTINATION ${INSTALL_LIB_DIR}
  126. COMPONENT mindspore
  127. )
  128. file(GLOB_RECURSE SENTENCEPIECE_LIB_LIST
  129. ${sentencepiece_LIBPATH}/libsentencepiece*
  130. )
  131. install(
  132. FILES ${SENTENCEPIECE_LIB_LIST}
  133. DESTINATION ${INSTALL_LIB_DIR}
  134. COMPONENT mindspore
  135. )
  136. if(CMAKE_SYSTEM_NAME MATCHES "Windows")
  137. message("icu4c does not support windows system temporarily")
  138. else()
  139. file(GLOB_RECURSE ICU4C_LIB_LIST
  140. ${icu4c_LIBPATH}/libicuuc*
  141. ${icu4c_LIBPATH}/libicudata*
  142. ${icu4c_LIBPATH}/libicui18n*
  143. )
  144. install(
  145. FILES ${ICU4C_LIB_LIST}
  146. DESTINATION ${INSTALL_LIB_DIR}
  147. COMPONENT mindspore
  148. )
  149. endif()
  150. endif()
  151. if(ENABLE_CPU)
  152. if(CMAKE_SYSTEM_NAME MATCHES "Linux")
  153. file(GLOB_RECURSE DNNL_LIB_LIST ${onednn_LIBPATH}/libdnnl${CMAKE_SHARED_LIBRARY_SUFFIX}*)
  154. elseif(CMAKE_SYSTEM_NAME MATCHES "Darwin")
  155. file(GLOB_RECURSE DNNL_LIB_LIST ${onednn_LIBPATH}/libdnnl*${CMAKE_SHARED_LIBRARY_SUFFIX}*)
  156. elseif(CMAKE_SYSTEM_NAME MATCHES "Windows")
  157. file(GLOB_RECURSE DNNL_LIB_LIST ${onednn_LIBPATH}/dnnl.dll)
  158. endif()
  159. install(
  160. FILES ${DNNL_LIB_LIST}
  161. DESTINATION ${INSTALL_LIB_DIR}
  162. COMPONENT mindspore
  163. )
  164. install(
  165. TARGETS nnacl
  166. DESTINATION ${INSTALL_LIB_DIR}
  167. COMPONENT mindspore
  168. )
  169. endif()
  170. if(ENABLE_MPI)
  171. if(ENABLE_GPU)
  172. install(
  173. TARGETS _ms_mpi
  174. DESTINATION ${INSTALL_BASE_DIR}
  175. COMPONENT mindspore
  176. )
  177. endif()
  178. if(ENABLE_CPU)
  179. install(
  180. TARGETS mpi_adapter
  181. DESTINATION ${INSTALL_LIB_DIR}
  182. COMPONENT mindspore
  183. )
  184. endif()
  185. endif()
  186. if(ENABLE_GPU)
  187. if(ENABLE_MPI)
  188. install(
  189. TARGETS gpu_collective
  190. DESTINATION ${INSTALL_LIB_DIR}
  191. COMPONENT mindspore
  192. )
  193. endif()
  194. install(
  195. TARGETS gpu_queue
  196. DESTINATION ${INSTALL_LIB_DIR}
  197. COMPONENT mindspore
  198. )
  199. endif()
  200. if(ENABLE_CPU AND NOT WIN32)
  201. install(
  202. TARGETS ps_cache
  203. DESTINATION ${INSTALL_LIB_DIR}
  204. COMPONENT mindspore
  205. )
  206. endif()
  207. if(ENABLE_TESTCASES)
  208. file(GLOB_RECURSE LIBEVENT_LIB_LIST
  209. ${libevent_LIBPATH}/libevent*
  210. ${libevent_LIBPATH}/libevent_pthreads*
  211. )
  212. endif()
  213. if(NOT ENABLE_GE)
  214. if(ENABLE_D OR ENABLE_ACL)
  215. if(DEFINED ENV{ASCEND_CUSTOM_PATH})
  216. set(ASCEND_PATH $ENV{ASCEND_CUSTOM_PATH})
  217. else()
  218. set(ASCEND_PATH /usr/local/Ascend)
  219. endif()
  220. set(ASCEND_DRIVER_PATH ${ASCEND_PATH}/driver/lib64/common)
  221. install(
  222. FILES ${CMAKE_SOURCE_DIR}/build/graphengine/c_sec/lib/libc_sec.so
  223. DESTINATION ${INSTALL_LIB_DIR}
  224. COMPONENT mindspore
  225. )
  226. if(ENABLE_D)
  227. install(
  228. TARGETS ms_profile
  229. DESTINATION ${INSTALL_LIB_DIR}
  230. COMPONENT mindspore
  231. )
  232. install(
  233. FILES
  234. ${CMAKE_BINARY_DIR}/graphengine/metadef/graph/libgraph.so
  235. ${CMAKE_BINARY_DIR}/graphengine/ge/common/libge_common.so
  236. DESTINATION ${INSTALL_LIB_DIR}
  237. COMPONENT mindspore
  238. )
  239. endif()
  240. elseif(ENABLE_TESTCASES)
  241. install(
  242. FILES
  243. ${CMAKE_BINARY_DIR}/graphengine/metadef/graph/libgraph.so
  244. ${CMAKE_SOURCE_DIR}/build/graphengine/c_sec/lib/libc_sec.so
  245. ${LIBEVENT_LIB_LIST}
  246. DESTINATION ${INSTALL_LIB_DIR}
  247. COMPONENT mindspore
  248. )
  249. endif()
  250. endif()
  251. if(MS_BUILD_GRPC)
  252. install(FILES ${grpc_LIBPATH}/libmindspore_grpc++.so.1.27.3
  253. DESTINATION ${INSTALL_LIB_DIR} RENAME libmindspore_grpc++.so.1 COMPONENT mindspore)
  254. install(FILES ${grpc_LIBPATH}/libmindspore_grpc.so.9.0.0
  255. DESTINATION ${INSTALL_LIB_DIR} RENAME libmindspore_grpc.so.9 COMPONENT mindspore)
  256. install(FILES ${grpc_LIBPATH}/libmindspore_gpr.so.9.0.0
  257. DESTINATION ${INSTALL_LIB_DIR} RENAME libmindspore_gpr.so.9 COMPONENT mindspore)
  258. install(FILES ${grpc_LIBPATH}/libmindspore_upb.so.9.0.0
  259. DESTINATION ${INSTALL_LIB_DIR} RENAME libmindspore_upb.so.9 COMPONENT mindspore)
  260. install(FILES ${grpc_LIBPATH}/libmindspore_address_sorting.so.9.0.0
  261. DESTINATION ${INSTALL_LIB_DIR} RENAME libmindspore_address_sorting.so.9 COMPONENT mindspore)
  262. endif()
  263. if(CMAKE_SYSTEM_NAME MATCHES "Windows")
  264. get_filename_component(CXX_DIR ${CMAKE_CXX_COMPILER} PATH)
  265. file(GLOB CXX_LIB_LIST ${CXX_DIR}/*.dll)
  266. string(REPLACE "\\" "/" SystemRoot $ENV{SystemRoot})
  267. file(GLOB VC_LIB_LIST ${SystemRoot}/System32/msvcp140.dll ${SystemRoot}/System32/vcomp140.dll)
  268. file(GLOB JPEG_LIB_LIST ${jpeg_turbo_LIBPATH}/*.dll)
  269. file(GLOB SQLITE_LIB_LIST ${sqlite_LIBPATH}/*.dll)
  270. install(
  271. FILES ${CXX_LIB_LIST} ${JPEG_LIB_LIST} ${SQLITE_LIB_LIST} ${VC_LIB_LIST}
  272. DESTINATION ${INSTALL_LIB_DIR}
  273. COMPONENT mindspore
  274. )
  275. endif()
  276. # set python files
  277. file(GLOB MS_PY_LIST ${CMAKE_SOURCE_DIR}/mindspore/*.py)
  278. install(
  279. FILES ${MS_PY_LIST}
  280. DESTINATION ${INSTALL_PY_DIR}
  281. COMPONENT mindspore
  282. )
  283. install(
  284. DIRECTORY
  285. ${CMAKE_SOURCE_DIR}/mindspore/nn
  286. ${CMAKE_SOURCE_DIR}/mindspore/_extends
  287. ${CMAKE_SOURCE_DIR}/mindspore/parallel
  288. ${CMAKE_SOURCE_DIR}/mindspore/mindrecord
  289. ${CMAKE_SOURCE_DIR}/mindspore/numpy
  290. ${CMAKE_SOURCE_DIR}/mindspore/train
  291. ${CMAKE_SOURCE_DIR}/mindspore/common
  292. ${CMAKE_SOURCE_DIR}/mindspore/ops
  293. ${CMAKE_SOURCE_DIR}/mindspore/communication
  294. ${CMAKE_SOURCE_DIR}/mindspore/profiler
  295. ${CMAKE_SOURCE_DIR}/mindspore/explainer
  296. ${CMAKE_SOURCE_DIR}/mindspore/compression
  297. DESTINATION ${INSTALL_PY_DIR}
  298. COMPONENT mindspore
  299. )
  300. if((ENABLE_D OR ENABLE_GPU) AND ENABLE_AKG)
  301. set (AKG_PATH ${CMAKE_SOURCE_DIR}/build/mindspore/akg)
  302. file(REMOVE_RECURSE ${AKG_PATH}/_akg)
  303. file(MAKE_DIRECTORY ${AKG_PATH}/_akg)
  304. file(TOUCH ${AKG_PATH}/_akg/__init__.py)
  305. install(DIRECTORY "${AKG_PATH}/akg" DESTINATION "${AKG_PATH}/_akg")
  306. install(
  307. DIRECTORY
  308. ${AKG_PATH}/_akg
  309. DESTINATION ${INSTALL_PY_DIR}/
  310. COMPONENT mindspore
  311. )
  312. endif()
  313. if(EXISTS ${CMAKE_SOURCE_DIR}/mindspore/dataset)
  314. install(
  315. DIRECTORY ${CMAKE_SOURCE_DIR}/mindspore/dataset
  316. DESTINATION ${INSTALL_PY_DIR}
  317. COMPONENT mindspore
  318. )
  319. endif()
  320. if(CMAKE_SYSTEM_NAME MATCHES "Windows")
  321. message("offline debugger does not support windows system temporarily")
  322. else()
  323. if(EXISTS ${CMAKE_SOURCE_DIR}/mindspore/offline_debug)
  324. install(
  325. DIRECTORY ${CMAKE_SOURCE_DIR}/mindspore/offline_debug
  326. DESTINATION ${INSTALL_PY_DIR}
  327. COMPONENT mindspore
  328. )
  329. endif()
  330. endif()
  331. ## Public header files
  332. install(
  333. DIRECTORY ${CMAKE_SOURCE_DIR}/include
  334. DESTINATION ${INSTALL_BASE_DIR}
  335. COMPONENT mindspore
  336. )
  337. ## Public header files for minddata
  338. install(
  339. FILES ${CMAKE_SOURCE_DIR}/mindspore/ccsrc/minddata/dataset/include/dataset/constants.h
  340. ${CMAKE_SOURCE_DIR}/mindspore/ccsrc/minddata/dataset/include/dataset/transforms.h
  341. ${CMAKE_SOURCE_DIR}/mindspore/ccsrc/minddata/dataset/include/dataset/vision.h
  342. ${CMAKE_SOURCE_DIR}/mindspore/ccsrc/minddata/dataset/include/dataset/vision_lite.h
  343. ${CMAKE_SOURCE_DIR}/mindspore/ccsrc/minddata/dataset/include/dataset/vision_ascend.h
  344. ${CMAKE_SOURCE_DIR}/mindspore/ccsrc/minddata/dataset/include/dataset/execute.h
  345. DESTINATION ${INSTALL_BASE_DIR}/include/dataset
  346. COMPONENT mindspore
  347. )
  348. ## config files
  349. install(
  350. FILES ${CMAKE_SOURCE_DIR}/config/op_info.config
  351. DESTINATION ${INSTALL_CFG_DIR}
  352. COMPONENT mindspore
  353. )