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 5.5 kB

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