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