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 7.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
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245
  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. endif ()
  122. if (ENABLE_GPU)
  123. install(
  124. TARGETS gpu_collective
  125. DESTINATION ${INSTALL_LIB_DIR}
  126. COMPONENT mindspore
  127. )
  128. install(
  129. TARGETS gpu_queue
  130. DESTINATION ${INSTALL_LIB_DIR}
  131. COMPONENT mindspore
  132. )
  133. endif ()
  134. if (NOT ENABLE_GE)
  135. if (ENABLE_D)
  136. if (DEFINED ENV{ASCEND_CUSTOM_PATH})
  137. set(ASCEND_PATH $ENV{ASCEND_CUSTOM_PATH})
  138. else ()
  139. set(ASCEND_PATH /usr/local/Ascend)
  140. endif ()
  141. set(ASCEND_DRIVER_PATH ${ASCEND_PATH}/driver/lib64/common)
  142. install(
  143. FILES
  144. ${CMAKE_BINARY_DIR}/graphengine/src/common/graph/libgraph.so
  145. ${CMAKE_BINARY_DIR}/graphengine/src/ge/common/libge_common.so
  146. ${CMAKE_BINARY_DIR}/graphengine/src/ge/ge_runtime/libge_runtime.so
  147. ${ASCEND_DRIVER_PATH}/libslog.so
  148. ${ASCEND_DRIVER_PATH}/libc_sec.so
  149. DESTINATION ${INSTALL_LIB_DIR}
  150. COMPONENT mindspore
  151. )
  152. elseif (ENABLE_TESTCASES)
  153. install(
  154. FILES
  155. ${CMAKE_BINARY_DIR}/graphengine/src/common/graph/libgraph.so
  156. ${CMAKE_SOURCE_DIR}/graphengine/third_party/prebuild/${CMAKE_HOST_SYSTEM_PROCESSOR}/libslog.so
  157. ${CMAKE_SOURCE_DIR}/build/graphengine/libc_sec.so
  158. DESTINATION ${INSTALL_LIB_DIR}
  159. COMPONENT mindspore
  160. )
  161. endif ()
  162. endif ()
  163. if (CMAKE_SYSTEM_NAME MATCHES "Windows")
  164. get_filename_component(CXX_DIR ${CMAKE_CXX_COMPILER} PATH)
  165. file(GLOB CXX_LIB_LIST ${CXX_DIR}/*.dll)
  166. string(REPLACE "\\" "/" SystemRoot $ENV{SystemRoot})
  167. file(GLOB VC_LIB_LIST ${SystemRoot}/System32/msvcp140.dll ${SystemRoot}/System32/vcomp140.dll)
  168. file(GLOB JPEG_LIB_LIST ${jpeg_turbo_LIBPATH}/*.dll)
  169. file(GLOB SQLITE_LIB_LIST ${sqlite_LIBPATH}/*.dll)
  170. install(
  171. FILES ${CXX_LIB_LIST} ${JPEG_LIB_LIST} ${SQLITE_LIB_LIST} ${VC_LIB_LIST}
  172. DESTINATION ${INSTALL_LIB_DIR}
  173. COMPONENT mindspore
  174. )
  175. endif ()
  176. # set python files
  177. file(GLOB MS_PY_LIST ${CMAKE_SOURCE_DIR}/mindspore/*.py)
  178. install(
  179. FILES ${MS_PY_LIST}
  180. DESTINATION ${INSTALL_PY_DIR}
  181. COMPONENT mindspore
  182. )
  183. install(
  184. DIRECTORY
  185. ${CMAKE_SOURCE_DIR}/mindspore/nn
  186. ${CMAKE_SOURCE_DIR}/mindspore/_extends
  187. ${CMAKE_SOURCE_DIR}/mindspore/parallel
  188. ${CMAKE_SOURCE_DIR}/mindspore/mindrecord
  189. ${CMAKE_SOURCE_DIR}/mindspore/train
  190. ${CMAKE_SOURCE_DIR}/mindspore/model_zoo
  191. ${CMAKE_SOURCE_DIR}/mindspore/common
  192. ${CMAKE_SOURCE_DIR}/mindspore/ops
  193. ${CMAKE_SOURCE_DIR}/mindspore/communication
  194. DESTINATION ${INSTALL_PY_DIR}
  195. COMPONENT mindspore
  196. )
  197. if (ENABLE_GPU)
  198. install(
  199. DIRECTORY ${CMAKE_SOURCE_DIR}/mindspore/_akg
  200. DESTINATION ${INSTALL_PY_DIR}/../
  201. COMPONENT mindspore
  202. )
  203. if (EXISTS ${incubator_tvm_gpu_ROOT})
  204. file(GLOB_RECURSE GLOG_LIB_LIST ${incubator_tvm_gpu_LIBPATH}/lib*)
  205. install(
  206. FILES ${GLOG_LIB_LIST}
  207. DESTINATION ${INSTALL_LIB_DIR}
  208. COMPONENT mindspore
  209. )
  210. install(
  211. DIRECTORY
  212. ${incubator_tvm_gpu_ROOT}/topi/python/topi
  213. ${incubator_tvm_gpu_ROOT}/python/tvm
  214. DESTINATION ${INSTALL_PY_DIR}/../_akg
  215. COMPONENT mindspore
  216. )
  217. endif ()
  218. endif ()
  219. if (EXISTS ${CMAKE_SOURCE_DIR}/mindspore/dataset)
  220. install(
  221. DIRECTORY ${CMAKE_SOURCE_DIR}/mindspore/dataset
  222. DESTINATION ${INSTALL_PY_DIR}
  223. COMPONENT mindspore
  224. )
  225. endif ()