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