Skip to content

Commit

Permalink
Merge pull request #431 from seoklab/build/prebuilt-absl
Browse files Browse the repository at this point in the history
build: enable downloading prebuilt absl binaries
  • Loading branch information
jnooree authored Dec 9, 2024
2 parents 882107e + 8f63400 commit 737518e
Show file tree
Hide file tree
Showing 3 changed files with 49 additions and 12 deletions.
6 changes: 6 additions & 0 deletions .github/workflows/_wheel-build.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,12 @@ jobs:
- if: ${{ contains(inputs.python, 'macosx') }}
run: brew install eigen spectra boost pybind11 ninja

- if: ${{ contains(inputs.python, 'macosx') }}
uses: maxim-lobanov/setup-xcode@v1
with:
# XCode 15.4 fails to build abseil correctly
xcode-version: latest-stable

# https://github.com/pypa/cibuildwheel/issues/954
- if: ${{ inputs.python == 'cp38-macosx_arm64' }}
run: |
Expand Down
3 changes: 2 additions & 1 deletion CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ option(NURI_ENABLE_AVX2 "Use -mavx2 flag for optimization" OFF)
option(NURI_ENABLE_ARCH_NATIVE "Use -march=native flag for optimization" OFF)

option(NURI_ENABLE_SANITIZERS "Enable sanitizers for debug build" OFF)
option(NURI_PREBUILT_ABSL "Download prebuilt abseil binary" ON)

option(NURI_TEST_COVERAGE "Enable coverage build" OFF)
option(NURI_BUILD_DOCS "Build documentation" OFF)
Expand Down Expand Up @@ -112,8 +113,8 @@ if(CMAKE_BUILD_TYPE MATCHES "Release|MinSizeRel")
add_link_options(-s)
endif()

add_subdirectory(third-party EXCLUDE_FROM_ALL)
find_or_fetch_abseil()
add_subdirectory(third-party EXCLUDE_FROM_ALL)

add_compile_options(
-pedantic
Expand Down
52 changes: 41 additions & 11 deletions cmake/NuriKitUtils.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -189,23 +189,53 @@ function(find_or_fetch_abseil)
NOTICE
"abseil must be built with sanitizers enabled; ignoring system abseil"
)
else()
find_package(absl QUIET)
endif()

# 20240116 required for VLOG()
if(absl_FOUND AND absl_VERSION VERSION_GREATER_EQUAL 20240116)
message(STATUS "Found abseil ${absl_VERSION}")
else()
elseif(NURI_PREBUILT_ABSL AND NOT absl_ROOT)
include(FetchContent)
message(NOTICE "Could not find compatible abseil. Fetching from github.")
message(NOTICE "Fetching prebuilt abseil binary.")

if(CMAKE_SYSTEM_NAME MATCHES Linux)
set(os_arch "manylinux2014_x86_64")
elseif(CMAKE_SYSTEM_NAME MATCHES Darwin)
set(os_arch "macosx_universal2")
endif()

Fetchcontent_Declare(
absl
URL https://github.com/abseil/abseil-cpp/releases/download/20240722.0/abseil-cpp-20240722.0.tar.gz
URL "https://github.com/jnooree/abseil-cpp/releases/latest/download/libabsl-static-${os_arch}.tar.gz"
)
nuri_make_available_deponly(absl)
Fetchcontent_MakeAvailable(absl)

set(absl_ROOT "${absl_SOURCE_DIR}")
find_package(absl)

if(absl_FOUND AND absl_VERSION VERSION_GREATER_EQUAL 20240116)
message(STATUS "Found abseil ${absl_VERSION}")

if(CMAKE_SYSTEM_NAME MATCHES Linux)
string(APPEND CMAKE_CXX_FLAGS " -D_GLIBCXX_USE_CXX11_ABI=0")
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS}" PARENT_SCOPE)
endif()

return()
endif()
else()
find_package(absl QUIET)

# 20240116 required for VLOG()
if(absl_FOUND AND absl_VERSION VERSION_GREATER_EQUAL 20240116)
message(STATUS "Found abseil ${absl_VERSION}")
return()
endif()
endif()

include(FetchContent)
message(NOTICE "Could not find compatible abseil. Fetching from github.")

Fetchcontent_Declare(
absl
URL https://github.com/abseil/abseil-cpp/releases/download/20240722.0/abseil-cpp-20240722.0.tar.gz
)
nuri_make_available_deponly(absl)
endfunction()

function(handle_boost_dependency target)
Expand Down

0 comments on commit 737518e

Please sign in to comment.