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 6.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
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221
  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. else ()
  40. set(INSTALL_LIB_DIR "lib")
  41. endif ()
  42. # set package files
  43. install(
  44. TARGETS _c_expression
  45. DESTINATION ${INSTALL_BASE_DIR}
  46. COMPONENT mindspore
  47. )
  48. install(
  49. TARGETS mindspore_gvar
  50. DESTINATION ${INSTALL_LIB_DIR}
  51. COMPONENT mindspore
  52. )
  53. if (USE_GLOG)
  54. file(GLOB_RECURSE GLOG_LIB_LIST ${glog_LIBPATH}/libglog*)
  55. install(
  56. FILES ${GLOG_LIB_LIST}
  57. DESTINATION ${INSTALL_LIB_DIR}
  58. COMPONENT mindspore
  59. )
  60. endif ()
  61. if (ENABLE_MINDDATA)
  62. install(
  63. TARGETS _c_dataengine _c_mindrecord
  64. DESTINATION ${INSTALL_BASE_DIR}
  65. COMPONENT mindspore
  66. )
  67. file(GLOB_RECURSE OPENCV_LIB_LIST
  68. ${opencv_LIBPATH}/libopencv_core*
  69. ${opencv_LIBPATH}/libopencv_imgcodecs*
  70. ${opencv_LIBPATH}/libopencv_imgproc*
  71. )
  72. install(
  73. FILES ${OPENCV_LIB_LIST}
  74. DESTINATION ${INSTALL_LIB_DIR}
  75. COMPONENT mindspore
  76. )
  77. endif ()
  78. if (ENABLE_CPU)
  79. if (CMAKE_SYSTEM_NAME MATCHES "Linux")
  80. file(GLOB_RECURSE DNNL_LIB_LIST ${onednn_LIBPATH}/libdnnl${CMAKE_SHARED_LIBRARY_SUFFIX}*)
  81. elseif (CMAKE_SYSTEM_NAME MATCHES "Darwin")
  82. file(GLOB_RECURSE DNNL_LIB_LIST ${onednn_LIBPATH}/libdnnl*${CMAKE_SHARED_LIBRARY_SUFFIX}*)
  83. elseif (CMAKE_SYSTEM_NAME MATCHES "Windows")
  84. file(GLOB_RECURSE DNNL_LIB_LIST ${onednn_LIBPATH}/dnnl.dll)
  85. endif ()
  86. install(
  87. FILES ${DNNL_LIB_LIST}
  88. DESTINATION ${INSTALL_LIB_DIR}
  89. COMPONENT mindspore
  90. )
  91. endif ()
  92. if (ENABLE_GPU)
  93. if (ENABLE_MPI)
  94. install(
  95. TARGETS _ms_mpi
  96. DESTINATION ${INSTALL_BASE_DIR}
  97. COMPONENT mindspore
  98. )
  99. install(
  100. TARGETS gpu_collective
  101. DESTINATION ${INSTALL_LIB_DIR}
  102. COMPONENT mindspore
  103. )
  104. endif ()
  105. install(
  106. TARGETS gpu_queue
  107. DESTINATION ${INSTALL_LIB_DIR}
  108. COMPONENT mindspore
  109. )
  110. endif ()
  111. if (NOT ENABLE_GE)
  112. if (ENABLE_D)
  113. if (DEFINED ENV{ASCEND_CUSTOM_PATH})
  114. set(ASCEND_PATH $ENV{ASCEND_CUSTOM_PATH})
  115. else ()
  116. set(ASCEND_PATH /usr/local/Ascend)
  117. endif ()
  118. set(ASCEND_DRIVER_PATH ${ASCEND_PATH}/driver/lib64/common)
  119. install(
  120. FILES
  121. ${CMAKE_BINARY_DIR}/graphengine/src/common/graph/libgraph.so
  122. ${CMAKE_BINARY_DIR}/graphengine/src/ge/common/libge_common.so
  123. ${CMAKE_BINARY_DIR}/graphengine/src/ge/ge_runtime/libge_runtime.so
  124. ${ASCEND_DRIVER_PATH}/libslog.so
  125. ${ASCEND_DRIVER_PATH}/libc_sec.so
  126. DESTINATION ${INSTALL_LIB_DIR}
  127. COMPONENT mindspore
  128. )
  129. elseif (ENABLE_TESTCASES)
  130. install(
  131. FILES
  132. ${CMAKE_BINARY_DIR}/graphengine/src/common/graph/libgraph.so
  133. ${CMAKE_SOURCE_DIR}/graphengine/third_party/prebuild/${CMAKE_HOST_SYSTEM_PROCESSOR}/libslog.so
  134. ${CMAKE_SOURCE_DIR}/graphengine/third_party/prebuild/${CMAKE_HOST_SYSTEM_PROCESSOR}/libc_sec.so
  135. DESTINATION ${INSTALL_LIB_DIR}
  136. COMPONENT mindspore
  137. )
  138. endif ()
  139. endif ()
  140. if (CMAKE_SYSTEM_NAME MATCHES "Windows")
  141. get_filename_component(CXX_DIR ${CMAKE_CXX_COMPILER} PATH)
  142. file(GLOB CXX_LIB_LIST ${CXX_DIR}/*.dll)
  143. string(REPLACE "\\" "/" SystemRoot $ENV{SystemRoot})
  144. file(GLOB VC_LIB_LIST ${SystemRoot}/System32/msvcp140.dll ${SystemRoot}/System32/vcomp140.dll)
  145. file(GLOB JPEG_LIB_LIST ${jpeg_turbo_LIBPATH}/*.dll)
  146. file(GLOB SQLITE_LIB_LIST ${sqlite_LIBPATH}/*.dll)
  147. install(
  148. FILES ${CXX_LIB_LIST} ${JPEG_LIB_LIST} ${SQLITE_LIB_LIST} ${VC_LIB_LIST}
  149. DESTINATION ${INSTALL_LIB_DIR}
  150. COMPONENT mindspore
  151. )
  152. endif ()
  153. # set python files
  154. file(GLOB MS_PY_LIST ${CMAKE_SOURCE_DIR}/mindspore/*.py)
  155. install(
  156. FILES ${MS_PY_LIST}
  157. DESTINATION ${INSTALL_PY_DIR}
  158. COMPONENT mindspore
  159. )
  160. install(
  161. DIRECTORY
  162. ${CMAKE_SOURCE_DIR}/mindspore/nn
  163. ${CMAKE_SOURCE_DIR}/mindspore/_extends
  164. ${CMAKE_SOURCE_DIR}/mindspore/parallel
  165. ${CMAKE_SOURCE_DIR}/mindspore/mindrecord
  166. ${CMAKE_SOURCE_DIR}/mindspore/train
  167. ${CMAKE_SOURCE_DIR}/mindspore/model_zoo
  168. ${CMAKE_SOURCE_DIR}/mindspore/common
  169. ${CMAKE_SOURCE_DIR}/mindspore/ops
  170. ${CMAKE_SOURCE_DIR}/mindspore/communication
  171. DESTINATION ${INSTALL_PY_DIR}
  172. COMPONENT mindspore
  173. )
  174. if (ENABLE_GPU)
  175. install(
  176. DIRECTORY ${CMAKE_SOURCE_DIR}/mindspore/_akg
  177. DESTINATION ${INSTALL_PY_DIR}/../
  178. COMPONENT mindspore
  179. )
  180. if (EXISTS ${incubator_tvm_gpu_ROOT})
  181. file(GLOB_RECURSE GLOG_LIB_LIST ${incubator_tvm_gpu_LIBPATH}/lib*)
  182. install(
  183. FILES ${GLOG_LIB_LIST}
  184. DESTINATION ${INSTALL_LIB_DIR}
  185. COMPONENT mindspore
  186. )
  187. install(
  188. DIRECTORY
  189. ${incubator_tvm_gpu_ROOT}/topi/python/topi
  190. ${incubator_tvm_gpu_ROOT}/python/tvm
  191. DESTINATION ${INSTALL_PY_DIR}/../_akg
  192. COMPONENT mindspore
  193. )
  194. endif ()
  195. endif ()
  196. if (EXISTS ${CMAKE_SOURCE_DIR}/mindspore/dataset)
  197. install(
  198. DIRECTORY ${CMAKE_SOURCE_DIR}/mindspore/dataset
  199. DESTINATION ${INSTALL_PY_DIR}
  200. COMPONENT mindspore
  201. )
  202. endif ()