dgc.cmake 1.9 KB
Newer Older
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16
# Copyright (c) 2016 PaddlePaddle Authors. All Rights Reserved.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.

INCLUDE(ExternalProject)

W
WangXi 已提交
17 18
SET(DGC_PREFIX_DIR  "${THIRD_PARTY_PATH}/dgc")
SET(DGC_SOURCES_DIR "${THIRD_PARTY_PATH}/dgc/src/extern_dgc")
19 20
SET(DGC_INSTALL_DIR "${THIRD_PARTY_PATH}/install/dgc")
SET(DGC_INCLUDE_DIR "${DGC_INSTALL_DIR}/include" CACHE PATH "dgc include directory." FORCE)
21
SET(DGC_LIBRARIES   "${DGC_INSTALL_DIR}/lib/libdgc.a" CACHE FILEPATH "dgc library." FORCE)
22
SET(DGC_URL         "https://fleet.bj.bcebos.com/dgc/collective_f66ef73.tgz")
23 24
INCLUDE_DIRECTORIES(${DGC_INCLUDE_DIR})

W
WangXi 已提交
25 26 27 28
cache_third_party(extern_dgc
        URL       ${DGC_URL}
        DIR       DGC_SOURCES_DIR)

29 30 31
ExternalProject_Add(
    extern_dgc
    ${EXTERNAL_PROJECT_LOG_ARGS}
W
WangXi 已提交
32
    "${DGC_DOWNLOAD_CMD}"
33
    URL_MD5         "94e6fa1bc97169d0e1aad44570fe3251"
W
WangXi 已提交
34
    PREFIX          "${DGC_PREFIX_DIR}"
35
    SOURCE_DIR      "${DGC_SOURCES_DIR}"
36
    CONFIGURE_COMMAND ""
37
    BUILD_COMMAND make -j $(nproc)
38
    INSTALL_COMMAND mkdir -p ${DGC_INSTALL_DIR}/lib/  ${DGC_INCLUDE_DIR}/dgc
39 40
        && cp ${DGC_SOURCES_DIR}/build/lib/libdgc.a ${DGC_LIBRARIES}
        && cp ${DGC_SOURCES_DIR}/build/include/dgc.h ${DGC_INCLUDE_DIR}/dgc/
41
    BUILD_IN_SOURCE 1
42
    BUILD_BYPRODUCTS ${DGC_LIBRARIES}
43 44
)

45
ADD_LIBRARY(dgc STATIC IMPORTED GLOBAL)
46 47 48
SET_PROPERTY(TARGET dgc PROPERTY IMPORTED_LOCATION ${DGC_LIBRARIES})
ADD_DEPENDENCIES(dgc extern_dgc)