From afce32f32c153ccb77575992ec7a7daa3d06c943 Mon Sep 17 00:00:00 2001 From: lilong12 Date: Fri, 16 Oct 2020 10:17:52 +0800 Subject: [PATCH] build gloo from source code instead of using the pre-compiled library (#27930) * build gloo from source code , test=develop --- cmake/external/gloo.cmake | 73 ++++++++++++++++----------------------- 1 file changed, 29 insertions(+), 44 deletions(-) diff --git a/cmake/external/gloo.cmake b/cmake/external/gloo.cmake index 895bc0849a2..2d5207ed657 100644 --- a/cmake/external/gloo.cmake +++ b/cmake/external/gloo.cmake @@ -14,55 +14,40 @@ INCLUDE(ExternalProject) -execute_process(COMMAND bash -c "gcc -dumpversion" OUTPUT_VARIABLE GCC_VERSION) - SET(GLOO_PROJECT "extern_gloo") -IF((NOT DEFINED GLOO_VER) OR (NOT DEFINED GLOO_URL)) - MESSAGE(STATUS "use pre defined download url") - SET(GLOO_VER "master" CACHE STRING "" FORCE) - SET(GLOO_NAME "gloo" CACHE STRING "" FORCE) - - if(${GCC_VERSION} VERSION_EQUAL "8.2.0") - SET(GLOO_URL "https://fleet.bj.bcebos.com/gloo/gloo.tar.gz.gcc8" CACHE STRING "" FORCE) - else() - SET(GLOO_URL "https://fleet.bj.bcebos.com/gloo/gloo.tar.gz.gcc482" CACHE STRING "" FORCE) - endif() -ENDIF() - -MESSAGE(STATUS "GLOO_NAME: ${GLOO_NAME}, GLOO_URL: ${GLOO_URL}") -SET(GLOO_SOURCE_DIR "${THIRD_PARTY_PATH}/gloo") -SET(GLOO_DOWNLOAD_DIR "${GLOO_SOURCE_DIR}/src/${GLOO_PROJECT}") -SET(GLOO_DST_DIR "gloo") -SET(GLOO_INSTALL_ROOT "${THIRD_PARTY_PATH}/install") -SET(GLOO_INSTALL_DIR ${GLOO_INSTALL_ROOT}/${GLOO_DST_DIR}) -SET(GLOO_ROOT ${GLOO_INSTALL_DIR}) -SET(GLOO_INC_DIR ${GLOO_ROOT}/include) -SET(GLOO_LIB_DIR ${GLOO_ROOT}/lib) -SET(GLOO_LIB ${GLOO_LIB_DIR}/libgloo.a) -#SET(GLOO_IOMP_LIB ${GLOO_LIB_DIR}/libiomp5.so) #todo what is this -SET(CMAKE_INSTALL_RPATH "${CMAKE_INSTALL_RPATH}" "${GLOO_ROOT}/lib") - -INCLUDE_DIRECTORIES(${GLOO_INC_DIR}) - -FILE(WRITE ${GLOO_DOWNLOAD_DIR}/CMakeLists.txt - "PROJECT(GLOO)\n" - "cmake_minimum_required(VERSION 3.0)\n" - "install(DIRECTORY ${GLOO_NAME}/include ${GLOO_NAME}/lib \n" - " DESTINATION ${GLOO_DST_DIR})\n") +SET(GLOO_PREFIX_DIR ${THIRD_PARTY_PATH}/gloo) +SET(GLOO_SOURCE_DIR ${THIRD_PARTY_PATH}/gloo/src/extern_gloo/gloo) +SET(GLOO_INSTALL_DIR ${THIRD_PARTY_PATH}/install/gloo) +SET(GLOO_INCLUDE_DIR "${GLOO_INSTALL_DIR}/include" CACHE PATH "gloo include directory." FORCE) +SET(GLOO_LIBRARY_DIR "${GLOO_INSTALL_DIR}/lib" CACHE PATH "gloo library directory." FORCE) +SET(GLOO_REPOSITORY https://github.com/sandyhouse/gloo.git) +SET(GLOO_TAG v0.0.2) +SET(GLOO_LIBRARIES "${GLOO_INSTALL_DIR}/lib/libgloo.a" CACHE FILEPATH "gloo library." FORCE) + +INCLUDE_DIRECTORIES(${GLOO_INCLUDE_DIR}) + +cache_third_party(extern_gloo + REPOSITORY ${GLOO_REPOSITORY} + TAG ${GLOO_TAG} + DIR GLOO_SOURCE_DIR) ExternalProject_Add( - ${GLOO_PROJECT} + extern_gloo ${EXTERNAL_PROJECT_LOG_ARGS} - PREFIX ${GLOO_SOURCE_DIR} - DOWNLOAD_DIR ${GLOO_DOWNLOAD_DIR} - DOWNLOAD_COMMAND wget --no-check-certificate ${GLOO_URL} -c -q -O ${GLOO_NAME}.tar.gz - && tar zxvf ${GLOO_NAME}.tar.gz - DOWNLOAD_NO_PROGRESS 1 + ${SHALLOW_CLONE} + "${GLOO_DOWNLOAD_CMD}" + PREFIX "${GLOO_PREFIX_DIR}" + SOURCE_DIR "${GLOO_SOURCE_DIR}" UPDATE_COMMAND "" - CMAKE_ARGS -DCMAKE_INSTALL_PREFIX=${GLOO_INSTALL_ROOT} - CMAKE_CACHE_ARGS -DCMAKE_INSTALL_PREFIX:PATH=${GLOO_INSTALL_ROOT} + CONFIGURE_COMMAND "" + BUILD_COMMAND mkdir -p ${GLOO_SOURCE_DIR}/build + && cd ${GLOO_SOURCE_DIR}/build && cmake .. && make + && mkdir -p ${GLOO_LIBRARY_DIR} ${GLOO_INCLUDE_DIR}/gloo + INSTALL_COMMAND ${CMAKE_COMMAND} -E copy ${GLOO_SOURCE_DIR}/build/gloo/libgloo.a ${GLOO_LIBRARY_DIR} + COMMAND ${CMAKE_COMMAND} -E copy_directory "${GLOO_SOURCE_DIR}/gloo/" "${GLOO_INCLUDE_DIR}/gloo" ) -ADD_LIBRARY(gloo SHARED IMPORTED GLOBAL) -SET_PROPERTY(TARGET gloo PROPERTY IMPORTED_LOCATION ${GLOO_LIB}) + +ADD_LIBRARY(gloo STATIC IMPORTED GLOBAL) +SET_PROPERTY(TARGET gloo PROPERTY IMPORTED_LOCATION ${GLOO_LIBRARIES}) ADD_DEPENDENCIES(gloo ${GLOO_PROJECT}) -- GitLab