Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[cmake] add absl third_party cache #55549

Merged
merged 8 commits into from
Aug 10, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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}/dist/third_party/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