Search for system secp256k1 before vendoring

This commit is contained in:
Mo Morsi
2019-10-29 21:59:15 -04:00
committed by Nik Bougalis
parent b728bf0d09
commit e4ea3752ac
3 changed files with 86 additions and 29 deletions

View File

@@ -4,7 +4,6 @@
install ( install (
TARGETS TARGETS
secp256k1
ed25519-donna ed25519-donna
common common
opts opts
@@ -16,6 +15,18 @@ install (
ARCHIVE DESTINATION lib ARCHIVE DESTINATION lib
RUNTIME DESTINATION bin RUNTIME DESTINATION bin
INCLUDES DESTINATION include) INCLUDES DESTINATION include)
if(${INSTALL_SECP256K1})
install (
TARGETS
secp256k1
EXPORT RippleExports
LIBRARY DESTINATION lib
ARCHIVE DESTINATION lib
RUNTIME DESTINATION bin
INCLUDES DESTINATION include)
endif()
install (EXPORT RippleExports install (EXPORT RippleExports
FILE RippleTargets.cmake FILE RippleTargets.cmake
NAMESPACE Ripple:: NAMESPACE Ripple::

View File

@@ -0,0 +1,22 @@
find_package (PkgConfig REQUIRED)
pkg_search_module (secp256k1_PC QUIET libsecp256k1)
if(static)
set(SECP256K1_LIB libsecp256k1.a)
else()
set(SECP256K1_LIB secp256k1)
endif()
find_library(secp256k1
NAMES ${SECP256K1_LIB}
HINTS
${secp256k1_PC_LIBDIR}
${secp256k1_PC_LIBRARY_PATHS}
NO_DEFAULT_PATH)
find_path (SECP256K1_INCLUDE_DIR
NAMES secp256k1.h
HINTS
${secp256k1_PC_INCLUDEDIR}
${secp256k1_PC_INCLUDEDIRS}
NO_DEFAULT_PATH)

View File

@@ -2,34 +2,58 @@
NIH dep: secp256k1 NIH dep: secp256k1
#]===================================================================] #]===================================================================]
add_library (secp256k1 STATIC add_library (secp256k1_lib STATIC IMPORTED GLOBAL)
src/secp256k1/src/secp256k1.c)
target_compile_definitions (secp256k1 if (NOT WIN32)
PRIVATE find_package(secp256k1)
USE_NUM_NONE endif()
USE_FIELD_10X26
USE_FIELD_INV_BUILTIN
USE_SCALAR_8X32 if(secp256k1)
USE_SCALAR_INV_BUILTIN) set_target_properties (secp256k1_lib PROPERTIES
target_include_directories (secp256k1 IMPORTED_LOCATION_DEBUG
PUBLIC ${secp256k1}
$<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/src> IMPORTED_LOCATION_RELEASE
$<INSTALL_INTERFACE:include> ${secp256k1}
PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}/src/secp256k1) INTERFACE_INCLUDE_DIRECTORIES
target_compile_options (secp256k1 ${SECP256K1_INCLUDE_DIR})
PRIVATE
$<$<BOOL:${MSVC}>:-wd4319> add_library (secp256k1 ALIAS secp256k1_lib)
$<$<NOT:$<BOOL:${MSVC}>>: add_library (NIH::secp256k1 ALIAS secp256k1_lib)
-Wno-deprecated-declarations
-Wno-unused-function else()
> set(INSTALL_SECP256K1 true)
$<$<BOOL:${is_gcc}>:-Wno-nonnull-compare>)
add_library (NIH::secp256k1 ALIAS secp256k1) add_library (secp256k1 STATIC
target_link_libraries (ripple_libs INTERFACE NIH::secp256k1) src/secp256k1/src/secp256k1.c)
target_compile_definitions (secp256k1
PRIVATE
USE_NUM_NONE
USE_FIELD_10X26
USE_FIELD_INV_BUILTIN
USE_SCALAR_8X32
USE_SCALAR_INV_BUILTIN)
target_include_directories (secp256k1
PUBLIC
$<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/src>
$<INSTALL_INTERFACE:include>
PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}/src/secp256k1)
target_compile_options (secp256k1
PRIVATE
$<$<BOOL:${MSVC}>:-wd4319>
$<$<NOT:$<BOOL:${MSVC}>>:
-Wno-deprecated-declarations
-Wno-unused-function
>
$<$<BOOL:${is_gcc}>:-Wno-nonnull-compare>)
target_link_libraries (ripple_libs INTERFACE NIH::secp256k1)
#[===========================[ #[===========================[
headers installation headers installation
#]===========================] #]===========================]
install ( install (
FILES FILES
src/secp256k1/include/secp256k1.h src/secp256k1/include/secp256k1.h
DESTINATION include/secp256k1/include) DESTINATION include/secp256k1/include)
add_library (NIH::secp256k1 ALIAS secp256k1)
endif()