|
|
|
|
@@ -1,16 +1,21 @@
|
|
|
|
|
cmake_minimum_required(VERSION 3.13)
|
|
|
|
|
|
|
|
|
|
if(CMAKE_VERSION VERSION_GREATER 3.14)
|
|
|
|
|
if(CMAKE_VERSION VERSION_GREATER_EQUAL 3.15)
|
|
|
|
|
# MSVC runtime library flags are selected by the CMAKE_MSVC_RUNTIME_LIBRARY abstraction.
|
|
|
|
|
cmake_policy(SET CMP0091 NEW)
|
|
|
|
|
# MSVC warning flags are not in CMAKE_<LANG>_FLAGS by default.
|
|
|
|
|
cmake_policy(SET CMP0092 NEW)
|
|
|
|
|
endif()
|
|
|
|
|
|
|
|
|
|
# The package (a.k.a. release) version is based on semantic versioning 2.0.0 of
|
|
|
|
|
# the API. All changes in experimental modules are treated as
|
|
|
|
|
# backwards-compatible and therefore at most increase the minor version.
|
|
|
|
|
project(libsecp256k1 VERSION 0.3.2 LANGUAGES C)
|
|
|
|
|
project(libsecp256k1
|
|
|
|
|
# The package (a.k.a. release) version is based on semantic versioning 2.0.0 of
|
|
|
|
|
# the API. All changes in experimental modules are treated as
|
|
|
|
|
# backwards-compatible and therefore at most increase the minor version.
|
|
|
|
|
VERSION 0.3.2
|
|
|
|
|
DESCRIPTION "Optimized C library for ECDSA signatures and secret/public key operations on curve secp256k1."
|
|
|
|
|
HOMEPAGE_URL "https://github.com/bitcoin-core/secp256k1"
|
|
|
|
|
LANGUAGES C
|
|
|
|
|
)
|
|
|
|
|
|
|
|
|
|
# The library version is based on libtool versioning of the ABI. The set of
|
|
|
|
|
# rules for updating the version can be found here:
|
|
|
|
|
@@ -36,27 +41,27 @@ option(SECP256K1_INSTALL "Enable installation" ON)
|
|
|
|
|
|
|
|
|
|
option(SECP256K1_ENABLE_MODULE_ECDH "Enable ECDH module." ON)
|
|
|
|
|
if(SECP256K1_ENABLE_MODULE_ECDH)
|
|
|
|
|
add_definitions(-DENABLE_MODULE_ECDH=1)
|
|
|
|
|
add_compile_definitions(ENABLE_MODULE_ECDH=1)
|
|
|
|
|
endif()
|
|
|
|
|
|
|
|
|
|
option(SECP256K1_ENABLE_MODULE_RECOVERY "Enable ECDSA pubkey recovery module." OFF)
|
|
|
|
|
if(SECP256K1_ENABLE_MODULE_RECOVERY)
|
|
|
|
|
add_definitions(-DENABLE_MODULE_RECOVERY=1)
|
|
|
|
|
add_compile_definitions(ENABLE_MODULE_RECOVERY=1)
|
|
|
|
|
endif()
|
|
|
|
|
|
|
|
|
|
option(SECP256K1_ENABLE_MODULE_EXTRAKEYS "Enable extrakeys module." ON)
|
|
|
|
|
option(SECP256K1_ENABLE_MODULE_SCHNORRSIG "Enable schnorrsig module." ON)
|
|
|
|
|
if(SECP256K1_ENABLE_MODULE_SCHNORRSIG)
|
|
|
|
|
set(SECP256K1_ENABLE_MODULE_EXTRAKEYS ON)
|
|
|
|
|
add_definitions(-DENABLE_MODULE_SCHNORRSIG=1)
|
|
|
|
|
add_compile_definitions(ENABLE_MODULE_SCHNORRSIG=1)
|
|
|
|
|
endif()
|
|
|
|
|
if(SECP256K1_ENABLE_MODULE_EXTRAKEYS)
|
|
|
|
|
add_definitions(-DENABLE_MODULE_EXTRAKEYS=1)
|
|
|
|
|
add_compile_definitions(ENABLE_MODULE_EXTRAKEYS=1)
|
|
|
|
|
endif()
|
|
|
|
|
|
|
|
|
|
option(SECP256K1_USE_EXTERNAL_DEFAULT_CALLBACKS "Enable external default callback functions." OFF)
|
|
|
|
|
if(SECP256K1_USE_EXTERNAL_DEFAULT_CALLBACKS)
|
|
|
|
|
add_definitions(-DUSE_EXTERNAL_DEFAULT_CALLBACKS=1)
|
|
|
|
|
add_compile_definitions(USE_EXTERNAL_DEFAULT_CALLBACKS=1)
|
|
|
|
|
endif()
|
|
|
|
|
|
|
|
|
|
set(SECP256K1_ECMULT_WINDOW_SIZE "AUTO" CACHE STRING "Window size for ecmult precomputation for verification, specified as integer in range [2..24]. \"AUTO\" is a reasonable setting for desktop machines (currently 15). [default=AUTO]")
|
|
|
|
|
@@ -66,7 +71,7 @@ check_string_option_value(SECP256K1_ECMULT_WINDOW_SIZE)
|
|
|
|
|
if(SECP256K1_ECMULT_WINDOW_SIZE STREQUAL "AUTO")
|
|
|
|
|
set(SECP256K1_ECMULT_WINDOW_SIZE 15)
|
|
|
|
|
endif()
|
|
|
|
|
add_definitions(-DECMULT_WINDOW_SIZE=${SECP256K1_ECMULT_WINDOW_SIZE})
|
|
|
|
|
add_compile_definitions(ECMULT_WINDOW_SIZE=${SECP256K1_ECMULT_WINDOW_SIZE})
|
|
|
|
|
|
|
|
|
|
set(SECP256K1_ECMULT_GEN_PREC_BITS "AUTO" CACHE STRING "Precision bits to tune the precomputed table size for signing, specified as integer 2, 4 or 8. \"AUTO\" is a reasonable setting for desktop machines (currently 4). [default=AUTO]")
|
|
|
|
|
set_property(CACHE SECP256K1_ECMULT_GEN_PREC_BITS PROPERTY STRINGS "AUTO" 2 4 8)
|
|
|
|
|
@@ -74,14 +79,14 @@ check_string_option_value(SECP256K1_ECMULT_GEN_PREC_BITS)
|
|
|
|
|
if(SECP256K1_ECMULT_GEN_PREC_BITS STREQUAL "AUTO")
|
|
|
|
|
set(SECP256K1_ECMULT_GEN_PREC_BITS 4)
|
|
|
|
|
endif()
|
|
|
|
|
add_definitions(-DECMULT_GEN_PREC_BITS=${SECP256K1_ECMULT_GEN_PREC_BITS})
|
|
|
|
|
add_compile_definitions(ECMULT_GEN_PREC_BITS=${SECP256K1_ECMULT_GEN_PREC_BITS})
|
|
|
|
|
|
|
|
|
|
set(SECP256K1_TEST_OVERRIDE_WIDE_MULTIPLY "OFF" CACHE STRING "Test-only override of the (autodetected by the C code) \"widemul\" setting. Legal values are: \"OFF\", \"int128_struct\", \"int128\" or \"int64\". [default=OFF]")
|
|
|
|
|
set_property(CACHE SECP256K1_TEST_OVERRIDE_WIDE_MULTIPLY PROPERTY STRINGS "OFF" "int128_struct" "int128" "int64")
|
|
|
|
|
check_string_option_value(SECP256K1_TEST_OVERRIDE_WIDE_MULTIPLY)
|
|
|
|
|
if(SECP256K1_TEST_OVERRIDE_WIDE_MULTIPLY)
|
|
|
|
|
string(TOUPPER "${SECP256K1_TEST_OVERRIDE_WIDE_MULTIPLY}" widemul_upper_value)
|
|
|
|
|
add_definitions(-DUSE_FORCE_WIDEMUL_${widemul_upper_value}=1)
|
|
|
|
|
add_compile_definitions(USE_FORCE_WIDEMUL_${widemul_upper_value}=1)
|
|
|
|
|
endif()
|
|
|
|
|
mark_as_advanced(FORCE SECP256K1_TEST_OVERRIDE_WIDE_MULTIPLY)
|
|
|
|
|
|
|
|
|
|
@@ -90,13 +95,13 @@ set_property(CACHE SECP256K1_ASM PROPERTY STRINGS "AUTO" "OFF" "x86_64" "arm")
|
|
|
|
|
check_string_option_value(SECP256K1_ASM)
|
|
|
|
|
if(SECP256K1_ASM STREQUAL "arm")
|
|
|
|
|
enable_language(ASM)
|
|
|
|
|
add_definitions(-DUSE_EXTERNAL_ASM=1)
|
|
|
|
|
add_compile_definitions(USE_EXTERNAL_ASM=1)
|
|
|
|
|
elseif(SECP256K1_ASM)
|
|
|
|
|
include(Check64bitAssembly)
|
|
|
|
|
check_64bit_assembly()
|
|
|
|
|
if(HAS_64BIT_ASM)
|
|
|
|
|
set(SECP256K1_ASM "x86_64")
|
|
|
|
|
add_definitions(-DUSE_ASM_X86_64=1)
|
|
|
|
|
add_compile_definitions(USE_ASM_X86_64=1)
|
|
|
|
|
elseif(SECP256K1_ASM STREQUAL "AUTO")
|
|
|
|
|
set(SECP256K1_ASM "OFF")
|
|
|
|
|
else()
|
|
|
|
|
@@ -119,7 +124,7 @@ if(SECP256K1_VALGRIND)
|
|
|
|
|
if(Valgrind_FOUND)
|
|
|
|
|
set(SECP256K1_VALGRIND ON)
|
|
|
|
|
include_directories(${Valgrind_INCLUDE_DIR})
|
|
|
|
|
add_definitions(-DVALGRIND)
|
|
|
|
|
add_compile_definitions(VALGRIND)
|
|
|
|
|
elseif(SECP256K1_VALGRIND STREQUAL "AUTO")
|
|
|
|
|
set(SECP256K1_VALGRIND OFF)
|
|
|
|
|
else()
|
|
|
|
|
@@ -166,21 +171,24 @@ mark_as_advanced(
|
|
|
|
|
CMAKE_SHARED_LINKER_FLAGS_COVERAGE
|
|
|
|
|
)
|
|
|
|
|
|
|
|
|
|
if(CMAKE_CONFIGURATION_TYPES)
|
|
|
|
|
set(CMAKE_CONFIGURATION_TYPES "RelWithDebInfo" "Release" "Debug" "MinSizeRel" "Coverage")
|
|
|
|
|
endif()
|
|
|
|
|
|
|
|
|
|
get_property(cached_cmake_build_type CACHE CMAKE_BUILD_TYPE PROPERTY TYPE)
|
|
|
|
|
if(cached_cmake_build_type)
|
|
|
|
|
set_property(CACHE CMAKE_BUILD_TYPE PROPERTY
|
|
|
|
|
STRINGS "RelWithDebInfo" "Release" "Debug" "MinSizeRel" "Coverage"
|
|
|
|
|
)
|
|
|
|
|
endif()
|
|
|
|
|
|
|
|
|
|
get_property(is_multi_config GLOBAL PROPERTY GENERATOR_IS_MULTI_CONFIG)
|
|
|
|
|
set(default_build_type "RelWithDebInfo")
|
|
|
|
|
if(NOT CMAKE_BUILD_TYPE AND NOT CMAKE_CONFIGURATION_TYPES)
|
|
|
|
|
message(STATUS "Setting build type to \"${default_build_type}\" as none was specified")
|
|
|
|
|
set(CMAKE_BUILD_TYPE "${default_build_type}" CACHE STRING "Choose the type of build." FORCE)
|
|
|
|
|
if(is_multi_config)
|
|
|
|
|
set(CMAKE_CONFIGURATION_TYPES "${default_build_type}" "Release" "Debug" "MinSizeRel" "Coverage" CACHE STRING
|
|
|
|
|
"Supported configuration types."
|
|
|
|
|
FORCE
|
|
|
|
|
)
|
|
|
|
|
else()
|
|
|
|
|
set_property(CACHE CMAKE_BUILD_TYPE PROPERTY
|
|
|
|
|
STRINGS "${default_build_type}" "Release" "Debug" "MinSizeRel" "Coverage"
|
|
|
|
|
)
|
|
|
|
|
if(NOT CMAKE_BUILD_TYPE)
|
|
|
|
|
message(STATUS "Setting build type to \"${default_build_type}\" as none was specified")
|
|
|
|
|
set(CMAKE_BUILD_TYPE "${default_build_type}" CACHE STRING
|
|
|
|
|
"Choose the type of build."
|
|
|
|
|
FORCE
|
|
|
|
|
)
|
|
|
|
|
endif()
|
|
|
|
|
endif()
|
|
|
|
|
|
|
|
|
|
include(TryAddCompileOption)
|
|
|
|
|
@@ -274,7 +282,7 @@ message("CFLAGS ................................ ${CMAKE_C_FLAGS}")
|
|
|
|
|
get_directory_property(compile_options COMPILE_OPTIONS)
|
|
|
|
|
string(REPLACE ";" " " compile_options "${compile_options}")
|
|
|
|
|
message("Compile options ....................... " ${compile_options})
|
|
|
|
|
if(DEFINED CMAKE_BUILD_TYPE)
|
|
|
|
|
if(NOT is_multi_config)
|
|
|
|
|
message("Build type:")
|
|
|
|
|
message(" - CMAKE_BUILD_TYPE ................... ${CMAKE_BUILD_TYPE}")
|
|
|
|
|
string(TOUPPER "${CMAKE_BUILD_TYPE}" build_type)
|
|
|
|
|
@@ -282,7 +290,7 @@ if(DEFINED CMAKE_BUILD_TYPE)
|
|
|
|
|
message(" - LDFLAGS for executables ............ ${CMAKE_EXE_LINKER_FLAGS_${build_type}}")
|
|
|
|
|
message(" - LDFLAGS for shared libraries ....... ${CMAKE_SHARED_LINKER_FLAGS_${build_type}}")
|
|
|
|
|
else()
|
|
|
|
|
message("Available configurations .............. ${CMAKE_CONFIGURATION_TYPES}")
|
|
|
|
|
message("Supported configurations .............. ${CMAKE_CONFIGURATION_TYPES}")
|
|
|
|
|
message("RelWithDebInfo configuration:")
|
|
|
|
|
message(" - CFLAGS ............................. ${CMAKE_C_FLAGS_RELWITHDEBINFO}")
|
|
|
|
|
message(" - LDFLAGS for executables ............ ${CMAKE_EXE_LINKER_FLAGS_RELWITHDEBINFO}")
|
|
|
|
|
|