Skip to content

Commit

Permalink
[cmake] add absl third_party cache (#55549)
Browse files Browse the repository at this point in the history
* add absl to third_party

* fix

* ci test

* ci test

* ci test

* rollback
  • Loading branch information
gouzil authored Aug 10, 2023
1 parent a9d3cef commit 988b252
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 9 deletions.
4 changes: 0 additions & 4 deletions cmake/cinn.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -326,10 +326,6 @@ set(CINN_LIB "${CINN_LIB_LOCATION}/${CINN_LIB_NAME}")
# Add CINN's dependencies header files
######################################

# Add absl
set(ABSL_INCLUDE_DIR "${CMAKE_BINARY_DIR}/dist/third_party/absl/include")
include_directories(${ABSL_INCLUDE_DIR})

# Add isl
set(ISL_INCLUDE_DIR "${CMAKE_BINARY_DIR}/third_party/install/isl/include")
include_directories(${ISL_INCLUDE_DIR})
Expand Down
27 changes: 22 additions & 5 deletions cmake/cinn/external/absl.cmake
Original file line number Diff line number Diff line change
@@ -1,13 +1,31 @@
include(ExternalProject)

set(ABSL_SOURCES_DIR ${THIRD_PARTY_PATH}/absl)
set(ABSL_SOURCES_DIR ${PADDLE_SOURCE_DIR}/third_party/absl)
set(ABSL_INSTALL_DIR ${THIRD_PARTY_PATH}/install/absl)

set(ABSL_PREFIX_DIR ${THIRD_PARTY_PATH}/absl)
set(ABSL_CMAKE_CXX_FLAGS ${CMAKE_CXX_FLAGS})

set(ABSL_REPOSITORY "https://github.com/abseil/abseil-cpp.git")
set(ABSL_TAG "20210324.2")

if(NOT EXISTS ${ABSL_SOURCES_DIR})
message(
STATUS "Download absl source from ${ABSL_REPOSITORY} to ABSL_SOURCES_DIR")
execute_process(COMMAND ${GIT_EXECUTABLE} clone -b ${ABSL_TAG}
${ABSL_REPOSITORY} ${ABSL_SOURCES_DIR})
else()
# check git tag
execute_process(
COMMAND ${GIT_EXECUTABLE} -C ${ABSL_SOURCES_DIR} describe --tags
OUTPUT_VARIABLE CURRENT_TAG
OUTPUT_STRIP_TRAILING_WHITESPACE)
if(NOT ${CURRENT_TAG} STREQUAL ${ABSL_TAG})
message(STATUS "Checkout absl to ${ABSL_TAG}")
execute_process(COMMAND ${GIT_EXECUTABLE} -C ${ABSL_SOURCES_DIR} checkout
-q ${ABSL_TAG})
endif()
endif()

set(OPTIONAL_ARGS
"-DCMAKE_CXX_COMPILER=${CMAKE_CXX_COMPILER}"
"-DCMAKE_C_COMPILER=${CMAKE_C_COMPILER}"
Expand All @@ -22,9 +40,8 @@ ExternalProject_Add(
external_absl
${EXTERNAL_PROJECT_LOG_ARGS}
DEPENDS gflags
GIT_REPOSITORY ${ABSL_REPOSITORY}
GIT_TAG ${ABSL_TAG}
PREFIX ${ABSL_SOURCES_DIR}
PREFIX ${ABSL_PREFIX_DIR}
SOURCE_DIR ${ABSL_SOURCES_DIR}
UPDATE_COMMAND ""
CMAKE_ARGS ${OPTIONAL_ARGS}
-DCMAKE_INSTALL_PREFIX=${ABSL_INSTALL_DIR}
Expand Down

0 comments on commit 988b252

Please sign in to comment.