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