mindspore/cmake/package.cmake

394 lines
12 KiB
CMake
Raw Normal View History

2020-04-13 15:30:25 +08:00
# include dependency
include(CMakePackageConfigHelpers)
include(GNUInstallDirs)
# set package information
set(CPACK_PACKAGE_NAME ${PROJECT_NAME})
set(CPACK_GENERATOR "External")
set(CPACK_CMAKE_GENERATOR "Ninja")
2020-04-13 15:30:25 +08:00
set(CPACK_EXTERNAL_PACKAGE_SCRIPT ${CMAKE_SOURCE_DIR}/cmake/package_script.cmake)
set(CPACK_EXTERNAL_ENABLE_STAGING true)
set(CPACK_TEMPORARY_PACKAGE_FILE_NAME ${BUILD_PATH}/package/mindspore)
set(CPACK_TEMPORARY_INSTALL_DIRECTORY ${BUILD_PATH}/package/mindspore)
set(CPACK_PACK_ROOT_DIR ${BUILD_PATH}/package/)
set(CPACK_CMAKE_SOURCE_DIR ${CMAKE_SOURCE_DIR})
set(CPACK_ENABLE_SYM_FILE ${ENABLE_SYM_FILE})
set(CPACK_CMAKE_BUILD_TYPE ${CMAKE_BUILD_TYPE})
set(CPACK_PYTHON_EXE ${Python3_EXECUTABLE})
set(CPACK_PYTHON_VERSION ${Python3_VERSION_MAJOR}.${Python3_VERSION_MINOR})
2022-01-06 15:29:15 +08:00
if(ENABLE_GPU)
2020-04-13 15:30:25 +08:00
set(CPACK_MS_BACKEND "ms")
2021-03-23 20:01:58 +08:00
set(CPACK_MS_TARGET "gpu or cpu")
2021-11-06 16:56:44 +08:00
if(BUILD_DEV_MODE)
# providing cuda11 version of dev package only
set(CPACK_MS_PACKAGE_NAME "mindspore-cuda11-dev")
else()
set(CPACK_MS_PACKAGE_NAME "mindspore-gpu")
endif()
2021-01-23 20:20:31 +08:00
elseif(ENABLE_D)
2020-04-13 15:30:25 +08:00
set(CPACK_MS_BACKEND "ms")
2021-03-23 20:01:58 +08:00
set(CPACK_MS_TARGET "ascend or cpu")
2021-11-06 16:56:44 +08:00
if(BUILD_DEV_MODE)
set(CPACK_MS_PACKAGE_NAME "mindspore-ascend-dev")
else()
set(CPACK_MS_PACKAGE_NAME "mindspore-ascend")
endif()
2021-01-23 20:20:31 +08:00
elseif(ENABLE_CPU)
2020-04-13 15:30:25 +08:00
set(CPACK_MS_BACKEND "ms")
2020-09-03 10:01:39 +08:00
set(CPACK_MS_TARGET "cpu")
2021-11-06 16:56:44 +08:00
if(BUILD_DEV_MODE)
set(CPACK_MS_PACKAGE_NAME "mindspore-dev")
else()
set(CPACK_MS_PACKAGE_NAME "mindspore")
endif()
2021-01-23 20:20:31 +08:00
elseif(ENABLE_ACL)
set(CPACK_MS_BACKEND "debug")
2021-03-23 20:01:58 +08:00
set(CPACK_MS_TARGET "ascend or gpu or cpu")
2021-11-06 16:56:44 +08:00
if(BUILD_DEV_MODE)
set(CPACK_MS_PACKAGE_NAME "mindspore-ascend-dev")
else()
set(CPACK_MS_PACKAGE_NAME "mindspore-ascend")
endif()
2021-01-23 20:20:31 +08:00
else()
2020-04-13 15:30:25 +08:00
set(CPACK_MS_BACKEND "debug")
2021-03-23 20:01:58 +08:00
set(CPACK_MS_TARGET "ascend or gpu or cpu")
2021-11-06 16:56:44 +08:00
if(BUILD_DEV_MODE)
set(CPACK_MS_PACKAGE_NAME "mindspore-dev")
else()
set(CPACK_MS_PACKAGE_NAME "mindspore")
endif()
2021-01-23 20:20:31 +08:00
endif()
2020-04-13 15:30:25 +08:00
include(CPack)
# set install path
set(INSTALL_LIB_DIR ${CMAKE_INSTALL_LIBDIR} CACHE PATH "Installation directory for libraries")
set(INSTALL_PY_DIR ".")
set(INSTALL_BASE_DIR ".")
set(INSTALL_BIN_DIR "bin")
set(INSTALL_CFG_DIR "config")
set(INSTALL_LIB_DIR "lib")
2022-08-27 10:00:03 +08:00
set(INSTALL_PLUGIN_DIR "${INSTALL_LIB_DIR}/plugin")
2020-04-13 15:30:25 +08:00
# set package files
install(
TARGETS _c_expression
DESTINATION ${INSTALL_BASE_DIR}
COMPONENT mindspore
)
if(ENABLE_DEBUGGER)
install(
TARGETS _mindspore_offline_debug
DESTINATION ${INSTALL_BASE_DIR}
COMPONENT mindspore
)
endif()
install(
TARGETS mindspore_shared_lib
2021-01-26 17:06:34 +08:00
DESTINATION ${INSTALL_LIB_DIR}
COMPONENT mindspore
)
2020-08-11 12:40:23 +08:00
install(
TARGETS mindspore_core mindspore_common mindspore_backend
2020-10-15 10:53:47 +08:00
DESTINATION ${INSTALL_LIB_DIR}
COMPONENT mindspore
2020-08-11 12:40:23 +08:00
)
2022-07-21 09:28:31 +08:00
if(ENABLE_D)
install(
TARGETS mindspore_ascend
2022-08-27 10:00:03 +08:00
DESTINATION ${INSTALL_PLUGIN_DIR}
2022-07-21 09:28:31 +08:00
COMPONENT mindspore
)
endif()
if(ENABLE_GPU)
install(
TARGETS mindspore_gpu
2022-08-27 10:00:03 +08:00
DESTINATION ${INSTALL_PLUGIN_DIR}
2022-07-21 09:28:31 +08:00
COMPONENT mindspore
)
endif()
2021-01-23 20:20:31 +08:00
if(USE_GLOG)
install(FILES ${glog_LIBPATH}/libmindspore_glog.so.0.4.0
DESTINATION ${INSTALL_LIB_DIR} RENAME libmindspore_glog.so.0 COMPONENT mindspore)
2021-01-23 20:20:31 +08:00
endif()
2020-04-13 15:30:25 +08:00
2021-01-23 20:20:31 +08:00
if(ENABLE_MINDDATA)
2020-04-13 15:30:25 +08:00
install(
TARGETS _c_dataengine _c_mindrecord
DESTINATION ${INSTALL_BASE_DIR}
COMPONENT mindspore
)
2021-01-23 20:20:31 +08:00
if(CMAKE_SYSTEM_NAME MATCHES "Linux")
install(
TARGETS cache_admin cache_server
OPTIONAL
DESTINATION ${INSTALL_BIN_DIR}
COMPONENT mindspore
)
endif()
2021-12-17 10:49:07 +08:00
install(FILES ${opencv_LIBPATH}/libopencv_core.so.4.5.2
DESTINATION ${INSTALL_LIB_DIR} RENAME libopencv_core.so.4.5 COMPONENT mindspore)
install(FILES ${opencv_LIBPATH}/libopencv_imgcodecs.so.4.5.2
DESTINATION ${INSTALL_LIB_DIR} RENAME libopencv_imgcodecs.so.4.5 COMPONENT mindspore)
install(FILES ${opencv_LIBPATH}/libopencv_imgproc.so.4.5.2
DESTINATION ${INSTALL_LIB_DIR} RENAME libopencv_imgproc.so.4.5 COMPONENT mindspore)
install(FILES ${tinyxml2_LIBPATH}/libtinyxml2.so.8.0.0
DESTINATION ${INSTALL_LIB_DIR} RENAME libtinyxml2.so.8 COMPONENT mindspore)
2022-03-15 20:20:44 +08:00
install(FILES ${icu4c_LIBPATH}/libicuuc.so.69.1
DESTINATION ${INSTALL_LIB_DIR} RENAME libicuuc.so.69 COMPONENT mindspore)
install(FILES ${icu4c_LIBPATH}/libicudata.so.69.1
DESTINATION ${INSTALL_LIB_DIR} RENAME libicudata.so.69 COMPONENT mindspore)
install(FILES ${icu4c_LIBPATH}/libicui18n.so.69.1
DESTINATION ${INSTALL_LIB_DIR} RENAME libicui18n.so.69 COMPONENT mindspore)
2021-01-23 20:20:31 +08:00
endif()
2020-04-13 15:30:25 +08:00
2021-01-23 20:20:31 +08:00
if(ENABLE_CPU)
if(CMAKE_SYSTEM_NAME MATCHES "Linux")
install(FILES ${onednn_LIBPATH}/libdnnl.so.2.2
DESTINATION ${INSTALL_LIB_DIR} RENAME libdnnl.so.2 COMPONENT mindspore)
2021-01-23 20:20:31 +08:00
elseif(CMAKE_SYSTEM_NAME MATCHES "Darwin")
2020-04-13 15:30:25 +08:00
file(GLOB_RECURSE DNNL_LIB_LIST ${onednn_LIBPATH}/libdnnl*${CMAKE_SHARED_LIBRARY_SUFFIX}*)
install(
FILES ${DNNL_LIB_LIST}
DESTINATION ${INSTALL_LIB_DIR}
COMPONENT mindspore
)
2021-01-23 20:20:31 +08:00
endif()
2021-04-12 00:31:58 +08:00
install(
TARGETS nnacl
DESTINATION ${INSTALL_LIB_DIR}
COMPONENT mindspore
)
2021-01-23 20:20:31 +08:00
endif()
2020-04-13 15:30:25 +08:00
2021-01-23 20:20:31 +08:00
if(ENABLE_MPI)
if(ENABLE_GPU)
2020-08-05 22:07:45 +08:00
install(
TARGETS _ms_mpi
DESTINATION ${INSTALL_BASE_DIR}
COMPONENT mindspore
)
2021-01-23 20:20:31 +08:00
endif()
if(ENABLE_CPU)
2020-08-05 22:07:45 +08:00
install(
TARGETS mpi_adapter
DESTINATION ${INSTALL_LIB_DIR}
COMPONENT mindspore
)
2021-11-09 09:41:49 +08:00
install(
TARGETS mpi_collective
DESTINATION ${INSTALL_LIB_DIR}
COMPONENT mindspore
)
2021-01-23 20:20:31 +08:00
endif()
2021-08-25 14:45:58 +08:00
if(ENABLE_D)
install(
TARGETS _ascend_mpi
DESTINATION ${INSTALL_BASE_DIR}
COMPONENT mindspore
)
endif()
2021-01-23 20:20:31 +08:00
endif()
2021-01-23 20:20:31 +08:00
if(ENABLE_GPU)
if(ENABLE_MPI)
2020-04-16 09:22:47 +08:00
install(
TARGETS gpu_collective
DESTINATION ${INSTALL_LIB_DIR}
COMPONENT mindspore
)
2021-11-09 09:41:49 +08:00
install(
TARGETS nvidia_collective
DESTINATION ${INSTALL_LIB_DIR}
COMPONENT mindspore
)
2022-10-06 19:53:06 +08:00
if(CMAKE_SYSTEM_NAME MATCHES "Linux" AND GPU_BACKEND_CUDA)
2022-01-28 17:24:43 +08:00
install(FILES ${nccl_LIBPATH}/libnccl.so.2.7.6 DESTINATION ${INSTALL_LIB_DIR}
RENAME libnccl.so.2 COMPONENT mindspore)
endif()
2021-01-23 20:20:31 +08:00
endif()
install(
TARGETS cuda_ops
DESTINATION ${INSTALL_LIB_DIR}
COMPONENT mindspore
)
2021-01-23 20:20:31 +08:00
endif()
2020-04-13 15:30:25 +08:00
2021-08-25 14:45:58 +08:00
if(ENABLE_D)
if(ENABLE_MPI)
install(
TARGETS ascend_collective
DESTINATION ${INSTALL_LIB_DIR}
COMPONENT mindspore
)
endif()
endif()
2021-04-26 14:36:19 +08:00
if(ENABLE_CPU AND NOT WIN32)
2020-11-04 15:36:39 +08:00
install(
TARGETS ps_cache
DESTINATION ${INSTALL_LIB_DIR}
COMPONENT mindspore
)
endif()
2022-01-06 15:29:15 +08:00
if(ENABLE_D OR ENABLE_ACL)
if(DEFINED ENV{ASCEND_CUSTOM_PATH})
set(ASCEND_PATH $ENV{ASCEND_CUSTOM_PATH})
else()
set(ASCEND_PATH /usr/local/Ascend)
endif()
set(ASCEND_DRIVER_PATH ${ASCEND_PATH}/driver/lib64/common)
2020-04-13 15:30:25 +08:00
2022-01-06 15:29:15 +08:00
if(ENABLE_D)
2020-04-13 15:30:25 +08:00
install(
2022-01-06 15:29:15 +08:00
TARGETS hccl_plugin
DESTINATION ${INSTALL_LIB_DIR}
COMPONENT mindspore
2020-04-13 15:30:25 +08:00
)
2021-01-23 20:20:31 +08:00
endif()
if(ENABLE_ACL)
install(
TARGETS dvpp_utils
DESTINATION ${INSTALL_LIB_DIR}
COMPONENT mindspore
)
endif()
2021-01-23 20:20:31 +08:00
endif()
2020-04-13 15:30:25 +08:00
if(MS_BUILD_GRPC)
install(FILES ${grpc_LIBPATH}/libmindspore_grpc++.so.1.36.1
DESTINATION ${INSTALL_LIB_DIR} RENAME libmindspore_grpc++.so.1 COMPONENT mindspore)
install(FILES ${grpc_LIBPATH}/libmindspore_grpc.so.15.0.0
DESTINATION ${INSTALL_LIB_DIR} RENAME libmindspore_grpc.so.15 COMPONENT mindspore)
install(FILES ${grpc_LIBPATH}/libmindspore_gpr.so.15.0.0
DESTINATION ${INSTALL_LIB_DIR} RENAME libmindspore_gpr.so.15 COMPONENT mindspore)
install(FILES ${grpc_LIBPATH}/libmindspore_upb.so.15.0.0
DESTINATION ${INSTALL_LIB_DIR} RENAME libmindspore_upb.so.15 COMPONENT mindspore)
install(FILES ${grpc_LIBPATH}/libmindspore_address_sorting.so.15.0.0
DESTINATION ${INSTALL_LIB_DIR} RENAME libmindspore_address_sorting.so.15 COMPONENT mindspore)
endif()
2021-01-23 20:20:31 +08:00
if(CMAKE_SYSTEM_NAME MATCHES "Windows")
get_filename_component(CXX_DIR ${CMAKE_CXX_COMPILER} PATH)
file(GLOB CXX_LIB_LIST ${CXX_DIR}/*.dll)
string(REPLACE "\\" "/" SystemRoot $ENV{SystemRoot})
file(GLOB VC_LIB_LIST ${SystemRoot}/System32/msvcp140.dll ${SystemRoot}/System32/vcomp140.dll)
file(GLOB JPEG_LIB_LIST ${jpeg_turbo_LIBPATH}/*.dll)
file(GLOB SQLITE_LIB_LIST ${sqlite_LIBPATH}/*.dll)
install(
2020-04-23 11:11:54 +08:00
FILES ${CXX_LIB_LIST} ${JPEG_LIB_LIST} ${SQLITE_LIB_LIST} ${VC_LIB_LIST}
DESTINATION ${INSTALL_LIB_DIR}
COMPONENT mindspore
)
2021-01-23 20:20:31 +08:00
endif()
2020-04-13 15:30:25 +08:00
# set python files
2021-12-15 10:33:16 +08:00
file(GLOB MS_PY_LIST ${CMAKE_SOURCE_DIR}/mindspore/python/mindspore/*.py)
2020-04-13 15:30:25 +08:00
install(
FILES ${MS_PY_LIST}
DESTINATION ${INSTALL_PY_DIR}
COMPONENT mindspore
)
install(
DIRECTORY
2021-12-15 10:33:16 +08:00
${CMAKE_SOURCE_DIR}/mindspore/python/mindspore/nn
${CMAKE_SOURCE_DIR}/mindspore/python/mindspore/_extends
${CMAKE_SOURCE_DIR}/mindspore/python/mindspore/parallel
${CMAKE_SOURCE_DIR}/mindspore/python/mindspore/mindrecord
${CMAKE_SOURCE_DIR}/mindspore/python/mindspore/numpy
${CMAKE_SOURCE_DIR}/mindspore/python/mindspore/scipy
${CMAKE_SOURCE_DIR}/mindspore/python/mindspore/train
${CMAKE_SOURCE_DIR}/mindspore/python/mindspore/boost
${CMAKE_SOURCE_DIR}/mindspore/python/mindspore/common
${CMAKE_SOURCE_DIR}/mindspore/python/mindspore/ops
${CMAKE_SOURCE_DIR}/mindspore/python/mindspore/communication
${CMAKE_SOURCE_DIR}/mindspore/python/mindspore/profiler
${CMAKE_SOURCE_DIR}/mindspore/python/mindspore/compression
2022-03-08 14:12:51 +08:00
${CMAKE_SOURCE_DIR}/mindspore/python/mindspore/rewrite
2021-12-15 10:33:16 +08:00
${CMAKE_SOURCE_DIR}/mindspore/python/mindspore/run_check
2022-09-16 11:08:56 +08:00
${CMAKE_SOURCE_DIR}/mindspore/python/mindspore/experimental
2020-04-13 15:30:25 +08:00
DESTINATION ${INSTALL_PY_DIR}
COMPONENT mindspore
)
if(ENABLE_AKG AND CMAKE_SYSTEM_NAME MATCHES "Linux")
set (AKG_PATH ${BUILD_PATH}/mindspore/akg)
2021-03-15 11:43:54 +08:00
file(REMOVE_RECURSE ${AKG_PATH}/_akg)
file(MAKE_DIRECTORY ${AKG_PATH}/_akg)
file(TOUCH ${AKG_PATH}/_akg/__init__.py)
install(DIRECTORY "${AKG_PATH}/akg" DESTINATION "${AKG_PATH}/_akg")
install(
DIRECTORY
2021-03-15 11:43:54 +08:00
${AKG_PATH}/_akg
DESTINATION ${INSTALL_PY_DIR}/
COMPONENT mindspore
)
2021-01-23 20:20:31 +08:00
endif()
2021-12-15 10:33:16 +08:00
if(EXISTS ${CMAKE_SOURCE_DIR}/mindspore/python/mindspore/dataset)
2020-04-13 15:30:25 +08:00
install(
2021-12-15 10:33:16 +08:00
DIRECTORY ${CMAKE_SOURCE_DIR}/mindspore/python/mindspore/dataset
2020-04-13 15:30:25 +08:00
DESTINATION ${INSTALL_PY_DIR}
COMPONENT mindspore
)
2021-01-23 20:20:31 +08:00
endif()
if(CMAKE_SYSTEM_NAME MATCHES "Windows")
message("offline debugger does not support windows system temporarily")
else()
2021-12-15 10:33:16 +08:00
if(EXISTS ${CMAKE_SOURCE_DIR}/mindspore/python/mindspore/offline_debug)
install(
2021-12-15 10:33:16 +08:00
DIRECTORY ${CMAKE_SOURCE_DIR}/mindspore/python/mindspore/offline_debug
DESTINATION ${INSTALL_PY_DIR}
COMPONENT mindspore
)
endif()
endif()
## Public header files
install(
DIRECTORY ${CMAKE_SOURCE_DIR}/include
DESTINATION ${INSTALL_BASE_DIR}
COMPONENT mindspore
)
2020-12-12 15:18:45 +08:00
## Public header files for minddata
install(
2021-05-10 11:12:00 +08:00
FILES ${CMAKE_SOURCE_DIR}/mindspore/ccsrc/minddata/dataset/include/dataset/config.h
${CMAKE_SOURCE_DIR}/mindspore/ccsrc/minddata/dataset/include/dataset/constants.h
${CMAKE_SOURCE_DIR}/mindspore/ccsrc/minddata/dataset/include/dataset/execute.h
${CMAKE_SOURCE_DIR}/mindspore/ccsrc/minddata/dataset/include/dataset/text.h
2021-04-17 15:44:57 +08:00
${CMAKE_SOURCE_DIR}/mindspore/ccsrc/minddata/dataset/include/dataset/transforms.h
${CMAKE_SOURCE_DIR}/mindspore/ccsrc/minddata/dataset/include/dataset/vision.h
${CMAKE_SOURCE_DIR}/mindspore/ccsrc/minddata/dataset/include/dataset/vision_lite.h
${CMAKE_SOURCE_DIR}/mindspore/ccsrc/minddata/dataset/include/dataset/vision_ascend.h
DESTINATION ${INSTALL_BASE_DIR}/include/dataset
2020-12-12 15:18:45 +08:00
COMPONENT mindspore
)
install(
FILES
${CMAKE_SOURCE_DIR}/mindspore/core/mindapi/base/format.h
${CMAKE_SOURCE_DIR}/mindspore/core/mindapi/base/type_id.h
${CMAKE_SOURCE_DIR}/mindspore/core/mindapi/base/types.h
DESTINATION ${INSTALL_BASE_DIR}/include/mindapi/base
COMPONENT mindspore)
## config files
install(
FILES ${CMAKE_SOURCE_DIR}/config/op_info.config
DESTINATION ${INSTALL_CFG_DIR}
COMPONENT mindspore
)