Skip to content

Commit 5c67a00

Browse files
author
Richard Fric
committed
Use cmake for secp256k1 build
1 parent 80d9b98 commit 5c67a00

File tree

1 file changed

+8
-43
lines changed

1 file changed

+8
-43
lines changed

CMakeLists.txt

Lines changed: 8 additions & 43 deletions
Original file line numberDiff line numberDiff line change
@@ -38,56 +38,21 @@ SET( CMAKE_DEBUG_POSTFIX _debug )
3838
SET( BUILD_SHARED_LIBS NO )
3939

4040
# Configure secp256k1-zkp
41-
if ( WIN32 )
42-
# autoconf won't work here, hard code the defines
43-
set( SECP256K1_DIR "${CMAKE_CURRENT_SOURCE_DIR}/vendor/secp256k1-zkp" )
44-
45-
file( GLOB SECP256K1_SOURCES "${SECP256K1_DIR}/src/secp256k1.c" )
46-
add_library( secp256k1 ${SECP256K1_SOURCES} )
47-
48-
target_include_directories( secp256k1 PRIVATE "${SECP256K1_DIR}" PUBLIC "${SECP256K1_DIR}/include" )
49-
50-
set( SECP256K1_BUILD_DEFINES
51-
USE_FIELD_10X26
52-
USE_FIELD_INV_BUILTIN
53-
USE_NUM_NONE
54-
USE_SCALAR_8X32
55-
USE_SCALAR_INV_BUILTIN )
56-
set_target_properties( secp256k1 PROPERTIES COMPILE_DEFINITIONS "${SECP256K1_BUILD_DEFINES}" LINKER_LANGUAGE C )
57-
else ( WIN32 )
58-
include(ExternalProject)
59-
ExternalProject_Add( project_secp256k1
60-
PREFIX ${CMAKE_CURRENT_BINARY_DIR}/vendor/secp256k1-zkp
61-
SOURCE_DIR ${CMAKE_CURRENT_SOURCE_DIR}/vendor/secp256k1-zkp
62-
CONFIGURE_COMMAND ${CMAKE_CURRENT_SOURCE_DIR}/vendor/secp256k1-zkp/configure --prefix=${CMAKE_CURRENT_BINARY_DIR}/vendor/secp256k1-zkp --with-bignum=no --with-pic=yes
63-
BUILD_COMMAND make
64-
INSTALL_COMMAND true
65-
BUILD_BYPRODUCTS ${CMAKE_CURRENT_BINARY_DIR}/vendor/secp256k1-zkp/src/project_secp256k1-build/.libs/libsecp256k1.a
66-
)
67-
ExternalProject_Add_Step(project_secp256k1 autogen
68-
WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}/vendor/secp256k1-zkp
69-
COMMAND ${CMAKE_CURRENT_SOURCE_DIR}/vendor/secp256k1-zkp/autogen.sh
70-
DEPENDERS configure
71-
)
72-
73-
ExternalProject_Get_Property(project_secp256k1 binary_dir)
74-
75-
add_library(secp256k1 STATIC IMPORTED)
76-
set_property(TARGET secp256k1 PROPERTY IMPORTED_LOCATION ${binary_dir}/.libs/libsecp256k1${CMAKE_STATIC_LIBRARY_SUFFIX})
77-
set_property(TARGET secp256k1 PROPERTY INTERFACE_INCLUDE_DIRECTORIES ${CMAKE_CURRENT_SOURCE_DIR}/vendor/secp256k1-zkp/include)
78-
add_dependencies(secp256k1 project_secp256k1)
79-
endif ( WIN32 )
80-
# End configure secp256k1-zkp
41+
set( SECP256K1_DIR "${CMAKE_CURRENT_SOURCE_DIR}/vendor/secp256k1-zkp" )
42+
file( GLOB SECP256K1_HEADERS "${SECP256K1_DIR}/*.h" "${SECP256K1_DIR}/include/*.h" )
43+
add_library( secp256k1 "${SECP256K1_DIR}/src/secp256k1.c" ${SECP256K1_HEADERS} )
8144

82-
IF( WIN32 )
45+
target_include_directories( secp256k1 PRIVATE "${SECP256K1_DIR}" PUBLIC "${SECP256K1_DIR}/include" )
46+
47+
IF(WIN32)
8348
MESSAGE(STATUS "Configuring fc to build on Win32")
8449

50+
target_compile_definitions( secp256k1 PRIVATE USE_FIELD_10X26 USE_FIELD_INV_BUILTIN USE_NUM_NONE USE_SCALAR_8X32 USE_SCALAR_INV_BUILTIN )
8551
set( PLATFORM_SPECIFIC_LIBS WS2_32.lib Userenv.lib crypt32.lib )
86-
# iphlpapi.lib
87-
8852
ELSE(WIN32)
8953
MESSAGE(STATUS "Configuring fc to build on Unix/Apple")
9054

55+
target_compile_definitions( secp256k1 PRIVATE HAVE___INT128 USE_FIELD_5X52 USE_FIELD_INV_BUILTIN USE_NUM_NONE USE_SCALAR_4X64 USE_SCALAR_INV_BUILTIN )
9156
ENDIF(WIN32)
9257

9358
IF(NOT "$ENV{OPENSSL_ROOT_DIR}" STREQUAL "")

0 commit comments

Comments
 (0)