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.9 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
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232
  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. endif ()
  87. if (ENABLE_CPU)
  88. if (CMAKE_SYSTEM_NAME MATCHES "Linux")
  89. file(GLOB_RECURSE DNNL_LIB_LIST ${onednn_LIBPATH}/libdnnl${CMAKE_SHARED_LIBRARY_SUFFIX}*)
  90. elseif (CMAKE_SYSTEM_NAME MATCHES "Darwin")
  91. file(GLOB_RECURSE DNNL_LIB_LIST ${onednn_LIBPATH}/libdnnl*${CMAKE_SHARED_LIBRARY_SUFFIX}*)
  92. elseif (CMAKE_SYSTEM_NAME MATCHES "Windows")
  93. file(GLOB_RECURSE DNNL_LIB_LIST ${onednn_LIBPATH}/dnnl.dll)
  94. endif ()
  95. install(
  96. FILES ${DNNL_LIB_LIST}
  97. DESTINATION ${INSTALL_LIB_DIR}
  98. COMPONENT mindspore
  99. )
  100. endif ()
  101. if (ENABLE_MPI)
  102. install(
  103. TARGETS _ms_mpi
  104. DESTINATION ${INSTALL_BASE_DIR}
  105. COMPONENT mindspore
  106. )
  107. endif ()
  108. if (ENABLE_GPU)
  109. install(
  110. TARGETS gpu_collective
  111. DESTINATION ${INSTALL_LIB_DIR}
  112. COMPONENT mindspore
  113. )
  114. install(
  115. TARGETS gpu_queue
  116. DESTINATION ${INSTALL_LIB_DIR}
  117. COMPONENT mindspore
  118. )
  119. endif ()
  120. if (NOT ENABLE_GE)
  121. if (ENABLE_D)
  122. if (DEFINED ENV{ASCEND_CUSTOM_PATH})
  123. set(ASCEND_PATH $ENV{ASCEND_CUSTOM_PATH})
  124. else ()
  125. set(ASCEND_PATH /usr/local/Ascend)
  126. endif ()
  127. set(ASCEND_DRIVER_PATH ${ASCEND_PATH}/driver/lib64/common)
  128. install(
  129. FILES
  130. ${CMAKE_BINARY_DIR}/graphengine/src/common/graph/libgraph.so
  131. ${CMAKE_BINARY_DIR}/graphengine/src/ge/common/libge_common.so
  132. ${CMAKE_BINARY_DIR}/graphengine/src/ge/ge_runtime/libge_runtime.so
  133. ${ASCEND_DRIVER_PATH}/libslog.so
  134. ${ASCEND_DRIVER_PATH}/libc_sec.so
  135. DESTINATION ${INSTALL_LIB_DIR}
  136. COMPONENT mindspore
  137. )
  138. elseif (ENABLE_TESTCASES)
  139. install(
  140. FILES
  141. ${CMAKE_BINARY_DIR}/graphengine/src/common/graph/libgraph.so
  142. ${CMAKE_SOURCE_DIR}/graphengine/third_party/prebuild/${CMAKE_HOST_SYSTEM_PROCESSOR}/libslog.so
  143. ${CMAKE_SOURCE_DIR}/build/graphengine/libc_sec.so
  144. DESTINATION ${INSTALL_LIB_DIR}
  145. COMPONENT mindspore
  146. )
  147. endif ()
  148. endif ()
  149. if (CMAKE_SYSTEM_NAME MATCHES "Windows")
  150. get_filename_component(CXX_DIR ${CMAKE_CXX_COMPILER} PATH)
  151. file(GLOB CXX_LIB_LIST ${CXX_DIR}/*.dll)
  152. string(REPLACE "\\" "/" SystemRoot $ENV{SystemRoot})
  153. file(GLOB VC_LIB_LIST ${SystemRoot}/System32/msvcp140.dll ${SystemRoot}/System32/vcomp140.dll)
  154. file(GLOB JPEG_LIB_LIST ${jpeg_turbo_LIBPATH}/*.dll)
  155. file(GLOB SQLITE_LIB_LIST ${sqlite_LIBPATH}/*.dll)
  156. install(
  157. FILES ${CXX_LIB_LIST} ${JPEG_LIB_LIST} ${SQLITE_LIB_LIST} ${VC_LIB_LIST}
  158. DESTINATION ${INSTALL_LIB_DIR}
  159. COMPONENT mindspore
  160. )
  161. endif ()
  162. # set python files
  163. file(GLOB MS_PY_LIST ${CMAKE_SOURCE_DIR}/mindspore/*.py)
  164. install(
  165. FILES ${MS_PY_LIST}
  166. DESTINATION ${INSTALL_PY_DIR}
  167. COMPONENT mindspore
  168. )
  169. install(
  170. DIRECTORY
  171. ${CMAKE_SOURCE_DIR}/mindspore/nn
  172. ${CMAKE_SOURCE_DIR}/mindspore/_extends
  173. ${CMAKE_SOURCE_DIR}/mindspore/parallel
  174. ${CMAKE_SOURCE_DIR}/mindspore/mindrecord
  175. ${CMAKE_SOURCE_DIR}/mindspore/train
  176. ${CMAKE_SOURCE_DIR}/mindspore/model_zoo
  177. ${CMAKE_SOURCE_DIR}/mindspore/common
  178. ${CMAKE_SOURCE_DIR}/mindspore/ops
  179. ${CMAKE_SOURCE_DIR}/mindspore/communication
  180. DESTINATION ${INSTALL_PY_DIR}
  181. COMPONENT mindspore
  182. )
  183. if (ENABLE_GPU)
  184. install(
  185. DIRECTORY ${CMAKE_SOURCE_DIR}/mindspore/_akg
  186. DESTINATION ${INSTALL_PY_DIR}/../
  187. COMPONENT mindspore
  188. )
  189. if (EXISTS ${incubator_tvm_gpu_ROOT})
  190. file(GLOB_RECURSE GLOG_LIB_LIST ${incubator_tvm_gpu_LIBPATH}/lib*)
  191. install(
  192. FILES ${GLOG_LIB_LIST}
  193. DESTINATION ${INSTALL_LIB_DIR}
  194. COMPONENT mindspore
  195. )
  196. install(
  197. DIRECTORY
  198. ${incubator_tvm_gpu_ROOT}/topi/python/topi
  199. ${incubator_tvm_gpu_ROOT}/python/tvm
  200. DESTINATION ${INSTALL_PY_DIR}/../_akg
  201. COMPONENT mindspore
  202. )
  203. endif ()
  204. endif ()
  205. if (EXISTS ${CMAKE_SOURCE_DIR}/mindspore/dataset)
  206. install(
  207. DIRECTORY ${CMAKE_SOURCE_DIR}/mindspore/dataset
  208. DESTINATION ${INSTALL_PY_DIR}
  209. COMPONENT mindspore
  210. )
  211. endif ()