isl.cmake 2.1 KB
Newer Older
1 2 3 4 5 6 7 8 9
include(ExternalProject)

# isl https://github.com/inducer/ISL
# commit-id 6a1760fe46967cda2a06387793a6b7d4a0876581
#   depends on llvm f9dc2b7079350d0fed3bb3775f496b90483c9e42
#   depends on gmp-6.2.1
# static build
# CPPFLAGS="-fPIC -DPIC" ./configure --with-gmp-prefix=<gmp-install-path> --with-clang-prefix=<llvm-install-path> --enable-shared=no --enable-static=yes

10 11 12
set(ISL_FILE
    "isl-6a1760fe.tar.gz"
    CACHE STRING "" FORCE)
13
set(ISL_DOWNLOAD_URL
14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48
    "https://paddle-inference-dist.bj.bcebos.com/CINN/${ISL_FILE}")
set(ISL_URL_MD5 fff10083fb79d394b8a7b7b2089f6183)
set(ISL_DOWNLOAD_DIR ${PADDLE_SOURCE_DIR}/third_party/isl)
set(ISL_PREFIX_DIR ${THIRD_PARTY_PATH}/isl)
set(ISL_INSTALL_DIR ${THIRD_PARTY_PATH}/install/isl)

function(download_isl)
  message(
    STATUS "Downloading ${ISL_DOWNLOAD_URL} to ${ISL_DOWNLOAD_DIR}/${ISL_FILE}")
  file(
    DOWNLOAD ${ISL_DOWNLOAD_URL} ${ISL_DOWNLOAD_DIR}/${ISL_FILE}
    EXPECTED_MD5 ${ISL_URL_MD5}
    STATUS ERR)
  if(ERR EQUAL 0)
    message(STATUS "Download ${ISL_FILE} success")
  else()
    message(
      FATAL_ERROR
        "Download failed, error: ${ERR}\n You can try downloading ${ISL_FILE} again"
    )
  endif()
endfunction()

# Download and check isl.
if(EXISTS ${ISL_DOWNLOAD_DIR}/${ISL_FILE})
  file(MD5 ${ISL_DOWNLOAD_DIR}/${ISL_FILE} ISL_MD5)
  if(NOT ISL_MD5 STREQUAL ISL_URL_MD5)
    # clean build file
    file(REMOVE_RECURSE ${ISL_PREFIX_DIR})
    file(REMOVE_RECURSE ${ISL_INSTALL_DIR})
    download_isl()
  endif()
else()
  download_isl()
endif()
49 50 51 52

ExternalProject_Add(
  external_isl
  ${EXTERNAL_PROJECT_LOG_ARGS}
53 54 55 56 57
  URL ${ISL_DOWNLOAD_DIR}/${ISL_FILE}
  URL_MD5 ${ISL_URL_MD5}
  DOWNLOAD_DIR ${ISL_DOWNLOAD_DIR}
  PREFIX ${ISL_PREFIX_DIR}
  SOURCE_DIR ${ISL_INSTALL_DIR}
58 59 60 61
  CONFIGURE_COMMAND ""
  BUILD_COMMAND ""
  UPDATE_COMMAND ""
  INSTALL_COMMAND ""
62
  BUILD_BYPRODUCTS ${ISL_INSTALL_DIR}/lib/libisl.a)
63 64

add_library(isl STATIC IMPORTED GLOBAL)
65
set_property(TARGET isl PROPERTY IMPORTED_LOCATION
66
                                 ${ISL_INSTALL_DIR}/lib/libisl.a)
67
add_dependencies(isl external_isl)
68
include_directories(${ISL_INSTALL_DIR}/include)