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