package.cmake 8.3 KB
Newer Older
Z
zhoufeng 已提交
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34
# include dependency
include(CMakePackageConfigHelpers)
include(GNUInstallDirs)

# set package information
set(CPACK_PACKAGE_NAME ${PROJECT_NAME})
set(CPACK_GENERATOR "External")
set(CPACK_EXTERNAL_PACKAGE_SCRIPT ${CMAKE_SOURCE_DIR}/cmake/package_script.cmake)
set(CPACK_EXTERNAL_ENABLE_STAGING true)
set(CPACK_TEMPORARY_PACKAGE_FILE_NAME ${CMAKE_SOURCE_DIR}/build/package/mindspore)
set(CPACK_TEMPORARY_INSTALL_DIRECTORY ${CMAKE_SOURCE_DIR}/build/package/mindspore)
if (ENABLE_GE)
    set(CPACK_MS_BACKEND "ge")
    set(CPACK_MS_PACKAGE_NAME "mindspore")
elseif (ENABLE_GPU)
    set(CPACK_MS_BACKEND "ms")
    set(CPACK_MS_PACKAGE_NAME "mindspore-gpu")
elseif (ENABLE_D)
    set(CPACK_MS_BACKEND "ms")
    set(CPACK_MS_PACKAGE_NAME "mindspore-ascend")
elseif (ENABLE_CPU)
    set(CPACK_MS_BACKEND "ms")
    set(CPACK_MS_PACKAGE_NAME "mindspore")
else ()
    set(CPACK_MS_BACKEND "debug")
    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 ".")

35 36 37 38 39 40
if (CMAKE_SYSTEM_NAME MATCHES "Windows")
    set(INSTALL_LIB_DIR ".")
    set(onednn_LIBPATH ${onednn_LIBPATH}/../bin/)
    set(glog_LIBPATH ${glog_LIBPATH}/../bin/)
    set(opencv_LIBPATH ${opencv_LIBPATH}/../bin/)
    set(jpeg_turbo_LIBPATH ${jpeg_turbo_LIBPATH}/../bin/)
Z
zhoufeng 已提交
41
    set(sqlite_LIBPATH ${sqlite_LIBPATH}/../bin/)
X
xiefangqi 已提交
42
    set(tinyxml2_LIBPATH ${tinyxml2_LIBPATH}/../bin/)
X
xulei2020 已提交
43
    set(sentencepiece_LIBPATH ${sentencepiece_LIBPATH}/../bin/)
44 45 46 47
else ()
    set(INSTALL_LIB_DIR "lib")
endif ()

Z
zhoufeng 已提交
48 49 50 51 52 53 54
# set package files
install(
    TARGETS _c_expression
    DESTINATION ${INSTALL_BASE_DIR}
    COMPONENT mindspore
)

L
liubuyu 已提交
55 56 57 58 59 60
install(
        TARGETS mindspore_gvar
        DESTINATION ${INSTALL_LIB_DIR}
        COMPONENT mindspore
)

Z
zhoufeng 已提交
61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86
if (USE_GLOG)
    file(GLOB_RECURSE GLOG_LIB_LIST ${glog_LIBPATH}/libglog*)
    install(
        FILES ${GLOG_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
    )
X
xiefangqi 已提交
87 88 89 90 91 92 93 94
    file(GLOB_RECURSE TINYXML2_LIB_LIST
	    ${tinyxml2_LIBPATH}/libtinyxml2*
    )
    install(
	FILES ${TINYXML2_LIB_LIST}
        DESTINATION ${INSTALL_LIB_DIR}
        COMPONENT mindspore
    )
X
xulei2020 已提交
95 96 97 98 99 100 101 102
    file(GLOB_RECURSE SENTENCEPIECE_LIB_LIST
        ${sentencepiece_LIBPATH}/libsentencepiece*
    )
    install(
    FILES ${SENTENCEPIECE_LIB_LIST}
        DESTINATION ${INSTALL_LIB_DIR}
        COMPONENT mindspore
    )
103 104 105 106 107 108 109 110 111 112 113 114 115 116
    if (CMAKE_SYSTEM_NAME MATCHES "Windows")
        message("icu4c does not support windows system temporarily")
    else()
        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()
Z
zhoufeng 已提交
117 118 119 120 121 122 123 124
endif ()

if (ENABLE_CPU)
    if (CMAKE_SYSTEM_NAME MATCHES "Linux")
        file(GLOB_RECURSE DNNL_LIB_LIST ${onednn_LIBPATH}/libdnnl${CMAKE_SHARED_LIBRARY_SUFFIX}*)
    elseif (CMAKE_SYSTEM_NAME MATCHES "Darwin")
        file(GLOB_RECURSE DNNL_LIB_LIST ${onednn_LIBPATH}/libdnnl*${CMAKE_SHARED_LIBRARY_SUFFIX}*)
    elseif (CMAKE_SYSTEM_NAME MATCHES "Windows")
125
        file(GLOB_RECURSE DNNL_LIB_LIST ${onednn_LIBPATH}/dnnl.dll)
Z
zhoufeng 已提交
126 127 128 129 130 131 132 133
    endif ()
    install(
        FILES ${DNNL_LIB_LIST}
        DESTINATION ${INSTALL_LIB_DIR}
        COMPONENT mindspore
    )
endif ()

134
if (ENABLE_MPI)
K
kswang 已提交
135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151
    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 ()
    file(GLOB_RECURSE MPI_LIB_LIST
        ${ompi_LIBPATH}/libmpi${CMAKE_SHARED_LIBRARY_SUFFIX}*
        ${ompi_LIBPATH}/libopen*${CMAKE_SHARED_LIBRARY_SUFFIX}*
152
    )
153
    install(
K
kswang 已提交
154
        FILES ${MPI_LIB_LIST}
155 156 157
        DESTINATION ${INSTALL_LIB_DIR}
        COMPONENT mindspore
    )
158 159
endif ()

Z
zhoufeng 已提交
160
if (ENABLE_GPU)
K
kswang 已提交
161
    if (ENABLE_MPI)
Z
zhoufeng 已提交
162 163 164 165 166
        install(
            TARGETS gpu_collective
            DESTINATION ${INSTALL_LIB_DIR}
            COMPONENT mindspore
        )
K
kswang 已提交
167
    endif ()
Z
zhoufeng 已提交
168 169 170 171 172
    install(
        TARGETS gpu_queue
        DESTINATION ${INSTALL_LIB_DIR}
        COMPONENT mindspore
    )
Z
zhoufeng 已提交
173 174 175 176 177 178 179 180 181 182
endif ()

if (NOT ENABLE_GE)
    if (ENABLE_D)
        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)
183
        set(ASCEND_FWK_PATH ${ASCEND_PATH}/fwkacllib/lib64)
Z
zhoufeng 已提交
184 185 186 187 188 189 190 191

        install(
            FILES
                ${CMAKE_BINARY_DIR}/graphengine/src/common/graph/libgraph.so
                ${CMAKE_BINARY_DIR}/graphengine/src/ge/common/libge_common.so
                ${CMAKE_BINARY_DIR}/graphengine/src/ge/ge_runtime/libge_runtime.so
                ${ASCEND_DRIVER_PATH}/libslog.so
                ${ASCEND_DRIVER_PATH}/libc_sec.so
192
                ${ASCEND_FWK_PATH}/liberror_manager.so
Z
zhoufeng 已提交
193 194 195 196 197 198 199 200
            DESTINATION ${INSTALL_LIB_DIR}
            COMPONENT mindspore
        )
    elseif (ENABLE_TESTCASES)
        install(
            FILES
                ${CMAKE_BINARY_DIR}/graphengine/src/common/graph/libgraph.so
                ${CMAKE_SOURCE_DIR}/graphengine/third_party/prebuild/${CMAKE_HOST_SYSTEM_PROCESSOR}/libslog.so
201
                ${CMAKE_SOURCE_DIR}/graphengine/third_party/prebuild/${CMAKE_HOST_SYSTEM_PROCESSOR}/liberror_manager.so
C
caifubi 已提交
202
                ${CMAKE_SOURCE_DIR}/build/graphengine/libc_sec.so
Z
zhoufeng 已提交
203 204 205 206 207 208
            DESTINATION ${INSTALL_LIB_DIR}
            COMPONENT mindspore
        )
    endif ()
endif ()

209 210 211
if (CMAKE_SYSTEM_NAME MATCHES "Windows")
    get_filename_component(CXX_DIR ${CMAKE_CXX_COMPILER} PATH)
    file(GLOB CXX_LIB_LIST ${CXX_DIR}/*.dll)
212 213 214 215

    string(REPLACE "\\" "/" SystemRoot $ENV{SystemRoot})
    file(GLOB VC_LIB_LIST ${SystemRoot}/System32/msvcp140.dll ${SystemRoot}/System32/vcomp140.dll)

216 217 218
    file(GLOB JPEG_LIB_LIST ${jpeg_turbo_LIBPATH}/*.dll)
    file(GLOB SQLITE_LIB_LIST ${sqlite_LIBPATH}/*.dll)
    install(
Z
zhoufeng 已提交
219
        FILES ${CXX_LIB_LIST} ${JPEG_LIB_LIST} ${SQLITE_LIB_LIST} ${VC_LIB_LIST}
220 221 222 223 224
        DESTINATION ${INSTALL_LIB_DIR}
        COMPONENT mindspore
    )
endif ()

Z
zhoufeng 已提交
225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242
# set python files
file(GLOB MS_PY_LIST ${CMAKE_SOURCE_DIR}/mindspore/*.py)
install(
    FILES ${MS_PY_LIST}
    DESTINATION ${INSTALL_PY_DIR}
    COMPONENT mindspore
)

install(
    DIRECTORY
        ${CMAKE_SOURCE_DIR}/mindspore/nn
        ${CMAKE_SOURCE_DIR}/mindspore/_extends
        ${CMAKE_SOURCE_DIR}/mindspore/parallel
        ${CMAKE_SOURCE_DIR}/mindspore/mindrecord
        ${CMAKE_SOURCE_DIR}/mindspore/train
        ${CMAKE_SOURCE_DIR}/mindspore/common
        ${CMAKE_SOURCE_DIR}/mindspore/ops
        ${CMAKE_SOURCE_DIR}/mindspore/communication
Y
yuximiao 已提交
243
        ${CMAKE_SOURCE_DIR}/mindspore/profiler
Z
zhoufeng 已提交
244 245 246 247
    DESTINATION ${INSTALL_PY_DIR}
    COMPONENT mindspore
)

L
lingyunli63 已提交
248
if ((ENABLE_D OR ENABLE_GPU) AND ENABLE_AKG)
G
gong chen 已提交
249 250 251 252 253 254 255 256 257
    set (AKG_PATH ${CMAKE_SOURCE_DIR}/build/mindspore/akg)
    install(
        DIRECTORY
            ${AKG_PATH}/akg
        DESTINATION ${INSTALL_PY_DIR}/..
        COMPONENT mindspore
    )
endif ()

Z
zhoufeng 已提交
258 259 260 261 262 263 264
if (EXISTS ${CMAKE_SOURCE_DIR}/mindspore/dataset)
    install(
        DIRECTORY ${CMAKE_SOURCE_DIR}/mindspore/dataset
        DESTINATION ${INSTALL_PY_DIR}
        COMPONENT mindspore
    )
endif ()
265 266 267 268 269 270 271 272

if (ENABLE_SERVING)
    install(
        TARGETS ms_serving
        DESTINATION ${INSTALL_BASE_DIR}
        COMPONENT mindspore
    )

H
hexia 已提交
273
    install(
H
hexia 已提交
274 275
        FILES ${CMAKE_SOURCE_DIR}/build/mindspore/serving/ms_service_pb2.py
              ${CMAKE_SOURCE_DIR}/build/mindspore/serving/ms_service_pb2_grpc.py
H
hexia 已提交
276 277 278 279
        DESTINATION ${INSTALL_PY_DIR}
        COMPONENT mindspore
    )

280 281 282 283 284 285
    install(
        TARGETS inference
        DESTINATION ${INSTALL_LIB_DIR}
        COMPONENT mindspore
    )
endif ()