diff --git a/CMakeLists.txt b/CMakeLists.txt index 3f3963ffc3..6a69c5d2b6 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -112,7 +112,7 @@ option(BUILD_UTIL "Build ${FIRO_UTIL_NAME} executable and library." ${BUILD_TEST option(BUILD_UTIL_CHAINSTATE "Build experimental firo-chainstate executable." OFF) option(BUILD_KERNEL_LIB "Build experimental firokernel library." ${BUILD_UTIL_CHAINSTATE}) -option(ENABLE_WALLET "Enable wallet." ON) +option(ENABLE_WALLET "Enable wallet." OFF) option(WITH_BDB "Enable Berkeley DB (BDB) wallet support." OFF) cmake_dependent_option(WARN_INCOMPATIBLE_BDB "Warn when using a Berkeley DB (BDB) version other than 4.8." ON "WITH_BDB" OFF) if(WITH_BDB) @@ -421,6 +421,9 @@ find_library(MINIUPNP_LIBRARY REQUIRED ) +# Find GMP library +find_package(GMP 6.2.1 REQUIRED) + # Find zlib library find_library(ZLIB_LIBRARY NAMES z diff --git a/src/secp256k1/cmake/FindGMP.cmake b/cmake/module/FindGMP.cmake similarity index 57% rename from src/secp256k1/cmake/FindGMP.cmake rename to cmake/module/FindGMP.cmake index 91790e1987..0e658c05dd 100644 --- a/src/secp256k1/cmake/FindGMP.cmake +++ b/cmake/module/FindGMP.cmake @@ -1,7 +1,9 @@ -find_package(PkgConfig QUIET) -if(PKG_CONFIG_FOUND) - pkg_check_modules(PC_GMP QUIET gmp) -endif() +# Try to find the GNU Multiple Precision Arithmetic Library (GMP) +# See http://gmplib.org/ + +if (GMP_INCLUDES AND GMP_LIBRARIES) + set(GMP_FIND_QUIETLY TRUE) +endif (GMP_INCLUDES AND GMP_LIBRARIES) find_path(GMP_INCLUDES NAMES @@ -9,9 +11,10 @@ find_path(GMP_INCLUDES HINTS $ENV{GMPDIR} ${INCLUDE_INSTALL_DIR} - ${PC_GMP_INCLUDE_DIRS} - /usr/include - /usr/local/include + ${LIB_INSTALL_DIR} + ${PC_GMP_LIBRARY_DIRS} + /usr/lib + /usr/local/lib ) find_library(GMP_LIBRARIES @@ -24,7 +27,10 @@ find_library(GMP_LIBRARIES /usr/local/lib ) -if(GMP_INCLUDES) + +if(GMP_LIBRARIES AND GMP_INCLUDES) + message(STATUS "Found GMP: ${GMP_LIBRARIES}") + message(STATUS "GMP includes: ${GMP_INCLUDES}") file(STRINGS "${GMP_INCLUDES}/gmp.h" gmp_version_str REGEX "^#define[\t ]+__GNU_MP_VERSION[\t ]+[0-9]+") string(REGEX REPLACE "^#define[\t ]+__GNU_MP_VERSION[\t ]+([0-9]+).*" "\\1" GMP_VERSION_MAJOR "${gmp_version_str}") @@ -34,4 +40,11 @@ if(GMP_INCLUDES) set(GMP_VERSION "${GMP_VERSION_MAJOR}.${GMP_VERSION_MINOR}") message(STATUS "GMP_VERSION_MAJOR : ${GMP_VERSION_MAJOR}") message(STATUS "GMP_VERSION_MINOR : ${GMP_VERSION_MINOR}") -endif() \ No newline at end of file +else() + message(FATAL_ERROR "Could not find GMP") +endif() + +include(FindPackageHandleStandardArgs) +find_package_handle_standard_args(GMP DEFAULT_MSG + GMP_INCLUDES GMP_LIBRARIES) +mark_as_advanced(GMP_INCLUDES GMP_LIBRARIES) \ No newline at end of file diff --git a/doc/CMakeLists.txt b/doc/CMakeLists.txt index 310a90612b..60ddd49ec1 100644 --- a/doc/CMakeLists.txt +++ b/doc/CMakeLists.txt @@ -6,7 +6,6 @@ find_package(Doxygen COMPONENTS dot) if(DOXYGEN_FOUND) set(doxyfile ${CMAKE_CURRENT_BINARY_DIR}/Doxyfile) - configure_file(Doxyfile.in ${doxyfile} USE_SOURCE_PERMISSIONS) # In CMake 3.27, The FindDoxygen module's doxygen_add_docs() # command gained a CONFIG_FILE option to specify a custom doxygen diff --git a/src/secp256k1/src/CMakeLists.txt b/src/secp256k1/src/CMakeLists.txt index 6705451b44..359b5b2746 100644 --- a/src/secp256k1/src/CMakeLists.txt +++ b/src/secp256k1/src/CMakeLists.txt @@ -9,7 +9,7 @@ set_property(TARGET secp256k1 PROPERTY POSITION_INDEPENDENT_CODE ON) target_link_libraries(secp256k1 PUBLIC - gmp + ${GMP_LIBRARIES} PRIVATE OpenSSL::Crypto ) @@ -51,7 +51,11 @@ add_library(secp256k1pp set_property(TARGET secp256k1pp PROPERTY POSITION_INDEPENDENT_CODE ON) target_link_libraries(secp256k1pp - PUBLIC secp256k1 gmp + PUBLIC secp256k1 ${GMP_LIBRARIES} +) + +target_include_directories(secp256k1pp + PUBLIC ${GMP_INCLUDES} ) add_library(secp256k1_asm INTERFACE) @@ -128,18 +132,18 @@ if(SECP256K1_BUILD_BENCHMARK) add_executable(bench_verify bench_verify.c) target_link_libraries(bench_verify PUBLIC secp256k1) add_executable(bench_internal bench_internal.c) - target_link_libraries(bench_internal PUBLIC secp256k1_asm gmp) + target_link_libraries(bench_internal PUBLIC secp256k1_asm ${GMP_LIBRARIES}) endif() if(SECP256K1_BUILD_TESTS) add_executable(noverify_tests tests.c) target_compile_definitions(noverify_tests PRIVATE VERIFY) - target_link_libraries(noverify_tests secp256k1_asm gmp) + target_link_libraries(noverify_tests secp256k1_asm ${GMP_LIBRARIES}) add_test(NAME secp256k1_noverify_tests COMMAND noverify_tests) if(NOT CMAKE_BUILD_TYPE STREQUAL "Coverage") add_executable(tests tests.c) target_compile_definitions(tests PRIVATE VERIFY) - target_link_libraries(tests secp256k1_asm gmp) + target_link_libraries(tests secp256k1_asm ${GMP_LIBRARIES}) add_test(NAME secp256k1_tests COMMAND tests) endif() endif() @@ -147,7 +151,7 @@ endif() if(SECP256K1_BUILD_EXHAUSTIVE_TESTS) # Note: do not include secp256k1_precomputed in exhaustive_tests (it uses runtime-generated tables). add_executable(exhaustive_tests tests_exhaustive.c) - target_link_libraries(exhaustive_tests secp256k1_asm gmp) + target_link_libraries(exhaustive_tests secp256k1_asm ${GMP_LIBRARIES}) target_compile_definitions(exhaustive_tests PRIVATE $<$>:VERIFY>) add_test(NAME secp256k1_exhaustive_tests COMMAND exhaustive_tests) endif()