mindspore/cmake/package_mac.cmake

281 lines
8.0 KiB
CMake
Raw Normal View History

2021-10-25 16:59:19 +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")
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})
2021-11-30 19:10:40 +08:00
set(CPACK_OSX_DEPLOYMENT_TARGET ${CMAKE_OSX_DEPLOYMENT_TARGET})
2021-10-25 16:59:19 +08:00
if(ENABLE_GPU)
set(CPACK_MS_BACKEND "ms")
set(CPACK_MS_TARGET "gpu or cpu")
set(CPACK_MS_PACKAGE_NAME "mindspore-gpu")
elseif(ENABLE_CPU)
set(CPACK_MS_BACKEND "ms")
set(CPACK_MS_TARGET "cpu")
set(CPACK_MS_PACKAGE_NAME "mindspore")
else()
set(CPACK_MS_BACKEND "debug")
set(CPACK_MS_TARGET "ascend or gpu or cpu")
set(CPACK_MS_PACKAGE_NAME "mindspore")
endif()
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")
# 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()
2021-10-25 16:59:19 +08:00
install(
TARGETS mindspore_shared_lib
DESTINATION ${INSTALL_LIB_DIR}
COMPONENT mindspore
)
install(
TARGETS mindspore_gvar
DESTINATION ${INSTALL_LIB_DIR}
COMPONENT mindspore
)
if(USE_GLOG)
file(GLOB_RECURSE GLOG_LIB_LIST ${glog_LIBPATH}/libmindspore_glog*)
install(
FILES ${GLOG_LIB_LIST}
DESTINATION ${INSTALL_LIB_DIR}
COMPONENT mindspore
)
endif()
install(FILES ${libevent_LIBPATH}/libevent-2.1.7.dylib
DESTINATION ${INSTALL_LIB_DIR} COMPONENT mindspore)
install(FILES ${libevent_LIBPATH}/libevent_core-2.1.7.dylib
DESTINATION ${INSTALL_LIB_DIR} COMPONENT mindspore)
install(FILES ${libevent_LIBPATH}/libevent_extra-2.1.7.dylib
DESTINATION ${INSTALL_LIB_DIR} COMPONENT mindspore)
install(FILES ${libevent_LIBPATH}/libevent_openssl-2.1.7.dylib
DESTINATION ${INSTALL_LIB_DIR} COMPONENT mindspore)
install(FILES ${libevent_LIBPATH}/libevent_pthreads-2.1.7.dylib
DESTINATION ${INSTALL_LIB_DIR} COMPONENT mindspore)
if(ENABLE_CPU AND NOT WIN32)
install(
TARGETS ps_cache
DESTINATION ${INSTALL_LIB_DIR}
COMPONENT mindspore
)
endif()
2021-10-25 16:59:19 +08:00
if(MS_BUILD_GRPC)
file(GLOB_RECURSE GRPC_LIB_LIST
${grpc_LIBPATH}/libmindspore*
)
install(
FILES ${GRPC_LIB_LIST}
DESTINATION ${INSTALL_LIB_DIR}
COMPONENT mindspore
)
endif()
if(ENABLE_MINDDATA)
install(
TARGETS _c_dataengine _c_mindrecord
DESTINATION ${INSTALL_BASE_DIR}
COMPONENT mindspore
)
file(GLOB_RECURSE OPENCV_LIB_LIST
${opencv_LIBPATH}/libopencv_core*
${opencv_LIBPATH}/libopencv_imgcodecs*
${opencv_LIBPATH}/libopencv_imgproc*
)
install(
FILES ${OPENCV_LIB_LIST}
DESTINATION ${INSTALL_LIB_DIR}
COMPONENT mindspore
)
file(GLOB_RECURSE JPEG_LIB_LIST
${jpeg_turbo_LIBPATH}/*.dylib
)
install(
FILES ${JPEG_LIB_LIST}
DESTINATION ${INSTALL_LIB_DIR}
COMPONENT mindspore
)
file(GLOB_RECURSE TINYXML2_LIB_LIST ${tinyxml2_LIBPATH}/libtinyxml2*)
install(
FILES ${TINYXML2_LIB_LIST}
DESTINATION ${INSTALL_LIB_DIR}
COMPONENT mindspore
)
file(GLOB_RECURSE ICU4C_LIB_LIST
${icu4c_LIBPATH}/libicuuc*
${icu4c_LIBPATH}/libicudata*
${icu4c_LIBPATH}/libicui18n*
)
install(
FILES ${ICU4C_LIB_LIST}
DESTINATION ${INSTALL_LIB_DIR}
COMPONENT mindspore
)
endif()
if(ENABLE_CPU)
file(GLOB_RECURSE DNNL_LIB_LIST ${onednn_LIBPATH}/libdnnl*)
install(
FILES ${DNNL_LIB_LIST}
DESTINATION ${INSTALL_LIB_DIR}
COMPONENT mindspore
)
install(
TARGETS nnacl
DESTINATION ${INSTALL_LIB_DIR}
COMPONENT mindspore
)
endif()
if(ENABLE_MPI)
if(ENABLE_GPU)
install(
TARGETS _ms_mpi
DESTINATION ${INSTALL_BASE_DIR}
COMPONENT mindspore
)
endif()
if(ENABLE_CPU)
install(
TARGETS mpi_adapter
DESTINATION ${INSTALL_LIB_DIR}
COMPONENT mindspore
)
endif()
endif()
if(ENABLE_GPU)
if(ENABLE_MPI)
install(
TARGETS gpu_collective
DESTINATION ${INSTALL_LIB_DIR}
COMPONENT mindspore
)
endif()
install(
TARGETS gpu_queue
DESTINATION ${INSTALL_LIB_DIR}
COMPONENT mindspore
)
endif()
get_filename_component(CXX_DIR ${CMAKE_CXX_COMPILER} PATH)
file(GLOB CXX_LIB_LIST ${CXX_DIR}/*.dylib)
file(GLOB JPEG_LIB_LIST ${jpeg_turbo_LIBPATH}/*.dylib)
file(GLOB SQLITE_LIB_LIST ${sqlite_LIBPATH}/*.dylib)
install(
FILES ${CXX_LIB_LIST} ${SQLITE_LIB_LIST}
DESTINATION ${INSTALL_LIB_DIR}
COMPONENT mindspore
)
# set python files
2021-12-15 10:33:16 +08:00
file(GLOB MS_PY_LIST ${CMAKE_SOURCE_DIR}/mindspore/python/mindspore/*.py)
2021-10-25 16:59:19 +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
${CMAKE_SOURCE_DIR}/mindspore/python/mindspore/run_check
2021-10-25 16:59:19 +08:00
DESTINATION ${INSTALL_PY_DIR}
COMPONENT mindspore
)
2021-12-15 10:33:16 +08:00
if(EXISTS ${CMAKE_SOURCE_DIR}/mindspore/python/mindspore/dataset)
2021-10-25 16:59:19 +08:00
install(
2021-12-15 10:33:16 +08:00
DIRECTORY ${CMAKE_SOURCE_DIR}/mindspore/python/mindspore/dataset
2021-10-25 16:59:19 +08:00
DESTINATION ${INSTALL_PY_DIR}
COMPONENT mindspore
)
endif()
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()
2021-10-25 16:59:19 +08:00
## Public header files
install(
DIRECTORY ${CMAKE_SOURCE_DIR}/include
DESTINATION ${INSTALL_BASE_DIR}
COMPONENT mindspore
)
## Public header files for minddata
install(
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
${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
COMPONENT mindspore
)
## config files
install(
FILES ${CMAKE_SOURCE_DIR}/config/op_info.config
DESTINATION ${INSTALL_CFG_DIR}
COMPONENT mindspore
)