Skip to content

Commit

Permalink
CI: use mpir from Conan on Windows
Browse files Browse the repository at this point in the history
  • Loading branch information
battlmonstr committed May 26, 2023
1 parent 1ca7057 commit a58e3fd
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 32 deletions.
18 changes: 1 addition & 17 deletions .github/workflows/windows.yml
Original file line number Diff line number Diff line change
Expand Up @@ -49,30 +49,14 @@ jobs:
with:
version: 1.59.0

- name: Conan version
run: echo "${{ steps.conan.outputs.version }}"

- name: vcpkg build
uses: johnwason/vcpkg-action@v4
id: vcpkg
with:
pkgs: mpir
triplet: x64-windows
token: ${{ github.token }}

- name: Create Build Environment
# Some projects don't allow in-source building, so create a separate build directory
# We'll use this as our working directory for all subsequent commands
run: cmake -E make_directory C:\build

- name: Add VCPKG libs to environment
run: |
Add-Content $env:GITHUB_PATH "${{runner.workspace}}\silkworm\vcpkg\installed\x64-windows\bin"
Add-Content $env:GITHUB_ENV "INCLUDE=${{runner.workspace}}\silkworm\vcpkg\installed\x64-windows\include"
- name: Configure CMake
working-directory: C:\build
run: cmake ${{runner.workspace}}\silkworm
run: cmake ${{runner.workspace}}\silkworm -DCMAKE_BUILD_TYPE=${{ matrix.config.build_type }}

- name: Build silkworm
working-directory: C:\build
Expand Down
7 changes: 7 additions & 0 deletions cmake/conan.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,13 @@ include("${CMAKE_SOURCE_DIR}/third_party/cmake-conan/conan.cmake")
# provide a static conanfile.txt instead of generating it with conan_cmake_configure()
file(COPY "${CMAKE_SOURCE_DIR}/conanfile.txt" DESTINATION "${CONAN_BINARY_DIR}")

# use mpir instead of gmp on Windows
if(CMAKE_HOST_SYSTEM_NAME STREQUAL "Windows")
file(READ "${CONAN_BINARY_DIR}/conanfile.txt" conanfile_contents)
string(REPLACE "gmp/6.2.1" "mpir/3.0.0" conanfile_contents "${conanfile_contents}")
file(WRITE "${CONAN_BINARY_DIR}/conanfile.txt" "${conanfile_contents}")
endif()

if(NOT DEFINED CONAN_PROFILE)
guess_conan_profile()
endif()
Expand Down
18 changes: 3 additions & 15 deletions third_party/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -82,26 +82,14 @@ if(NOT MSVC)
add_custom_target(gmplib DEPENDS gmp::gmp)
endif()
else()
find_path(GMP_INCLUDE_DIR NAMES gmp.h)
find_library(GMP_LIBRARY mpir)
if(GMP_LIBRARY MATCHES ${CMAKE_SHARED_LIBRARY_SUFFIX})
set(gmp_library_type SHARED)
else()
set(gmp_library_type STATIC)
endif()
message(STATUS "GMP: ${GMP_LIBRARY}, ${GMP_INCLUDE_DIR}")
add_library(gmp ${gmp_library_type} IMPORTED)
set_target_properties(
gmp PROPERTIES
IMPORTED_LOCATION ${GMP_LIBRARY}
INTERFACE_INCLUDE_DIRECTORIES ${GMP_INCLUDE_DIR}
)
find_package(mpir REQUIRED)
add_custom_target(gmplib DEPENDS mpir::mpir)
endif()

# secp256k1
add_library(secp256k1 secp256k1/src/secp256k1.c)
if(MSVC)
target_link_libraries(secp256k1 PRIVATE gmp)
target_link_libraries(secp256k1 PRIVATE gmplib)
target_compile_definitions(secp256k1 PUBLIC USE_NUM_GMP USE_FIELD_INV_NUM USE_SCALAR_INV_NUM)
target_compile_definitions(secp256k1 PUBLIC USE_FIELD_10X26 USE_SCALAR_8X32)
target_compile_options(secp256k1 PRIVATE /w) # Not much we can do about warnings
Expand Down

0 comments on commit a58e3fd

Please sign in to comment.