-
Notifications
You must be signed in to change notification settings - Fork 1k
/
Copy pathCMakeLists.txt
123 lines (108 loc) · 5.34 KB
/
CMakeLists.txt
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
# Copyright 2022 Hennadii Stepanov
# Distributed under the MIT software license, see the accompanying
# file COPYING or https://www.opensource.org/licenses/mit-license.php.
cmake_minimum_required(VERSION 3.1)
if(CMAKE_VERSION VERSION_GREATER 3.14)
# MSVC warning flags are not in CMAKE_<LANG>_FLAGS by default.
# See: https://cmake.org/cmake/help/latest/policy/CMP0092.html
cmake_policy(SET CMP0092 NEW)
endif()
project(secp256k1 VERSION 0.1.0 LANGUAGES C)
set(CMAKE_C_STANDARD 90)
set(CMAKE_C_EXTENSIONS OFF)
option(ENABLE_DEV_MODE "enable all binaries and modules by default but individual options can still be overridden explicitly" OFF)
option(BUILD_BENCHMARK "build benchmarks" ON)
option(BUILD_TESTS "build tests" ON)
option(BUILD_EXHAUSTIVE_TESTS "build exhaustive tests" ON)
option(BUILD_EXAMPLES "build examples" ${ENABLE_DEV_MODE})
option(ENABLE_MODULE_ECDH "enable ECDH module" ${ENABLE_DEV_MODE})
option(ENABLE_MODULE_RECOVERY "enable ECDSA pubkey recovery module" ${ENABLE_DEV_MODE})
option(ENABLE_MODULE_EXTRAKEYS "enable extrakeys module" ${ENABLE_DEV_MODE})
option(ENABLE_MODULE_SCHNORRSIG "enable schnorrsig module" ${ENABLE_DEV_MODE})
option(ALLOW_EXPERIMENTAL "allow experimental configure options" ${ENABLE_DEV_MODE})
option(USE_EXTERNAL_DEFAULT_CALLBACKS "enable external default callback functions" OFF)
option(COVERAGE "enable compiler flags to support coverage analysis" OFF)
set(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]")
if(ECMULT_WINDOW_SIZE STREQUAL auto)
set(ECMULT_WINDOW_SIZE 15)
endif()
if(NOT ECMULT_WINDOW_SIZE MATCHES ^[1-9][0-9]*$ OR ECMULT_WINDOW_SIZE LESS 2 OR ECMULT_WINDOW_SIZE GREATER 24)
message(FATAL_ERROR "ECMULT_WINDOW_SIZE value is \"${ECMULT_WINDOW_SIZE}\", but must an integer in range [2..24] or \"auto\".")
endif()
set(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]")
if(ECMULT_GEN_PREC_BITS STREQUAL auto)
set(ECMULT_GEN_PREC_BITS 4)
endif()
if(NOT ECMULT_GEN_PREC_BITS STREQUAL 2 AND NOT ECMULT_GEN_PREC_BITS STREQUAL 4 AND NOT ECMULT_GEN_PREC_BITS STREQUAL 8)
message(FATAL_ERROR "ECMULT_GEN_PREC_BITS value is \"${ECMULT_GEN_PREC_BITS}\", but must an integer 2, 4, 8, or \"auto\".")
endif()
option(USE_FORCE_WIDEMUL_INT128 "force the use of the (unsigned) __int128 based wide multiplication implementation" OFF)
option(USE_FORCE_WIDEMUL_INT64 "force the use of the (u)int64_t based wide multiplication implementation" OFF)
if (USE_FORCE_WIDEMUL_INT128 AND USE_FORCE_WIDEMUL_INT64)
message(FATAL_ERROR "USE_FORCE_WIDEMUL_INT128 and USE_FORCE_WIDEMUL_INT64 cannot be enabled simultaneously.")
endif()
mark_as_advanced(FORCE
ENABLE_DEV_MODE
USE_FORCE_WIDEMUL_INT128
USE_FORCE_WIDEMUL_INT64
)
configure_file(
"cmake/libsecp256k1-config.h.in"
"${PROJECT_BINARY_DIR}/src/libsecp256k1-config.h"
)
include(cmake/secp_try_append_cflag.cmake)
secp_try_append_cflag(-pedantic)
secp_try_append_cflag(-Wno-long-long)
secp_try_append_cflag(-Wnested-externs)
secp_try_append_cflag(-Wshadow)
secp_try_append_cflag(-Wstrict-prototypes)
secp_try_append_cflag(-Wundef)
secp_try_append_cflag(-Wno-overlength-strings)
secp_try_append_cflag(-Wall)
secp_try_append_cflag(-Wno-unused-function)
secp_try_append_cflag(-Wextra)
secp_try_append_cflag(-Wcast-align)
secp_try_append_cflag(-Wcast-align=strict)
secp_try_append_cflag(-Wconditional-uninitialized)
if(CMAKE_VERSION VERSION_GREATER 3.2)
# Honor visibility properties for all target types.
# See: https://cmake.org/cmake/help/latest/policy/CMP0063.html
cmake_policy(SET CMP0063 NEW)
endif()
set(CMAKE_C_VISIBILITY_PRESET hidden)
set(CMAKE_VISIBILITY_INLINES_HIDDEN 1)
add_subdirectory(src)
message("\n")
message("Configure summary")
message("=================")
if(CMAKE_CROSSCOMPILING)
message("Cross compiling for ${CMAKE_SYSTEM_NAME}, ${CMAKE_SYSTEM_PROCESSOR}")
endif()
message("Optional binaries:")
message(" benchmark ........................ ${BUILD_BENCHMARK}")
message(" tests ............................ ${BUILD_TESTS}")
message(" exhaustive tests ................. ${BUILD_EXHAUSTIVE_TESTS}")
message(" examples ......................... ${BUILD_EXAMPLES}")
message("Optional modules:")
message(" ECDH ............................. ${ENABLE_MODULE_ECDH}")
message(" ECDSA pubkey recovery ............ ${ENABLE_MODULE_RECOVERY}")
message(" extrakeys ........................ ${ENABLE_MODULE_EXTRAKEYS}")
message(" schnorrsig ....................... ${ENABLE_MODULE_SCHNORRSIG}")
message("Parameters:")
message(" ecmult window size ............... ${ECMULT_WINDOW_SIZE}")
message(" ecmult gen precision bits ........ ${ECMULT_GEN_PREC_BITS}")
message("Optional features:")
message(" external callbacks ............... ${USE_EXTERNAL_DEFAULT_CALLBACKS}")
if(BUILD_TESTS OR BUILD_EXHAUSTIVE_TESTS)
message(" support kcov coverage analysis ... ${COVERAGE}")
endif()
if(USE_FORCE_WIDEMUL_INT128)
message(" override wide multiplication ..... int128")
endif()
if(USE_FORCE_WIDEMUL_INT64)
message(" override wide multiplication ..... int64")
endif()
message("\n")
message("CC: ${CMAKE_C_COMPILER}")
message("CFLAGS: ${CMAKE_C_FLAGS}")
message("\n")