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,6 +2,28 @@
NIH dep: secp256k1 NIH dep: secp256k1
#]===================================================================] #]===================================================================]
add_library (secp256k1_lib STATIC IMPORTED GLOBAL)
if (NOT WIN32)
find_package(secp256k1)
endif()
if(secp256k1)
set_target_properties (secp256k1_lib PROPERTIES
IMPORTED_LOCATION_DEBUG
${secp256k1}
IMPORTED_LOCATION_RELEASE
${secp256k1}
INTERFACE_INCLUDE_DIRECTORIES
${SECP256K1_INCLUDE_DIR})
add_library (secp256k1 ALIAS secp256k1_lib)
add_library (NIH::secp256k1 ALIAS secp256k1_lib)
else()
set(INSTALL_SECP256K1 true)
add_library (secp256k1 STATIC add_library (secp256k1 STATIC
src/secp256k1/src/secp256k1.c) src/secp256k1/src/secp256k1.c)
target_compile_definitions (secp256k1 target_compile_definitions (secp256k1
@@ -24,7 +46,6 @@ target_compile_options (secp256k1
-Wno-unused-function -Wno-unused-function
> >
$<$<BOOL:${is_gcc}>:-Wno-nonnull-compare>) $<$<BOOL:${is_gcc}>:-Wno-nonnull-compare>)
add_library (NIH::secp256k1 ALIAS secp256k1)
target_link_libraries (ripple_libs INTERFACE NIH::secp256k1) target_link_libraries (ripple_libs INTERFACE NIH::secp256k1)
#[===========================[ #[===========================[
headers installation headers installation
@@ -33,3 +54,6 @@ 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()