• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1# include dependency
2include(CMakePackageConfigHelpers)
3include(GNUInstallDirs)
4
5# prepare output directory
6file(REMOVE_RECURSE ${CMAKE_SOURCE_DIR}/output)
7file(MAKE_DIRECTORY ${CMAKE_SOURCE_DIR}/output)
8
9# cpack variables
10file(READ ${CMAKE_SOURCE_DIR}/version.txt VERSION_NUMBER)
11string(TOLOWER linux_${CMAKE_HOST_SYSTEM_PROCESSOR} PLATFORM_NAME)
12set(CPACK_PACKAGE_FILE_NAME mindspore_ascend-${VERSION_NUMBER}-${PLATFORM_NAME})
13set(CPACK_GENERATOR "TGZ")
14set(CPACK_PACKAGE_CHECKSUM SHA256)
15set(CPACK_PACKAGE_DIRECTORY ${CMAKE_SOURCE_DIR}/output)
16
17set(INSTALL_LIB_DIR ${CMAKE_INSTALL_LIBDIR} CACHE PATH "Installation directory for libraries")
18set(INSTALL_BASE_DIR ".")
19set(INSTALL_BIN_DIR "bin")
20set(INSTALL_CFG_DIR "config")
21set(INSTALL_LIB_DIR "lib")
22
23# set package files
24install(
25        TARGETS mindspore_shared_lib
26        DESTINATION ${INSTALL_LIB_DIR}
27        COMPONENT mindspore
28)
29
30install(
31        TARGETS mindspore_gvar
32        DESTINATION ${INSTALL_LIB_DIR}
33        COMPONENT mindspore
34)
35
36if(USE_GLOG)
37    file(GLOB_RECURSE GLOG_LIB_LIST ${glog_LIBPATH}/libmindspore_glog*)
38    install(
39            FILES ${GLOG_LIB_LIST}
40            DESTINATION ${INSTALL_LIB_DIR}
41            COMPONENT mindspore
42    )
43endif()
44
45file(GLOB_RECURSE LIBEVENT_LIB_LIST
46        ${libevent_LIBPATH}/libevent*${CMAKE_SHARED_LIBRARY_SUFFIX}*
47        ${libevent_LIBPATH}/libevent_pthreads*${CMAKE_SHARED_LIBRARY_SUFFIX}*
48        )
49
50install(
51        FILES ${LIBEVENT_LIB_LIST}
52        DESTINATION ${INSTALL_LIB_DIR}
53        COMPONENT mindspore
54)
55
56if(ENABLE_MINDDATA)
57    install(
58            TARGETS _c_dataengine _c_mindrecord
59            DESTINATION ${INSTALL_BASE_DIR}
60            COMPONENT mindspore
61    )
62    install(
63            TARGETS cache_admin cache_server
64            OPTIONAL
65            DESTINATION ${INSTALL_BIN_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 ${tinyxml2_LIBPATH}/libtinyxml2*)
79    install(
80            FILES ${TINYXML2_LIB_LIST}
81            DESTINATION ${INSTALL_LIB_DIR}
82            COMPONENT mindspore
83    )
84    file(GLOB_RECURSE ICU4C_LIB_LIST
85            ${icu4c_LIBPATH}/libicuuc*
86            ${icu4c_LIBPATH}/libicudata*
87            ${icu4c_LIBPATH}/libicui18n*
88            )
89    install(
90            FILES ${ICU4C_LIB_LIST}
91            DESTINATION ${INSTALL_LIB_DIR}
92            COMPONENT mindspore
93    )
94endif()
95
96# CPU mode
97if(ENABLE_CPU AND NOT WIN32)
98    install(
99            TARGETS ps_cache
100            DESTINATION ${INSTALL_LIB_DIR}
101            COMPONENT mindspore
102    )
103endif()
104
105if(ENABLE_CPU)
106    if(CMAKE_SYSTEM_NAME MATCHES "Linux")
107        file(GLOB_RECURSE DNNL_LIB_LIST ${onednn_LIBPATH}/libdnnl${CMAKE_SHARED_LIBRARY_SUFFIX}*)
108    elseif(CMAKE_SYSTEM_NAME MATCHES "Darwin")
109        file(GLOB_RECURSE DNNL_LIB_LIST ${onednn_LIBPATH}/libdnnl*${CMAKE_SHARED_LIBRARY_SUFFIX}*)
110    elseif(CMAKE_SYSTEM_NAME MATCHES "Windows")
111        file(GLOB_RECURSE DNNL_LIB_LIST ${onednn_LIBPATH}/dnnl.dll)
112    endif()
113    install(
114            FILES ${DNNL_LIB_LIST}
115            DESTINATION ${INSTALL_LIB_DIR}
116            COMPONENT mindspore
117    )
118    install(
119            TARGETS nnacl
120            DESTINATION ${INSTALL_LIB_DIR}
121            COMPONENT mindspore
122    )
123endif()
124
125if(MS_BUILD_GRPC)
126    install(FILES ${grpc_LIBPATH}/libmindspore_grpc++.so.1.36.1
127            DESTINATION ${INSTALL_LIB_DIR} RENAME libmindspore_grpc++.so.1 COMPONENT mindspore)
128    install(FILES ${grpc_LIBPATH}/libmindspore_grpc.so.15.0.0
129            DESTINATION ${INSTALL_LIB_DIR} RENAME libmindspore_grpc.so.15 COMPONENT mindspore)
130    install(FILES ${grpc_LIBPATH}/libmindspore_gpr.so.15.0.0
131            DESTINATION ${INSTALL_LIB_DIR} RENAME libmindspore_gpr.so.15 COMPONENT mindspore)
132    install(FILES ${grpc_LIBPATH}/libmindspore_upb.so.15.0.0
133            DESTINATION ${INSTALL_LIB_DIR} RENAME libmindspore_upb.so.15 COMPONENT mindspore)
134    install(FILES ${grpc_LIBPATH}/libmindspore_address_sorting.so.15.0.0
135            DESTINATION ${INSTALL_LIB_DIR} RENAME libmindspore_address_sorting.so.15 COMPONENT mindspore)
136endif()
137
138## Public header files
139install(
140        DIRECTORY ${CMAKE_SOURCE_DIR}/include
141        DESTINATION ${INSTALL_BASE_DIR}
142        COMPONENT mindspore
143)
144
145## Public header files for minddata
146install(
147        FILES ${CMAKE_SOURCE_DIR}/mindspore/ccsrc/minddata/dataset/include/dataset/config.h
148        ${CMAKE_SOURCE_DIR}/mindspore/ccsrc/minddata/dataset/include/dataset/constants.h
149        ${CMAKE_SOURCE_DIR}/mindspore/ccsrc/minddata/dataset/include/dataset/execute.h
150        ${CMAKE_SOURCE_DIR}/mindspore/ccsrc/minddata/dataset/include/dataset/text.h
151        ${CMAKE_SOURCE_DIR}/mindspore/ccsrc/minddata/dataset/include/dataset/transforms.h
152        ${CMAKE_SOURCE_DIR}/mindspore/ccsrc/minddata/dataset/include/dataset/vision.h
153        ${CMAKE_SOURCE_DIR}/mindspore/ccsrc/minddata/dataset/include/dataset/vision_lite.h
154        ${CMAKE_SOURCE_DIR}/mindspore/ccsrc/minddata/dataset/include/dataset/vision_ascend.h
155        DESTINATION ${INSTALL_BASE_DIR}/include/dataset
156        COMPONENT mindspore
157)
158
159## config files
160install(
161        FILES ${CMAKE_SOURCE_DIR}/config/op_info.config
162        DESTINATION ${INSTALL_CFG_DIR}
163        COMPONENT mindspore
164)
165
166include(CPack)
167