lapack.cmake 3.1 KB
Newer Older
1 2 3 4 5 6 7 8 9 10 11 12 13 14
# Copyright (c) 2021 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.

15
include(ExternalProject)
16

17 18 19 20
set(LAPACK_PREFIX_DIR ${THIRD_PARTY_PATH}/lapack)
set(LAPACK_SOURCE_DIR ${THIRD_PARTY_PATH}/lapack/src/extern_lapack)
set(LAPACK_INSTALL_DIR ${THIRD_PARTY_PATH}/install/lapack)
set(LAPACK_LIB_DIR ${LAPACK_INSTALL_DIR}/lib)
21 22 23 24

# Note(zhouwei): lapack need fortan compiler which many machines don't have, so use precompiled library.
# use lapack tag v3.10.0 on 06/28/2021 https://github.com/Reference-LAPACK/lapack
if(LINUX)
25 26 27 28 29 30 31 32 33 34 35
  set(LAPACK_VER
      "lapack_lnx_v3.10.0.20210628"
      CACHE STRING "" FORCE)
  set(LAPACK_URL
      "https://paddlepaddledeps.bj.bcebos.com/${LAPACK_VER}.tar.gz"
      CACHE STRING "" FORCE)
  set(LAPACK_URL_MD5 71f8cc8237a8571692f3e07f9a4f25f6)
  set(GNU_RT_LIB_1 "${LAPACK_LIB_DIR}/libquadmath.so.0")
  set(GFORTRAN_LIB "${LAPACK_LIB_DIR}/libgfortran.so.3")
  set(BLAS_LIB "${LAPACK_LIB_DIR}/libblas.so.3")
  set(LAPACK_LIB "${LAPACK_LIB_DIR}/liblapack.so.3")
36
elseif(WIN32)
37 38 39 40 41 42 43 44 45 46 47 48 49
  # Refer to [lapack-for-windows] http://icl.cs.utk.edu/lapack-for-windows/lapack/#lapacke
  set(LAPACK_VER
      "lapack_win_v3.10.0.20210628"
      CACHE STRING "" FORCE)
  set(LAPACK_URL
      "https://paddlepaddledeps.bj.bcebos.com/${LAPACK_VER}.zip"
      CACHE STRING "" FORCE)
  set(LAPACK_URL_MD5 590d080392dcd5abbd5dca767a50b63a)
  set(GNU_RT_LIB_1 "${LAPACK_LIB_DIR}/libquadmath-0.dll")
  set(GNU_RT_LIB_2 "${LAPACK_LIB_DIR}/libgcc_s_seh-1.dll")
  set(GFORTRAN_LIB "${LAPACK_LIB_DIR}/libgfortran-3.dll")
  set(BLAS_LIB "${LAPACK_LIB_DIR}/libblas.dll")
  set(LAPACK_LIB "${LAPACK_LIB_DIR}/liblapack.dll")
50
else()
51 52 53 54 55 56 57 58 59 60 61 62
  set(LAPACK_VER
      "lapack_mac_v3.10.0.20210628"
      CACHE STRING "" FORCE)
  set(LAPACK_URL
      "https://paddlepaddledeps.bj.bcebos.com/${LAPACK_VER}.tar.gz"
      CACHE STRING "" FORCE)
  set(LAPACK_URL_MD5 427aecf8dee8523de3566ca8e47944d7)
  set(GNU_RT_LIB_1 "${LAPACK_LIB_DIR}/libquadmath.0.dylib")
  set(GNU_RT_LIB_2 "${LAPACK_LIB_DIR}/libgcc_s.1.dylib")
  set(GFORTRAN_LIB "${LAPACK_LIB_DIR}/libgfortran.5.dylib")
  set(BLAS_LIB "${LAPACK_LIB_DIR}/libblas.3.dylib")
  set(LAPACK_LIB "${LAPACK_LIB_DIR}/liblapack.3.dylib")
63 64 65
endif()

ExternalProject_Add(
66 67 68 69 70 71 72 73 74 75 76 77 78 79
  extern_lapack
  ${EXTERNAL_PROJECT_LOG_ARGS}
  URL ${LAPACK_URL}
  URL_MD5 ${LAPACK_URL_MD5}
  PREFIX ${LAPACK_PREFIX_DIR}
  DOWNLOAD_NO_PROGRESS 1
  PATCH_COMMAND ""
  UPDATE_COMMAND ""
  CONFIGURE_COMMAND ""
  BUILD_COMMAND ""
  INSTALL_COMMAND ${CMAKE_COMMAND} -E copy_directory ${LAPACK_SOURCE_DIR}
                  ${LAPACK_LIB_DIR}
  BUILD_BYPRODUCTS ${BLAS_LIB}
  BUILD_BYPRODUCTS ${LAPACK_LIB})