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.2 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
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277
  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_PACKAGE_NAME "mindspore")
  14. elseif (ENABLE_GPU)
  15. set(CPACK_MS_BACKEND "ms")
  16. set(CPACK_MS_PACKAGE_NAME "mindspore-gpu")
  17. elseif (ENABLE_D)
  18. set(CPACK_MS_BACKEND "ms")
  19. set(CPACK_MS_PACKAGE_NAME "mindspore-ascend")
  20. elseif (ENABLE_CPU)
  21. set(CPACK_MS_BACKEND "ms")
  22. set(CPACK_MS_PACKAGE_NAME "mindspore")
  23. else ()
  24. set(CPACK_MS_BACKEND "debug")
  25. set(CPACK_MS_PACKAGE_NAME "mindspore")
  26. endif ()
  27. include(CPack)
  28. # set install path
  29. set(INSTALL_LIB_DIR ${CMAKE_INSTALL_LIBDIR} CACHE PATH "Installation directory for libraries")
  30. set(INSTALL_PY_DIR ".")
  31. set(INSTALL_BASE_DIR ".")
  32. if (CMAKE_SYSTEM_NAME MATCHES "Windows")
  33. set(INSTALL_LIB_DIR ".")
  34. set(onednn_LIBPATH ${onednn_LIBPATH}/../bin/)
  35. set(glog_LIBPATH ${glog_LIBPATH}/../bin/)
  36. set(opencv_LIBPATH ${opencv_LIBPATH}/../bin/)
  37. set(jpeg_turbo_LIBPATH ${jpeg_turbo_LIBPATH}/../bin/)
  38. set(sqlite_LIBPATH ${sqlite_LIBPATH}/../bin/)
  39. set(tinyxml2_LIBPATH ${tinyxml2_LIBPATH}/../bin/)
  40. else ()
  41. set(INSTALL_LIB_DIR "lib")
  42. endif ()
  43. # set package files
  44. install(
  45. TARGETS _c_expression
  46. DESTINATION ${INSTALL_BASE_DIR}
  47. COMPONENT mindspore
  48. )
  49. install(
  50. TARGETS mindspore_gvar
  51. DESTINATION ${INSTALL_LIB_DIR}
  52. COMPONENT mindspore
  53. )
  54. if (USE_GLOG)
  55. file(GLOB_RECURSE GLOG_LIB_LIST ${glog_LIBPATH}/libglog*)
  56. install(
  57. FILES ${GLOG_LIB_LIST}
  58. DESTINATION ${INSTALL_LIB_DIR}
  59. COMPONENT mindspore
  60. )
  61. endif ()
  62. if (ENABLE_MINDDATA)
  63. install(
  64. TARGETS _c_dataengine _c_mindrecord
  65. DESTINATION ${INSTALL_BASE_DIR}
  66. COMPONENT mindspore
  67. )
  68. file(GLOB_RECURSE OPENCV_LIB_LIST
  69. ${opencv_LIBPATH}/libopencv_core*
  70. ${opencv_LIBPATH}/libopencv_imgcodecs*
  71. ${opencv_LIBPATH}/libopencv_imgproc*
  72. )
  73. install(
  74. FILES ${OPENCV_LIB_LIST}
  75. DESTINATION ${INSTALL_LIB_DIR}
  76. COMPONENT mindspore
  77. )
  78. file(GLOB_RECURSE TINYXML2_LIB_LIST
  79. ${tinyxml2_LIBPATH}/libtinyxml2*
  80. )
  81. install(
  82. FILES ${TINYXML2_LIB_LIST}
  83. DESTINATION ${INSTALL_LIB_DIR}
  84. COMPONENT mindspore
  85. )
  86. if (CMAKE_SYSTEM_NAME MATCHES "Windows")
  87. message("icu4c does not support windows system temporarily")
  88. else()
  89. file(GLOB_RECURSE ICU4C_LIB_LIST
  90. ${icu4c_LIBPATH}/libicuuc*
  91. ${icu4c_LIBPATH}/libicudata*
  92. ${icu4c_LIBPATH}/libicui18n*
  93. )
  94. install(
  95. FILES ${ICU4C_LIB_LIST}
  96. DESTINATION ${INSTALL_LIB_DIR}
  97. COMPONENT mindspore
  98. )
  99. endif()
  100. endif ()
  101. if (ENABLE_CPU)
  102. if (CMAKE_SYSTEM_NAME MATCHES "Linux")
  103. file(GLOB_RECURSE DNNL_LIB_LIST ${onednn_LIBPATH}/libdnnl${CMAKE_SHARED_LIBRARY_SUFFIX}*)
  104. elseif (CMAKE_SYSTEM_NAME MATCHES "Darwin")
  105. file(GLOB_RECURSE DNNL_LIB_LIST ${onednn_LIBPATH}/libdnnl*${CMAKE_SHARED_LIBRARY_SUFFIX}*)
  106. elseif (CMAKE_SYSTEM_NAME MATCHES "Windows")
  107. file(GLOB_RECURSE DNNL_LIB_LIST ${onednn_LIBPATH}/dnnl.dll)
  108. endif ()
  109. install(
  110. FILES ${DNNL_LIB_LIST}
  111. DESTINATION ${INSTALL_LIB_DIR}
  112. COMPONENT mindspore
  113. )
  114. endif ()
  115. if (ENABLE_MPI)
  116. install(
  117. TARGETS _ms_mpi
  118. DESTINATION ${INSTALL_BASE_DIR}
  119. COMPONENT mindspore
  120. )
  121. install(
  122. TARGETS mpi_adapter
  123. DESTINATION ${INSTALL_LIB_DIR}
  124. COMPONENT mindspore
  125. )
  126. endif ()
  127. if (ENABLE_GPU)
  128. install(
  129. TARGETS gpu_collective
  130. DESTINATION ${INSTALL_LIB_DIR}
  131. COMPONENT mindspore
  132. )
  133. install(
  134. TARGETS gpu_queue
  135. DESTINATION ${INSTALL_LIB_DIR}
  136. COMPONENT mindspore
  137. )
  138. endif ()
  139. if (NOT ENABLE_GE)
  140. if (ENABLE_D)
  141. if (DEFINED ENV{ASCEND_CUSTOM_PATH})
  142. set(ASCEND_PATH $ENV{ASCEND_CUSTOM_PATH})
  143. else ()
  144. set(ASCEND_PATH /usr/local/Ascend)
  145. endif ()
  146. set(ASCEND_DRIVER_PATH ${ASCEND_PATH}/driver/lib64/common)
  147. set(ASCEND_FWK_PATH ${ASCEND_PATH}/fwkacllib/lib64)
  148. install(
  149. FILES
  150. ${CMAKE_BINARY_DIR}/graphengine/src/common/graph/libgraph.so
  151. ${CMAKE_BINARY_DIR}/graphengine/src/ge/common/libge_common.so
  152. ${CMAKE_BINARY_DIR}/graphengine/src/ge/ge_runtime/libge_runtime.so
  153. ${ASCEND_DRIVER_PATH}/libslog.so
  154. ${ASCEND_DRIVER_PATH}/libc_sec.so
  155. ${ASCEND_FWK_PATH}/liberror_manager.so
  156. DESTINATION ${INSTALL_LIB_DIR}
  157. COMPONENT mindspore
  158. )
  159. elseif (ENABLE_TESTCASES)
  160. install(
  161. FILES
  162. ${CMAKE_BINARY_DIR}/graphengine/src/common/graph/libgraph.so
  163. ${CMAKE_SOURCE_DIR}/graphengine/third_party/prebuild/${CMAKE_HOST_SYSTEM_PROCESSOR}/libslog.so
  164. ${CMAKE_SOURCE_DIR}/graphengine/third_party/prebuild/${CMAKE_HOST_SYSTEM_PROCESSOR}/liberror_manager.so
  165. ${CMAKE_SOURCE_DIR}/build/graphengine/libc_sec.so
  166. DESTINATION ${INSTALL_LIB_DIR}
  167. COMPONENT mindspore
  168. )
  169. endif ()
  170. endif ()
  171. if (CMAKE_SYSTEM_NAME MATCHES "Windows")
  172. get_filename_component(CXX_DIR ${CMAKE_CXX_COMPILER} PATH)
  173. file(GLOB CXX_LIB_LIST ${CXX_DIR}/*.dll)
  174. string(REPLACE "\\" "/" SystemRoot $ENV{SystemRoot})
  175. file(GLOB VC_LIB_LIST ${SystemRoot}/System32/msvcp140.dll ${SystemRoot}/System32/vcomp140.dll)
  176. file(GLOB JPEG_LIB_LIST ${jpeg_turbo_LIBPATH}/*.dll)
  177. file(GLOB SQLITE_LIB_LIST ${sqlite_LIBPATH}/*.dll)
  178. install(
  179. FILES ${CXX_LIB_LIST} ${JPEG_LIB_LIST} ${SQLITE_LIB_LIST} ${VC_LIB_LIST}
  180. DESTINATION ${INSTALL_LIB_DIR}
  181. COMPONENT mindspore
  182. )
  183. endif ()
  184. # set python files
  185. file(GLOB MS_PY_LIST ${CMAKE_SOURCE_DIR}/mindspore/*.py)
  186. install(
  187. FILES ${MS_PY_LIST}
  188. DESTINATION ${INSTALL_PY_DIR}
  189. COMPONENT mindspore
  190. )
  191. install(
  192. DIRECTORY
  193. ${CMAKE_SOURCE_DIR}/mindspore/nn
  194. ${CMAKE_SOURCE_DIR}/mindspore/_extends
  195. ${CMAKE_SOURCE_DIR}/mindspore/parallel
  196. ${CMAKE_SOURCE_DIR}/mindspore/mindrecord
  197. ${CMAKE_SOURCE_DIR}/mindspore/train
  198. ${CMAKE_SOURCE_DIR}/mindspore/common
  199. ${CMAKE_SOURCE_DIR}/mindspore/ops
  200. ${CMAKE_SOURCE_DIR}/mindspore/communication
  201. ${CMAKE_SOURCE_DIR}/mindspore/profiler
  202. DESTINATION ${INSTALL_PY_DIR}
  203. COMPONENT mindspore
  204. )
  205. if (ENABLE_GPU)
  206. install(
  207. DIRECTORY ${CMAKE_SOURCE_DIR}/mindspore/_akg
  208. DESTINATION ${INSTALL_PY_DIR}/../
  209. COMPONENT mindspore
  210. )
  211. if (EXISTS ${incubator_tvm_gpu_ROOT})
  212. file(GLOB_RECURSE GLOG_LIB_LIST ${incubator_tvm_gpu_LIBPATH}/lib*)
  213. install(
  214. FILES ${GLOG_LIB_LIST}
  215. DESTINATION ${INSTALL_LIB_DIR}
  216. COMPONENT mindspore
  217. )
  218. install(
  219. DIRECTORY
  220. ${incubator_tvm_gpu_ROOT}/topi/python/topi
  221. ${incubator_tvm_gpu_ROOT}/python/tvm
  222. DESTINATION ${INSTALL_PY_DIR}/../_akg
  223. COMPONENT mindspore
  224. )
  225. endif ()
  226. endif ()
  227. if (ENABLE_D 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. TARGETS inference
  251. DESTINATION ${INSTALL_LIB_DIR}
  252. COMPONENT mindspore
  253. )
  254. endif ()