From e5c3f67b045d0a73feb6201b22a0d2a2b232cb97 Mon Sep 17 00:00:00 2001 From: battlmonstr Date: Mon, 29 May 2023 12:15:53 +0200 Subject: [PATCH] CI: use GMP from Conan on Windows too (#1184) --- .github/workflows/windows.yml | 18 +----------- README.md | 6 +--- third_party/CMakeLists.txt | 55 ++++++++++++++--------------------- 3 files changed, 24 insertions(+), 55 deletions(-) diff --git a/.github/workflows/windows.yml b/.github/workflows/windows.yml index b123d6cdc7..ce4c06382e 100644 --- a/.github/workflows/windows.yml +++ b/.github/workflows/windows.yml @@ -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 diff --git a/README.md b/README.md index 3a16a18304..cebea174a2 100644 --- a/README.md +++ b/README.md @@ -108,11 +108,7 @@ cmd/test/ethereum **Note! Windows builds are maintained for compatibility/portability reasons. However, due to the lack of 128-bit integers support by MSVC, execution performance is inferior when compared to Linux builds.** * Install [Visual Studio] 2019. Community edition is fine. * Make sure your setup includes CMake support and Windows 10 SDK. -* Install [vcpkg](https://github.com/microsoft/vcpkg#quick-start-windows). -* `.\vcpkg\vcpkg install mpir:x64-windows` -* Add \installed\x64-windows\include to your `INCLUDE` environment variable. -* Add \installed\x64-windows\bin to your `PATH` environment variable. -* Install [Perl](https://strawberryperl.com/) (needed for OpenSSL build process) +* Install [Conan](https://conan.io) and add it to PATH. * Open Visual Studio and select File -> CMake... * Browse the folder where you have cloned this repository and select the file CMakeLists.txt * Let CMake cache generation complete (it may take several minutes) diff --git a/third_party/CMakeLists.txt b/third_party/CMakeLists.txt index 2b6cd2a7bd..779741ae90 100644 --- a/third_party/CMakeLists.txt +++ b/third_party/CMakeLists.txt @@ -16,6 +16,27 @@ include(ExternalProject) +# GMP +# declaring it first to be used by intx, libff +if(DEFINED GMP_LIBRARY) + add_library(gmplib STATIC IMPORTED) + set_target_properties(gmplib PROPERTIES IMPORTED_LOCATION "${GMP_LIBRARY}") + if(DEFINED GMP_INCLUDE_DIR) + set_target_properties(gmplib PROPERTIES INTERFACE_INCLUDE_DIRECTORIES "${GMP_INCLUDE_DIR}") + else() + message(FATAL_ERROR "GMP_INCLUDE_DIR is required if a custom GMP_LIBRARY is provided") + endif() +else() + find_package(gmp REQUIRED) + add_custom_target(gmplib DEPENDS gmp::GMP) + + # derive the path variables from the package for intx, libff + get_target_property(GMP_INCLUDE_DIR gmp::GMP INTERFACE_INCLUDE_DIRECTORIES) + set(GMP_INCLUDE_DIR "${GMP_INCLUDE_DIR}" CACHE PATH "") + get_target_property(GMP_LIBRARY_DIR gmp::GMP INTERFACE_LINK_DIRECTORIES) + find_library(GMP_LIBRARY gmp "${GMP_LIBRARY_DIR}") +endif() + # evmone with dependencies add_subdirectory(intx) @@ -69,39 +90,10 @@ else() target_compile_options(evmone PRIVATE -fno-exceptions) endif() -# GMP -if(NOT MSVC) - if(DEFINED GMP_LIBRARY) - add_library(gmplib STATIC IMPORTED) - set_target_properties(gmplib PROPERTIES IMPORTED_LOCATION "${GMP_LIBRARY}") - if(DEFINED GMP_INCLUDE_DIR) - set_target_properties(gmplib PROPERTIES INTERFACE_INCLUDE_DIRECTORIES "${GMP_INCLUDE_DIR}") - endif() - else() - find_package(gmp REQUIRED) - 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} - ) -endif() - # secp256k1 add_library(secp256k1 secp256k1/src/secp256k1.c) if(MSVC) - target_link_libraries(secp256k1 PRIVATE gmp) + add_dependencies(secp256k1 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 @@ -125,9 +117,6 @@ set(CURVE ) option(WITH_PROCPS "" OFF) option(IS_LIBFF_PARENT "" OFF) -if(MSVC) - option(MPIR_INSTEAD_OF_GMP "" ON) -endif() add_subdirectory(libff) if(NOT MSVC) add_dependencies(ff gmplib)