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