File 01_find_libs.patch of Package ethereum-cpp

From: Adam Mizerski <adam@mizerski.pl>
Date: 2019-02-12 20:48:31
Upstream: no
Subject: find libraries

ethereum-cpp uses Hunter to download and build dependencies, some of which are
build as static libraries. Hunter also provides many cmake files. In OBS we
can't download anything from internet and it's better to have dependencies as
shared libraries in separate packages.

Index: ethereum-cpp-1.8.0/CMakeLists.txt
===================================================================
--- ethereum-cpp-1.8.0.orig/CMakeLists.txt
+++ ethereum-cpp-1.8.0/CMakeLists.txt
@@ -19,10 +19,6 @@ cable_configure_toolchain(DEFAULT cxx14-
 set(ETH_CMAKE_DIR "${CMAKE_CURRENT_LIST_DIR}/cmake" CACHE PATH "The path to the cmake directory")
 list(APPEND CMAKE_MODULE_PATH ${ETH_CMAKE_DIR})
 
-# Map current configuration to configurations of imported targets.
-set(CMAKE_MAP_IMPORTED_CONFIG_DEBUG Release)
-set(CMAKE_MAP_IMPORTED_CONFIG_RELWITHDEBINFO Release)
-
 set(HUNTER_CONFIGURATION_TYPES Release CACHE STRING "Hunter configuration types")
 set(HUNTER_JOBS_NUMBER 4 CACHE STRING "Hunter jobs number")
 set(HUNTER_CACHE_SERVERS "https://github.com/ethereum/hunter-cache" CACHE STRING "Hunter cache servers")
@@ -59,34 +55,36 @@ include(EthCompilerSettings)
 include(EthExecutableHelper)
 include(EthDependencies)
 include(EthUtils)
+include(FindPkgConfig)
 
-set(Boost_USE_STATIC_LIBS ON)
-set(Boost_USE_MULTITHREADED ON)
 hunter_add_package(Boost COMPONENTS program_options filesystem system thread context fiber log)
-find_package(Boost CONFIG REQUIRED program_options filesystem system thread context fiber log)
+set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -DBOOST_ALL_DYN_LINK")
+find_package(Boost REQUIRED program_options filesystem system thread context fiber log)
 
 hunter_add_package(jsoncpp)
-find_package(jsoncpp CONFIG REQUIRED)
+pkg_check_modules(JSONCPP REQUIRED jsoncpp)
 
 hunter_add_package(Snappy)
 find_package(Snappy CONFIG REQUIRED)
 
 hunter_add_package(cryptopp)
-find_package(cryptopp CONFIG REQUIRED)
+pkg_check_modules(CRYPTOPP REQUIRED cryptopp)
 
 hunter_add_package(libjson-rpc-cpp)
-find_package(libjson-rpc-cpp CONFIG REQUIRED)
+pkg_check_modules(LIBJSONRPCCPP_SERVER REQUIRED libjsonrpccpp-server)
+pkg_check_modules(LIBJSONRPCCPP_CLIENT REQUIRED libjsonrpccpp-client)
 
 hunter_add_package(libscrypt)
-find_package(libscrypt CONFIG REQUIRED)
+find_library(LIBSCRYPT scrypt)
 
 hunter_add_package(ethash)
 find_package(ethash CONFIG REQUIRED)
 
 message("Crypto++: ${HUNTER_cryptopp_VERSION}")
 
-include(ProjectSecp256k1)
-include(ProjectLibFF)
+pkg_check_modules(SECP256K1 REQUIRED libsecp256k1)
+find_library(LIBGMP gmp)
+find_library(LIBFF ff)
 
 find_package(Threads)
 
Index: ethereum-cpp-1.8.0/cmake/EthCompilerSettings.cmake
===================================================================
--- ethereum-cpp-1.8.0.orig/cmake/EthCompilerSettings.cmake
+++ ethereum-cpp-1.8.0/cmake/EthCompilerSettings.cmake
@@ -34,6 +34,7 @@ if (("${CMAKE_CXX_COMPILER_ID}" MATCHES
 
     # Disable warnings about unknown pragmas (which is enabled by -Wall).
     add_compile_options(-Wno-unknown-pragmas)
+    add_compile_options(-Wno-deprecated-declarations)
 
     # Configuration-specific compiler settings.
     set(CMAKE_CXX_FLAGS_DEBUG          "-O0 -g -DETH_DEBUG")
@@ -42,7 +43,6 @@ if (("${CMAKE_CXX_COMPILER_ID}" MATCHES
     set(CMAKE_CXX_FLAGS_RELWITHDEBINFO "-O2 -g")
 
     # Hide all symbols by default.
-    add_compile_options(-fvisibility=hidden)
     if(CMAKE_SYSTEM_NAME STREQUAL "Linux")
         # Do not export symbols from dependencies.
         set(CMAKE_SHARED_LINKER_FLAGS "${CMAKE_SHARED_LINKER_FLAGS} -Wl,--exclude-libs,ALL")
Index: ethereum-cpp-1.8.0/libaleth-interpreter/CMakeLists.txt
===================================================================
--- ethereum-cpp-1.8.0.orig/libaleth-interpreter/CMakeLists.txt
+++ ethereum-cpp-1.8.0/libaleth-interpreter/CMakeLists.txt
@@ -1,8 +1,6 @@
 # Aleth: Ethereum C++ client, tools and libraries.
 # Copyright 2018-2019 Aleth Authors.
 # Licensed under the GNU General Public License, Version 3. See the LICENSE file.
-hunter_add_package(intx)
-find_package(intx CONFIG REQUIRED)
 
 set(
     sources
@@ -21,10 +19,10 @@ set(
     evmc::evmc
     evmc::instructions
     Boost::boost
-    intx::intx
 )
 
 add_library(aleth-interpreter STATIC ${sources})
+set_property(TARGET aleth-interpreter PROPERTY POSITION_INDEPENDENT_CODE ON)
 target_link_libraries(aleth-interpreter PRIVATE ${dependencies})
 
 if(EVM_OPTIMIZE)
Index: ethereum-cpp-1.8.0/libdevcore/CMakeLists.txt
===================================================================
--- ethereum-cpp-1.8.0.orig/libdevcore/CMakeLists.txt
+++ ethereum-cpp-1.8.0/libdevcore/CMakeLists.txt
@@ -61,16 +61,16 @@ add_library(
 # Needed to prevent including system-level boost headers:
 target_include_directories(devcore SYSTEM PUBLIC ${Boost_INCLUDE_DIR} PRIVATE ../utils)
 
-target_link_libraries(devcore PUBLIC aleth-buildinfo Boost::filesystem Boost::system Boost::log Boost::thread Threads::Threads PRIVATE ethash::ethash)
+target_link_libraries(devcore PUBLIC aleth-buildinfo Boost::filesystem Boost::system Boost::log Boost::thread Boost::program_options Threads::Threads ethash::ethash)
 
 hunter_add_package(leveldb)
-find_package(leveldb CONFIG REQUIRED)
-target_link_libraries(devcore PRIVATE leveldb::leveldb)
+find_library(LEVELDB leveldb)
+target_link_libraries(devcore PRIVATE ${LEVELDB})
 
 if(ROCKSDB)
     hunter_add_package(rocksdb)
-    find_package(RocksDB CONFIG REQUIRED)
+    find_library(ROCKSDB rocksdb)
     target_sources(devcore PRIVATE RocksDB.cpp RocksDB.h)
-    target_link_libraries(devcore PRIVATE RocksDB::rocksdb)
+    target_link_libraries(devcore PRIVATE ${ROCKSDB})
     target_compile_definitions(devcore PRIVATE ALETH_ROCKSDB)
 endif()
\ No newline at end of file
Index: ethereum-cpp-1.8.0/libdevcrypto/CMakeLists.txt
===================================================================
--- ethereum-cpp-1.8.0.orig/libdevcrypto/CMakeLists.txt
+++ ethereum-cpp-1.8.0/libdevcrypto/CMakeLists.txt
@@ -3,4 +3,4 @@ file(GLOB HEADERS "*.h")
 
 add_library(devcrypto ${SOURCES} ${HEADERS})
 target_include_directories(devcrypto PRIVATE ${UTILS_INCLUDE_DIR})
-target_link_libraries(devcrypto PUBLIC devcore Secp256k1 PRIVATE libff::ff cryptopp-static libscrypt::scrypt)
+target_link_libraries(devcrypto PUBLIC devcore ${SECP256K1_LIBRARIES} PRIVATE ${LIBFF} ${LIBGMP} ${CRYPTOPP_LIBRARIES} ${LIBSCRYPT})
\ No newline at end of file
Index: ethereum-cpp-1.8.0/libdevcrypto/CryptoPP.cpp
===================================================================
--- ethereum-cpp-1.8.0.orig/libdevcrypto/CryptoPP.cpp
+++ ethereum-cpp-1.8.0/libdevcrypto/CryptoPP.cpp
@@ -10,8 +10,6 @@
 #include <libdevcore/Assertions.h>
 #include <libdevcore/SHA3.h>
 
-static_assert(CRYPTOPP_VERSION == 820, "Wrong Crypto++ version");
-
 using namespace dev;
 using namespace dev::crypto;
 
Index: ethereum-cpp-1.8.0/libdevcrypto/LibSnark.cpp
===================================================================
--- ethereum-cpp-1.8.0.orig/libdevcrypto/LibSnark.cpp
+++ ethereum-cpp-1.8.0/libdevcrypto/LibSnark.cpp
@@ -3,11 +3,11 @@
 // Licensed under the GNU General Public License, Version 3.
 #include <libdevcrypto/LibSnark.h>
 
-#include <algebra/curves/alt_bn128/alt_bn128_g1.hpp>
-#include <algebra/curves/alt_bn128/alt_bn128_g2.hpp>
-#include <algebra/curves/alt_bn128/alt_bn128_pairing.hpp>
-#include <algebra/curves/alt_bn128/alt_bn128_pp.hpp>
-#include <common/profiling.hpp>
+#include <libff/algebra/curves/alt_bn128/alt_bn128_g1.hpp>
+#include <libff/algebra/curves/alt_bn128/alt_bn128_g2.hpp>
+#include <libff/algebra/curves/alt_bn128/alt_bn128_pairing.hpp>
+#include <libff/algebra/curves/alt_bn128/alt_bn128_pp.hpp>
+#include <libff/common/profiling.hpp>
 
 #include <libdevcore/Exceptions.h>
 #include <libdevcore/Log.h>
Index: ethereum-cpp-1.8.0/libevm/CMakeLists.txt
===================================================================
--- ethereum-cpp-1.8.0.orig/libevm/CMakeLists.txt
+++ ethereum-cpp-1.8.0/libevm/CMakeLists.txt
@@ -16,7 +16,7 @@ add_library(evm ${sources})
 target_link_libraries(
     evm
     PUBLIC ethcore devcore evmc::evmc
-    PRIVATE aleth-interpreter aleth-buildinfo jsoncpp_lib_static Boost::program_options evmc::loader
+    PRIVATE aleth-interpreter aleth-buildinfo jsoncpp Boost::program_options evmc::loader
 )
 
 if(EVM_OPTIMIZE)
Index: ethereum-cpp-1.8.0/libp2p/CMakeLists.txt
===================================================================
--- ethereum-cpp-1.8.0.orig/libp2p/CMakeLists.txt
+++ ethereum-cpp-1.8.0/libp2p/CMakeLists.txt
@@ -1,7 +1,7 @@
 file(GLOB sources "*.cpp" "*.h")
 
 add_library(p2p ${sources})
-target_link_libraries(p2p PUBLIC devcrypto devcore)
+target_link_libraries(p2p PUBLIC devcrypto devcore ${CRYPTOPP_LIBRARIES})
 target_include_directories(p2p SYSTEM PRIVATE ${CRYPTOPP_INCLUDE_DIR})
 
 if(MINIUPNPC)
Index: ethereum-cpp-1.8.0/libweb3jsonrpc/CMakeLists.txt
===================================================================
--- ethereum-cpp-1.8.0.orig/libweb3jsonrpc/CMakeLists.txt
+++ ethereum-cpp-1.8.0/libweb3jsonrpc/CMakeLists.txt
@@ -84,4 +84,4 @@ jsonrpcstub_create(web3jsonrpc test.json
     TestClient ${CMAKE_CURRENT_BINARY_DIR} TestClient
 )
 
-target_link_libraries(web3jsonrpc ethashseal webthree libjson-rpc-cpp::server)
+target_link_libraries(web3jsonrpc ethashseal webthree ${LIBJSONRPCCPP_SERVER_LIBRARIES})
Index: ethereum-cpp-1.8.0/libwebthree/CMakeLists.txt
===================================================================
--- ethereum-cpp-1.8.0.orig/libwebthree/CMakeLists.txt
+++ ethereum-cpp-1.8.0/libwebthree/CMakeLists.txt
@@ -1,3 +1,3 @@
 add_library(webthree WebThree.cpp WebThree.h)
 target_include_directories(webthree PRIVATE ../utils)
-target_link_libraries(webthree PUBLIC ethereum p2p devcore)
+target_link_libraries(webthree PUBLIC ethereum p2p devcore PRIVATE ethashseal)
Index: ethereum-cpp-1.8.0/test/CMakeLists.txt
===================================================================
--- ethereum-cpp-1.8.0.orig/test/CMakeLists.txt
+++ ethereum-cpp-1.8.0/test/CMakeLists.txt
@@ -4,7 +4,7 @@ set(CTEST_OUTPUT_ON_FAILURE TRUE)
 include(GoogleTest)
 
 hunter_add_package(GTest)
-find_package(GTest CONFIG REQUIRED)
+find_package(GTest REQUIRED)
 
 set(unittest_sources
     unittests/libdevcore/CommonJS.cpp
@@ -42,7 +42,7 @@ add_executable(aleth-unittests ${unittes
 target_include_directories(aleth-unittests PRIVATE ${UTILS_INCLUDE_DIR})
 target_link_libraries(aleth-unittests PRIVATE
     web3jsonrpc ethashseal devcrypto devcore
-    GTest::gtest GTest::gtest_main
+    GTest::GTest GTest::Main
 )
 gtest_add_tests(TARGET aleth-unittests TEST_PREFIX unittests/ TEST_LIST unittests)
 set_tests_properties(${unittests} PROPERTIES TIMEOUT ${timeout})
@@ -118,7 +118,7 @@ find_package(yaml-cpp CONFIG REQUIRED)
 
 add_executable(testeth ${sources})
 target_include_directories(testeth PRIVATE ${UTILS_INCLUDE_DIR})
-target_link_libraries(testeth PRIVATE ethereum ethashseal web3jsonrpc devcrypto devcore aleth-buildinfo cryptopp-static yaml-cpp::yaml-cpp libjson-rpc-cpp::client)
+target_link_libraries(testeth PRIVATE ethereum ethashseal web3jsonrpc devcrypto devcore aleth-buildinfo aleth-interpreter ${CRYPTOPP_LIBRARIES} yaml-cpp ${LIBJSONRPCCPP_CLIENT_LIBRARIES})
 install(TARGETS testeth DESTINATION ${CMAKE_INSTALL_BINDIR})
 
 set_property(SOURCE tools/libtesteth/TestHelper.cpp PROPERTY COMPILE_DEFINITIONS BINARYEN_VERSION=${BINARYEN_VERSION})
Index: ethereum-cpp-1.8.0/libethereum/CMakeLists.txt
===================================================================
--- ethereum-cpp-1.8.0.orig/libethereum/CMakeLists.txt
+++ ethereum-cpp-1.8.0/libethereum/CMakeLists.txt
@@ -3,4 +3,4 @@ file(GLOB sources "*.cpp" "*.h")
 add_library(ethereum ${sources})
 
 target_include_directories(ethereum PRIVATE "${UTILS_INCLUDE_DIR}")
-target_link_libraries(ethereum PUBLIC evm ethcore p2p devcrypto devcore PRIVATE jsoncpp_lib_static Snappy::snappy Boost::fiber Boost::context)
+target_link_libraries(ethereum PUBLIC evm ethcore p2p devcrypto devcore jsoncpp PRIVATE Snappy::snappy Boost::fiber Boost::context)
openSUSE Build Service is sponsored by