mirror of
https://github.com/eosswedenorg/libantelope
synced 2026-06-18 20:40:03 +02:00
CMakeLists.txt: Add support for compiling with either openssl or libsecp256k1 as EC library
This commit is contained in:
parent
54fc8614ef
commit
f920c7edee
1 changed files with 27 additions and 7 deletions
|
|
@ -38,6 +38,11 @@ set( CMAKE_CXX_EXTENSIONS OFF )
|
||||||
# Adding this flag makes the compiler not spam warnings.
|
# Adding this flag makes the compiler not spam warnings.
|
||||||
add_compile_options(-D OPENSSL_API_COMPAT=0x10100000L)
|
add_compile_options(-D OPENSSL_API_COMPAT=0x10100000L)
|
||||||
|
|
||||||
|
# --------------------------------
|
||||||
|
# Options
|
||||||
|
# --------------------------------
|
||||||
|
set(EC_LIB "libsecp256k1" CACHE STRING "What elliptic curve implementation to use")
|
||||||
|
|
||||||
# --------------------------------
|
# --------------------------------
|
||||||
# Library
|
# Library
|
||||||
# --------------------------------
|
# --------------------------------
|
||||||
|
|
@ -48,17 +53,31 @@ set( LIB_SOURCE
|
||||||
src/base58.cpp
|
src/base58.cpp
|
||||||
src/ec.cpp
|
src/ec.cpp
|
||||||
src/WIF.cpp
|
src/WIF.cpp
|
||||||
|
|
||||||
|
src/openssl/hash.cpp
|
||||||
)
|
)
|
||||||
|
|
||||||
# OpenSSL
|
# OpenSSL
|
||||||
include(OpenSSL)
|
include(OpenSSL)
|
||||||
set (LIB_SOURCE ${LIB_SOURCE}
|
|
||||||
src/openssl/ec.cpp
|
# EC Implementation
|
||||||
src/openssl/ecdsa.cpp
|
if (${EC_LIB} STREQUAL "libsecp256k1")
|
||||||
src/openssl/hash.cpp
|
add_subdirectory( vendor/secp256k1 )
|
||||||
src/openssl/helpers.c
|
# Note: this is a big hack to get cmake to not export this library.
|
||||||
src/openssl/recovery.c
|
# Must be a better way, but works so cba.
|
||||||
)
|
LIST(APPEND LIB_PRIVATE_INCLUDE $<BUILD_INTERFACE:$<TARGET_PROPERTY:secp256k1,INCLUDE_DIRECTORIES>>)
|
||||||
|
LIST(APPEND LIB_SOURCE src/libsecp256k1/ec.cpp $<TARGET_OBJECTS:secp256k1>)
|
||||||
|
|
||||||
|
elseif (${EC_LIB} STREQUAL "openssl")
|
||||||
|
LIST(APPEND LIB_SOURCE
|
||||||
|
src/openssl/ec.cpp
|
||||||
|
src/openssl/ecdsa.cpp
|
||||||
|
src/openssl/helpers.c
|
||||||
|
src/openssl/recovery.c
|
||||||
|
)
|
||||||
|
else()
|
||||||
|
message(FATAL_ERROR "Invalid ec implementation: " ${EC_LIB})
|
||||||
|
endif()
|
||||||
|
|
||||||
add_library( ${LIB_NAME} STATIC ${LIB_SOURCE} )
|
add_library( ${LIB_NAME} STATIC ${LIB_SOURCE} )
|
||||||
|
|
||||||
|
|
@ -73,6 +92,7 @@ target_link_libraries( ${LIB_NAME}
|
||||||
)
|
)
|
||||||
|
|
||||||
target_include_directories( ${LIB_NAME}
|
target_include_directories( ${LIB_NAME}
|
||||||
|
PRIVATE ${LIB_PRIVATE_INCLUDE}
|
||||||
PUBLIC
|
PUBLIC
|
||||||
$<BUILD_INTERFACE:${CMAKE_CURRENT_LIST_DIR}/include>
|
$<BUILD_INTERFACE:${CMAKE_CURRENT_LIST_DIR}/include>
|
||||||
$<INSTALL_INTERFACE:include>
|
$<INSTALL_INTERFACE:include>
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue