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

precompiles: Prepare blst dependency #972

Merged
merged 1 commit into from
Aug 27, 2024
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
43 changes: 43 additions & 0 deletions cmake/blst.cmake
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
include_guard()
include(ExternalProject)

if(MSVC)
set(BLST_BUILD_SCRIPT build.bat)
elseif(CMAKE_SYSTEM_NAME STREQUAL "Darwin")
# Don't pass CC to the script because it doesn't work.
set(BLST_BUILD_SCRIPT ./build.sh -mmacosx-version-min=${CMAKE_OSX_DEPLOYMENT_TARGET})
else()
# Pass CC and AR, this supports cross-compilation.
# Pass CFLAGS as part of CC (e.g. to pass -m32). Using CFLAGS directly overwrites blst's default.
string(JOIN " " BLST_CC ${CMAKE_C_COMPILER} ${CMAKE_C_FLAGS})
set(BLST_BUILD_SCRIPT ./build.sh CC='${BLST_CC}' AR='${CMAKE_AR}')
endif()

ExternalProject_Add(
blst
EXCLUDE_FROM_ALL TRUE
PREFIX ${PROJECT_BINARY_DIR}/deps
URL https://github.com/supranational/blst/archive/refs/tags/v0.3.13.tar.gz
URL_HASH SHA256=89772cef338e93bc0348ae531462752906e8fa34738e38035308a7931dd2948f
DOWNLOAD_NO_PROGRESS TRUE
CONFIGURE_COMMAND ""
BUILD_COMMAND ${BLST_BUILD_SCRIPT}
BUILD_IN_SOURCE TRUE
BUILD_BYPRODUCTS "<SOURCE_DIR>/${CMAKE_STATIC_LIBRARY_PREFIX}blst${CMAKE_STATIC_LIBRARY_SUFFIX}"
LOG_BUILD TRUE
LOG_OUTPUT_ON_FAILURE TRUE
INSTALL_COMMAND ""
)
ExternalProject_Get_Property(blst SOURCE_DIR)

set(BLST_INCLUDE_DIR ${SOURCE_DIR}/bindings)
file(MAKE_DIRECTORY ${BLST_INCLUDE_DIR})

add_library(blst::blst STATIC IMPORTED GLOBAL)
add_dependencies(blst::blst blst)
set_target_properties(
blst::blst PROPERTIES
INTERFACE_INCLUDE_DIRECTORIES ${BLST_INCLUDE_DIR}
IMPORTED_LOCATION ${SOURCE_DIR}/${CMAKE_STATIC_LIBRARY_PREFIX}blst${CMAKE_STATIC_LIBRARY_SUFFIX}
)

2 changes: 2 additions & 0 deletions lib/evmone_precompiles/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@
# Copyright 2023 The evmone Authors.
# SPDX-License-Identifier: Apache-2.0

include(blst)

add_library(evmone_precompiles STATIC)
add_library(evmone::precompiles ALIAS evmone_precompiles)
target_link_libraries(evmone_precompiles PUBLIC evmc::evmc_cpp PRIVATE evmone::evmmax)
Expand Down