• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1# include dependency
2include(CMakePackageConfigHelpers)
3include(GNUInstallDirs)
4
5# set package information
6set(CPACK_PACKAGE_NAME ${PROJECT_NAME})
7set(CPACK_GENERATOR "External")
8set(CPACK_CMAKE_GENERATOR "Ninja")
9set(CPACK_EXTERNAL_PACKAGE_SCRIPT ${CMAKE_SOURCE_DIR}/cmake/package_script.cmake)
10set(CPACK_EXTERNAL_ENABLE_STAGING true)
11set(CPACK_TEMPORARY_PACKAGE_FILE_NAME ${BUILD_PATH}/package/mindspore)
12set(CPACK_TEMPORARY_INSTALL_DIRECTORY ${BUILD_PATH}/package/mindspore)
13set(CPACK_PACK_ROOT_DIR ${BUILD_PATH}/package/)
14set(CPACK_CMAKE_SOURCE_DIR ${CMAKE_SOURCE_DIR})
15set(CPACK_ENABLE_SYM_FILE ${ENABLE_SYM_FILE})
16set(CPACK_CMAKE_BUILD_TYPE ${CMAKE_BUILD_TYPE})
17if(ENABLE_GE)
18    set(CPACK_MS_BACKEND "ge")
19    set(CPACK_MS_TARGET "ascend or cpu")
20    set(CPACK_MS_PACKAGE_NAME "mindspore")
21elseif(ENABLE_GPU)
22    set(CPACK_MS_BACKEND "ms")
23    set(CPACK_MS_TARGET "gpu or cpu")
24    set(CPACK_MS_PACKAGE_NAME "mindspore-gpu")
25elseif(ENABLE_D)
26    set(CPACK_MS_BACKEND "ms")
27    set(CPACK_MS_TARGET "ascend or cpu")
28    set(CPACK_MS_PACKAGE_NAME "mindspore-ascend")
29elseif(ENABLE_CPU)
30    set(CPACK_MS_BACKEND "ms")
31    set(CPACK_MS_TARGET "cpu")
32    set(CPACK_MS_PACKAGE_NAME "mindspore")
33elseif(ENABLE_ACL)
34    set(CPACK_MS_BACKEND "debug")
35    set(CPACK_MS_TARGET "ascend or gpu or cpu")
36    set(CPACK_MS_PACKAGE_NAME "mindspore-ascend")
37else()
38    set(CPACK_MS_BACKEND "debug")
39    set(CPACK_MS_TARGET "ascend or gpu or cpu")
40    set(CPACK_MS_PACKAGE_NAME "mindspore")
41endif()
42include(CPack)
43
44# set install path
45set(INSTALL_LIB_DIR ${CMAKE_INSTALL_LIBDIR} CACHE PATH "Installation directory for libraries")
46set(INSTALL_PY_DIR ".")
47set(INSTALL_BASE_DIR ".")
48set(INSTALL_BIN_DIR "bin")
49set(INSTALL_CFG_DIR "config")
50set(INSTALL_LIB_DIR "lib")
51# set package files
52install(
53    TARGETS _c_expression
54    DESTINATION ${INSTALL_BASE_DIR}
55    COMPONENT mindspore
56)
57
58if(ENABLE_DEBUGGER)
59    install(
60        TARGETS _mindspore_offline_debug
61        DESTINATION ${INSTALL_BASE_DIR}
62        COMPONENT mindspore
63    )
64endif()
65
66install(
67    TARGETS mindspore_shared_lib
68    DESTINATION ${INSTALL_LIB_DIR}
69    COMPONENT mindspore
70)
71
72install(
73    TARGETS mindspore_gvar
74    DESTINATION ${INSTALL_LIB_DIR}
75    COMPONENT mindspore
76)
77
78if(USE_GLOG)
79    install(FILES ${glog_LIBPATH}/libmindspore_glog.so.0.4.0
80      DESTINATION ${INSTALL_LIB_DIR} RENAME libmindspore_glog.so.0 COMPONENT mindspore)
81endif()
82
83install(FILES ${libevent_LIBPATH}/libevent-2.1.so.7.0.1
84  DESTINATION ${INSTALL_LIB_DIR} RENAME libevent-2.1.so.7 COMPONENT mindspore)
85install(FILES ${libevent_LIBPATH}/libevent_core-2.1.so.7.0.1
86  DESTINATION ${INSTALL_LIB_DIR} RENAME libevent_core-2.1.so.7 COMPONENT mindspore)
87install(FILES ${libevent_LIBPATH}/libevent_extra-2.1.so.7.0.1
88  DESTINATION ${INSTALL_LIB_DIR} RENAME libevent_extra-2.1.so.7 COMPONENT mindspore)
89install(FILES ${libevent_LIBPATH}/libevent_openssl-2.1.so.7.0.1
90  DESTINATION ${INSTALL_LIB_DIR} RENAME libevent_openssl-2.1.so.7 COMPONENT mindspore)
91install(FILES ${libevent_LIBPATH}/libevent_pthreads-2.1.so.7.0.1
92  DESTINATION ${INSTALL_LIB_DIR} RENAME libevent_pthreads-2.1.so.7 COMPONENT mindspore)
93
94if(ENABLE_MINDDATA)
95    install(
96        TARGETS _c_dataengine _c_mindrecord
97        DESTINATION ${INSTALL_BASE_DIR}
98        COMPONENT mindspore
99    )
100    if(CMAKE_SYSTEM_NAME MATCHES "Linux")
101        install(
102            TARGETS cache_admin cache_server
103            OPTIONAL
104            DESTINATION ${INSTALL_BIN_DIR}
105            COMPONENT mindspore
106        )
107    endif()
108    if(PYTHON_VERSION MATCHES "3.8" OR PYTHON_VERSION MATCHES "3.7")
109      install(FILES ${opencv_LIBPATH}/libopencv_core.so.4.2.0
110        DESTINATION ${INSTALL_LIB_DIR} RENAME libopencv_core.so.4.2 COMPONENT mindspore)
111      install(FILES ${opencv_LIBPATH}/libopencv_imgcodecs.so.4.2.0
112        DESTINATION ${INSTALL_LIB_DIR} RENAME libopencv_imgcodecs.so.4.2 COMPONENT mindspore)
113      install(FILES ${opencv_LIBPATH}/libopencv_imgproc.so.4.2.0
114        DESTINATION ${INSTALL_LIB_DIR} RENAME libopencv_imgproc.so.4.2 COMPONENT mindspore)
115    elseif(PYTHON_VERSION MATCHES "3.9")
116      install(FILES ${opencv_LIBPATH}/libopencv_core.so.4.5.1
117        DESTINATION ${INSTALL_LIB_DIR} RENAME libopencv_core.so.4.5 COMPONENT mindspore)
118      install(FILES ${opencv_LIBPATH}/libopencv_imgcodecs.so.4.5.1
119        DESTINATION ${INSTALL_LIB_DIR} RENAME libopencv_imgcodecs.so.4.5 COMPONENT mindspore)
120      install(FILES ${opencv_LIBPATH}/libopencv_imgproc.so.4.5.1
121        DESTINATION ${INSTALL_LIB_DIR} RENAME libopencv_imgproc.so.4.5 COMPONENT mindspore)
122    endif()
123    install(FILES ${tinyxml2_LIBPATH}/libtinyxml2.so.8.0.0
124      DESTINATION ${INSTALL_LIB_DIR} RENAME libtinyxml2.so.8 COMPONENT mindspore)
125
126    install(FILES ${icu4c_LIBPATH}/libicuuc.so.67.1
127      DESTINATION ${INSTALL_LIB_DIR} RENAME libicuuc.so.67 COMPONENT mindspore)
128    install(FILES ${icu4c_LIBPATH}/libicudata.so.67.1
129      DESTINATION ${INSTALL_LIB_DIR} RENAME libicudata.so.67 COMPONENT mindspore)
130    install(FILES ${icu4c_LIBPATH}/libicui18n.so.67.1
131      DESTINATION ${INSTALL_LIB_DIR} RENAME libicui18n.so.67 COMPONENT mindspore)
132endif()
133
134if(ENABLE_CPU)
135    if(CMAKE_SYSTEM_NAME MATCHES "Linux")
136        install(FILES ${onednn_LIBPATH}/libdnnl.so.2.2
137          DESTINATION ${INSTALL_LIB_DIR} RENAME libdnnl.so.2 COMPONENT mindspore)
138    elseif(CMAKE_SYSTEM_NAME MATCHES "Darwin")
139        file(GLOB_RECURSE DNNL_LIB_LIST ${onednn_LIBPATH}/libdnnl*${CMAKE_SHARED_LIBRARY_SUFFIX}*)
140        install(
141            FILES ${DNNL_LIB_LIST}
142            DESTINATION ${INSTALL_LIB_DIR}
143            COMPONENT mindspore
144        )
145    endif()
146    install(
147        TARGETS nnacl
148        DESTINATION ${INSTALL_LIB_DIR}
149        COMPONENT mindspore
150    )
151endif()
152
153if(ENABLE_MPI)
154    if(ENABLE_GPU)
155        install(
156            TARGETS _ms_mpi
157            DESTINATION ${INSTALL_BASE_DIR}
158            COMPONENT mindspore
159        )
160    endif()
161    if(ENABLE_CPU)
162        install(
163            TARGETS mpi_adapter
164            DESTINATION ${INSTALL_LIB_DIR}
165            COMPONENT mindspore
166        )
167    endif()
168    if(ENABLE_D)
169        install(
170                TARGETS _ascend_mpi
171                DESTINATION ${INSTALL_BASE_DIR}
172                COMPONENT mindspore
173        )
174    endif()
175endif()
176
177if(ENABLE_GPU)
178    if(ENABLE_MPI)
179        install(
180            TARGETS gpu_collective
181            DESTINATION ${INSTALL_LIB_DIR}
182            COMPONENT mindspore
183        )
184    endif()
185    install(
186        TARGETS gpu_queue
187        DESTINATION ${INSTALL_LIB_DIR}
188        COMPONENT mindspore
189    )
190endif()
191
192if(ENABLE_D)
193    if(ENABLE_MPI)
194        install(
195                TARGETS ascend_collective
196                DESTINATION ${INSTALL_LIB_DIR}
197                COMPONENT mindspore
198        )
199    endif()
200endif()
201
202if(ENABLE_CPU AND NOT WIN32)
203    install(
204        TARGETS ps_cache
205        DESTINATION ${INSTALL_LIB_DIR}
206        COMPONENT mindspore
207    )
208endif()
209
210if(NOT ENABLE_GE)
211    if(ENABLE_D OR ENABLE_ACL)
212        if(DEFINED ENV{ASCEND_CUSTOM_PATH})
213            set(ASCEND_PATH $ENV{ASCEND_CUSTOM_PATH})
214        else()
215            set(ASCEND_PATH /usr/local/Ascend)
216        endif()
217        set(ASCEND_DRIVER_PATH ${ASCEND_PATH}/driver/lib64/common)
218
219        if(ENABLE_D)
220            install(
221              TARGETS hccl_plugin
222              DESTINATION ${INSTALL_LIB_DIR}
223              COMPONENT mindspore
224            )
225        endif()
226    elseif(ENABLE_TESTCASES)
227        install(
228            FILES
229                ${CMAKE_BINARY_DIR}/graphengine/metadef/graph/libgraph.so
230                ${BUILD_PATH}/graphengine/c_sec/lib/libc_sec.so
231            DESTINATION ${INSTALL_LIB_DIR}
232            COMPONENT mindspore
233        )
234    endif()
235endif()
236
237if(MS_BUILD_GRPC)
238    install(FILES ${grpc_LIBPATH}/libmindspore_grpc++.so.1.36.1
239      DESTINATION ${INSTALL_LIB_DIR} RENAME libmindspore_grpc++.so.1 COMPONENT mindspore)
240    install(FILES ${grpc_LIBPATH}/libmindspore_grpc.so.15.0.0
241      DESTINATION ${INSTALL_LIB_DIR} RENAME libmindspore_grpc.so.15 COMPONENT mindspore)
242    install(FILES ${grpc_LIBPATH}/libmindspore_gpr.so.15.0.0
243      DESTINATION ${INSTALL_LIB_DIR} RENAME libmindspore_gpr.so.15 COMPONENT mindspore)
244    install(FILES ${grpc_LIBPATH}/libmindspore_upb.so.15.0.0
245      DESTINATION ${INSTALL_LIB_DIR} RENAME libmindspore_upb.so.15 COMPONENT mindspore)
246    install(FILES ${grpc_LIBPATH}/libmindspore_address_sorting.so.15.0.0
247      DESTINATION ${INSTALL_LIB_DIR} RENAME libmindspore_address_sorting.so.15 COMPONENT mindspore)
248endif()
249
250if(CMAKE_SYSTEM_NAME MATCHES "Windows")
251    get_filename_component(CXX_DIR ${CMAKE_CXX_COMPILER} PATH)
252    file(GLOB CXX_LIB_LIST ${CXX_DIR}/*.dll)
253
254    string(REPLACE "\\" "/" SystemRoot $ENV{SystemRoot})
255    file(GLOB VC_LIB_LIST ${SystemRoot}/System32/msvcp140.dll ${SystemRoot}/System32/vcomp140.dll)
256
257    file(GLOB JPEG_LIB_LIST ${jpeg_turbo_LIBPATH}/*.dll)
258    file(GLOB SQLITE_LIB_LIST ${sqlite_LIBPATH}/*.dll)
259    install(
260        FILES ${CXX_LIB_LIST} ${JPEG_LIB_LIST} ${SQLITE_LIB_LIST} ${VC_LIB_LIST}
261        DESTINATION ${INSTALL_LIB_DIR}
262        COMPONENT mindspore
263    )
264endif()
265
266# set python files
267file(GLOB MS_PY_LIST ${CMAKE_SOURCE_DIR}/mindspore/*.py)
268install(
269    FILES ${MS_PY_LIST}
270    DESTINATION ${INSTALL_PY_DIR}
271    COMPONENT mindspore
272)
273
274install(
275    DIRECTORY
276        ${CMAKE_SOURCE_DIR}/mindspore/nn
277        ${CMAKE_SOURCE_DIR}/mindspore/_extends
278        ${CMAKE_SOURCE_DIR}/mindspore/parallel
279        ${CMAKE_SOURCE_DIR}/mindspore/mindrecord
280        ${CMAKE_SOURCE_DIR}/mindspore/numpy
281        ${CMAKE_SOURCE_DIR}/mindspore/train
282        ${CMAKE_SOURCE_DIR}/mindspore/boost
283        ${CMAKE_SOURCE_DIR}/mindspore/common
284        ${CMAKE_SOURCE_DIR}/mindspore/ops
285        ${CMAKE_SOURCE_DIR}/mindspore/communication
286        ${CMAKE_SOURCE_DIR}/mindspore/profiler
287        ${CMAKE_SOURCE_DIR}/mindspore/explainer
288        ${CMAKE_SOURCE_DIR}/mindspore/compression
289        ${CMAKE_SOURCE_DIR}/mindspore/run_check
290    DESTINATION ${INSTALL_PY_DIR}
291    COMPONENT mindspore
292)
293
294if((ENABLE_D OR ENABLE_GPU) AND ENABLE_AKG)
295    set (AKG_PATH ${BUILD_PATH}/mindspore/akg)
296    file(REMOVE_RECURSE ${AKG_PATH}/_akg)
297    file(MAKE_DIRECTORY ${AKG_PATH}/_akg)
298    file(TOUCH ${AKG_PATH}/_akg/__init__.py)
299    install(DIRECTORY "${AKG_PATH}/akg" DESTINATION "${AKG_PATH}/_akg")
300    install(
301        DIRECTORY
302            ${AKG_PATH}/_akg
303        DESTINATION ${INSTALL_PY_DIR}/
304        COMPONENT mindspore
305    )
306endif()
307
308if(EXISTS ${CMAKE_SOURCE_DIR}/mindspore/dataset)
309    install(
310        DIRECTORY ${CMAKE_SOURCE_DIR}/mindspore/dataset
311        DESTINATION ${INSTALL_PY_DIR}
312        COMPONENT mindspore
313    )
314endif()
315
316if(CMAKE_SYSTEM_NAME MATCHES "Windows")
317    message("offline debugger does not support windows system temporarily")
318else()
319    if(EXISTS ${CMAKE_SOURCE_DIR}/mindspore/offline_debug)
320        install(
321            DIRECTORY ${CMAKE_SOURCE_DIR}/mindspore/offline_debug
322            DESTINATION ${INSTALL_PY_DIR}
323            COMPONENT mindspore
324        )
325    endif()
326endif()
327
328## Public header files
329install(
330    DIRECTORY ${CMAKE_SOURCE_DIR}/include
331    DESTINATION ${INSTALL_BASE_DIR}
332    COMPONENT mindspore
333)
334
335## Public header files for minddata
336install(
337    FILES ${CMAKE_SOURCE_DIR}/mindspore/ccsrc/minddata/dataset/include/dataset/config.h
338          ${CMAKE_SOURCE_DIR}/mindspore/ccsrc/minddata/dataset/include/dataset/constants.h
339          ${CMAKE_SOURCE_DIR}/mindspore/ccsrc/minddata/dataset/include/dataset/execute.h
340          ${CMAKE_SOURCE_DIR}/mindspore/ccsrc/minddata/dataset/include/dataset/text.h
341          ${CMAKE_SOURCE_DIR}/mindspore/ccsrc/minddata/dataset/include/dataset/transforms.h
342          ${CMAKE_SOURCE_DIR}/mindspore/ccsrc/minddata/dataset/include/dataset/vision.h
343          ${CMAKE_SOURCE_DIR}/mindspore/ccsrc/minddata/dataset/include/dataset/vision_lite.h
344          ${CMAKE_SOURCE_DIR}/mindspore/ccsrc/minddata/dataset/include/dataset/vision_ascend.h
345    DESTINATION ${INSTALL_BASE_DIR}/include/dataset
346    COMPONENT mindspore
347)
348
349## config files
350install(
351    FILES ${CMAKE_SOURCE_DIR}/config/op_info.config
352    DESTINATION ${INSTALL_CFG_DIR}
353    COMPONENT mindspore
354)
355
356