Skip to content

Commit d47e4d4

Browse files
committed
Merge #252: Upstream PRs 1113, 1225, 1227, 1229, 1223
b40adf2 release: prepare for 0.3.0 (Jonas Nick) 8be82d4 cmake: Rename project to "libsecp256k1" (Hennadii Stepanov) 756b61d readme: Use correct build type in CMake/Windows build instructions (Tim Ruffing) 92098d8 changelog: Add entry for CMake (Tim Ruffing) e1eb337 ci: Add "x86_64: Windows (VS 2022)" task (Hennadii Stepanov) 10602b0 cmake: Export config files (Hennadii Stepanov) 5468d70 build: Add CMake-based build system (Hennadii Stepanov) Pull request description: ACKs for top commit: real-or-random: utACK dc73359 Tree-SHA512: ded76837ee78d3a99daf5e9dbdb3912a1f7efb8b9ea329535e5b5452f8bf6d02bc290dd2378b17a20e1d33b4811c1d88482bf46a57d6c414855b64cf55e38e99
2 parents 3937cef + dc73359 commit d47e4d4

13 files changed

+629
-3
lines changed

.cirrus.yml

+27
Original file line numberDiff line numberDiff line change
@@ -429,3 +429,30 @@ task:
429429
test_script:
430430
- cd sage
431431
- sage prove_group_implementations.sage
432+
433+
task:
434+
name: "x86_64: Windows (VS 2022)"
435+
windows_container:
436+
image: cirrusci/windowsservercore:visualstudio2022
437+
cpu: 4
438+
memory: 3840MB
439+
env:
440+
PATH: '%CIRRUS_WORKING_DIR%\build\src\RelWithDebInfo;%PATH%'
441+
x64_NATIVE_TOOLS: '"C:\Program Files (x86)\Microsoft Visual Studio\2022\BuildTools\VC\Auxiliary\Build\vcvars64.bat"'
442+
# Ignore MSBuild warning MSB8029.
443+
# See: https://learn.microsoft.com/en-us/visualstudio/msbuild/errors/msb8029?view=vs-2022
444+
IgnoreWarnIntDirInTempDetected: 'true'
445+
merge_script:
446+
- PowerShell -NoLogo -Command if ($env:CIRRUS_PR -ne $null) { git fetch $env:CIRRUS_REPO_CLONE_URL pull/$env:CIRRUS_PR/merge; git reset --hard FETCH_HEAD; }
447+
configure_script:
448+
- '%x64_NATIVE_TOOLS%'
449+
- cmake -G "Visual Studio 17 2022" -A x64 -S . -B build -DSECP256K1_ENABLE_MODULE_RECOVERY=ON -DSECP256K1_BUILD_EXAMPLES=ON
450+
build_script:
451+
- '%x64_NATIVE_TOOLS%'
452+
- cmake --build build --config RelWithDebInfo -- -property:UseMultiToolTask=true;CL_MPcount=5
453+
check_script:
454+
- '%x64_NATIVE_TOOLS%'
455+
- ctest --test-dir build -j 5
456+
- build\src\RelWithDebInfo\bench_ecmult.exe
457+
- build\src\RelWithDebInfo\bench_internal.exe
458+
- build\src\RelWithDebInfo\bench.exe

.gitignore

+3
Original file line numberDiff line numberDiff line change
@@ -66,3 +66,6 @@ libsecp256k1.pc
6666
contrib/gh-pr-create.sh
6767

6868
musig_example
69+
70+
# Default CMake build directory.
71+
/build

CHANGELOG.md

+11-3
Original file line numberDiff line numberDiff line change
@@ -10,9 +10,12 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
1010

1111
## [Unreleased]
1212

13+
## [0.3.0] - 2023-03-08
14+
1315
#### Added
16+
- Added experimental support for CMake builds. Traditional GNU Autotools builds (`./configure` and `make`) remain fully supported.
1417
- Usage examples: Added a recommended method for securely clearing sensitive data, e.g., secret keys, from memory.
15-
- Tests: Added a new test binary `noverify_tests`. This binary runs the tests without some additional checks present in the ordinary `tests` binary and is thereby closer to production binaries. The `noverify_tests` binary is automatically run as part of the `make check` target.
18+
- Tests: Added a new test binary `noverify_tests`. This binary runs the tests without some additional checks present in the ordinary `tests` binary and is thereby closer to production binaries. The `noverify_tests` binary is automatically run as part of the `make check` target.
1619

1720
#### Fixed
1821
- Fixed declarations of API variables for MSVC (`__declspec(dllimport)`). This fixes MSVC builds of programs which link against a libsecp256k1 DLL dynamically and use API variables (and not only API functions). Unfortunately, the MSVC linker now will emit warning `LNK4217` when trying to link against libsecp256k1 statically. Pass `/ignore:4217` to the linker to suppress this warning.
@@ -22,7 +25,11 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
2225
- Forbade randomizing (copies of) `secp256k1_context_static`. Randomizing a copy of `secp256k1_context_static` did not have any effect and did not provide defense-in-depth protection against side-channel attacks. Create a new context if you want to benefit from randomization.
2326

2427
#### Removed
25-
- Removed the configuration header `src/libsecp256k1-config.h`. We recommend passing flags to `./configure` to set configuration options (see `./configure --help`). If you cannot or do not want to use `./configure`, pass configuration flags such as `-DSECP256K1_ENABLE_MODULE_SCHNORRSIG` manually to the compiler (see the file `configure.ac` for supported flags).
28+
- Removed the configuration header `src/libsecp256k1-config.h`. We recommend passing flags to `./configure` or `cmake` to set configuration options (see `./configure --help` or `cmake -LH`). If you cannot or do not want to use one of the supported build systems, pass configuration flags such as `-DSECP256K1_ENABLE_MODULE_SCHNORRSIG` manually to the compiler (see the file `configure.ac` for supported flags).
29+
30+
#### ABI Compatibility
31+
32+
Due to changes in the API regarding `secp256k1_context_static` described above, the ABI is *not* compatible with previous versions.
2633

2734
## [0.2.0] - 2022-12-12
2835

@@ -51,6 +58,7 @@ This version was in fact never released.
5158
The number was given by the build system since the introduction of autotools in Jan 2014 (ea0fe5a5bf0c04f9cc955b2966b614f5f378c6f6).
5259
Therefore, this version number does not uniquely identify a set of source files.
5360

54-
[unreleased]: https://github.com/bitcoin-core/secp256k1/compare/v0.2.0...HEAD
61+
[unreleased]: https://github.com/bitcoin-core/secp256k1/compare/v0.3.0...HEAD
62+
[0.3.0]: https://github.com/bitcoin-core/secp256k1/compare/v0.2.0...v0.3.0
5563
[0.2.0]: https://github.com/bitcoin-core/secp256k1/compare/423b6d19d373f1224fd671a982584d7e7900bc93..v0.2.0
5664
[0.1.0]: https://github.com/bitcoin-core/secp256k1/commit/423b6d19d373f1224fd671a982584d7e7900bc93

CMakeLists.txt

+302
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,302 @@
1+
cmake_minimum_required(VERSION 3.1)
2+
3+
if(CMAKE_VERSION VERSION_GREATER 3.14)
4+
# MSVC runtime library flags are selected by the CMAKE_MSVC_RUNTIME_LIBRARY abstraction.
5+
cmake_policy(SET CMP0091 NEW)
6+
# MSVC warning flags are not in CMAKE_<LANG>_FLAGS by default.
7+
cmake_policy(SET CMP0092 NEW)
8+
endif()
9+
10+
# The package (a.k.a. release) version is based on semantic versioning 2.0.0 of
11+
# the API. All changes in experimental modules are treated as
12+
# backwards-compatible and therefore at most increase the minor version.
13+
project(libsecp256k1 VERSION 0.3.0 LANGUAGES C)
14+
15+
# The library version is based on libtool versioning of the ABI. The set of
16+
# rules for updating the version can be found here:
17+
# https://www.gnu.org/software/libtool/manual/html_node/Updating-version-info.html
18+
# All changes in experimental modules are treated as if they don't affect the
19+
# interface and therefore only increase the revision.
20+
set(${PROJECT_NAME}_LIB_VERSION_CURRENT 2)
21+
set(${PROJECT_NAME}_LIB_VERSION_REVISION 0)
22+
set(${PROJECT_NAME}_LIB_VERSION_AGE 0)
23+
24+
set(CMAKE_C_STANDARD 90)
25+
set(CMAKE_C_EXTENSIONS OFF)
26+
27+
list(APPEND CMAKE_MODULE_PATH ${PROJECT_SOURCE_DIR}/cmake)
28+
29+
# We do not use CMake's BUILD_SHARED_LIBS option.
30+
option(SECP256K1_BUILD_SHARED "Build shared library." ON)
31+
option(SECP256K1_BUILD_STATIC "Build static library." ON)
32+
if(NOT SECP256K1_BUILD_SHARED AND NOT SECP256K1_BUILD_STATIC)
33+
message(FATAL_ERROR "At least one of SECP256K1_BUILD_SHARED and SECP256K1_BUILD_STATIC must be enabled.")
34+
endif()
35+
36+
option(SECP256K1_ENABLE_MODULE_ECDH "Enable ECDH module." ON)
37+
if(SECP256K1_ENABLE_MODULE_ECDH)
38+
add_definitions(-DENABLE_MODULE_ECDH=1)
39+
endif()
40+
41+
option(SECP256K1_ENABLE_MODULE_RECOVERY "Enable ECDSA pubkey recovery module." OFF)
42+
if(SECP256K1_ENABLE_MODULE_RECOVERY)
43+
add_definitions(-DENABLE_MODULE_RECOVERY=1)
44+
endif()
45+
46+
option(SECP256K1_ENABLE_MODULE_EXTRAKEYS "Enable extrakeys module." ON)
47+
option(SECP256K1_ENABLE_MODULE_SCHNORRSIG "Enable schnorrsig module." ON)
48+
if(SECP256K1_ENABLE_MODULE_SCHNORRSIG)
49+
set(SECP256K1_ENABLE_MODULE_EXTRAKEYS ON)
50+
add_definitions(-DENABLE_MODULE_SCHNORRSIG=1)
51+
endif()
52+
if(SECP256K1_ENABLE_MODULE_EXTRAKEYS)
53+
add_definitions(-DENABLE_MODULE_EXTRAKEYS=1)
54+
endif()
55+
56+
option(SECP256K1_USE_EXTERNAL_DEFAULT_CALLBACKS "Enable external default callback functions." OFF)
57+
if(SECP256K1_USE_EXTERNAL_DEFAULT_CALLBACKS)
58+
add_definitions(-DUSE_EXTERNAL_DEFAULT_CALLBACKS=1)
59+
endif()
60+
61+
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]")
62+
set_property(CACHE SECP256K1_ECMULT_WINDOW_SIZE PROPERTY STRINGS "AUTO" 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24)
63+
include(CheckStringOptionValue)
64+
check_string_option_value(SECP256K1_ECMULT_WINDOW_SIZE)
65+
if(SECP256K1_ECMULT_WINDOW_SIZE STREQUAL "AUTO")
66+
set(SECP256K1_ECMULT_WINDOW_SIZE 15)
67+
endif()
68+
add_definitions(-DECMULT_WINDOW_SIZE=${SECP256K1_ECMULT_WINDOW_SIZE})
69+
70+
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]")
71+
set_property(CACHE SECP256K1_ECMULT_GEN_PREC_BITS PROPERTY STRINGS "AUTO" 2 4 8)
72+
check_string_option_value(SECP256K1_ECMULT_GEN_PREC_BITS)
73+
if(SECP256K1_ECMULT_GEN_PREC_BITS STREQUAL "AUTO")
74+
set(SECP256K1_ECMULT_GEN_PREC_BITS 4)
75+
endif()
76+
add_definitions(-DECMULT_GEN_PREC_BITS=${SECP256K1_ECMULT_GEN_PREC_BITS})
77+
78+
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]")
79+
set_property(CACHE SECP256K1_TEST_OVERRIDE_WIDE_MULTIPLY PROPERTY STRINGS "OFF" "int128_struct" "int128" "int64")
80+
check_string_option_value(SECP256K1_TEST_OVERRIDE_WIDE_MULTIPLY)
81+
if(SECP256K1_TEST_OVERRIDE_WIDE_MULTIPLY)
82+
string(TOUPPER "${SECP256K1_TEST_OVERRIDE_WIDE_MULTIPLY}" widemul_upper_value)
83+
add_definitions(-DUSE_FORCE_WIDEMUL_${widemul_upper_value}=1)
84+
endif()
85+
mark_as_advanced(FORCE SECP256K1_TEST_OVERRIDE_WIDE_MULTIPLY)
86+
87+
set(SECP256K1_ASM "AUTO" CACHE STRING "Assembly optimizations to use: \"AUTO\", \"OFF\", \"x86_64\" or \"arm\" (experimental). [default=AUTO]")
88+
set_property(CACHE SECP256K1_ASM PROPERTY STRINGS "AUTO" "OFF" "x86_64" "arm")
89+
check_string_option_value(SECP256K1_ASM)
90+
if(SECP256K1_ASM STREQUAL "arm")
91+
enable_language(ASM)
92+
add_definitions(-DUSE_EXTERNAL_ASM=1)
93+
elseif(SECP256K1_ASM)
94+
include(Check64bitAssembly)
95+
check_64bit_assembly()
96+
if(HAS_64BIT_ASM)
97+
set(SECP256K1_ASM "x86_64")
98+
add_definitions(-DUSE_ASM_X86_64=1)
99+
elseif(SECP256K1_ASM STREQUAL "AUTO")
100+
set(SECP256K1_ASM "OFF")
101+
else()
102+
message(FATAL_ERROR "x86_64 assembly optimization requested but not available.")
103+
endif()
104+
endif()
105+
106+
option(SECP256K1_EXPERIMENTAL "Allow experimental configuration options." OFF)
107+
if(NOT SECP256K1_EXPERIMENTAL)
108+
if(SECP256K1_ASM STREQUAL "arm")
109+
message(FATAL_ERROR "ARM assembly optimization is experimental. Use -DSECP256K1_EXPERIMENTAL=ON to allow.")
110+
endif()
111+
endif()
112+
113+
set(SECP256K1_VALGRIND "AUTO" CACHE STRING "Build with extra checks for running inside Valgrind. [default=AUTO]")
114+
set_property(CACHE SECP256K1_VALGRIND PROPERTY STRINGS "AUTO" "OFF" "ON")
115+
check_string_option_value(SECP256K1_VALGRIND)
116+
if(SECP256K1_VALGRIND)
117+
find_package(Valgrind MODULE)
118+
if(Valgrind_FOUND)
119+
set(SECP256K1_VALGRIND ON)
120+
include_directories(${Valgrind_INCLUDE_DIR})
121+
add_definitions(-DVALGRIND)
122+
elseif(SECP256K1_VALGRIND STREQUAL "AUTO")
123+
set(SECP256K1_VALGRIND OFF)
124+
else()
125+
message(FATAL_ERROR "Valgrind support requested but valgrind/memcheck.h header not available.")
126+
endif()
127+
endif()
128+
129+
option(SECP256K1_BUILD_BENCHMARK "Build benchmarks." ON)
130+
option(SECP256K1_BUILD_TESTS "Build tests." ON)
131+
option(SECP256K1_BUILD_EXHAUSTIVE_TESTS "Build exhaustive tests." ON)
132+
option(SECP256K1_BUILD_CTIME_TESTS "Build constant-time tests." ${SECP256K1_VALGRIND})
133+
option(SECP256K1_BUILD_EXAMPLES "Build examples." OFF)
134+
135+
# Redefine configuration flags.
136+
# We leave assertions on, because they are only used in the examples, and we want them always on there.
137+
if(MSVC)
138+
string(REGEX REPLACE "/DNDEBUG[ \t\r\n]*" "" CMAKE_C_FLAGS_RELWITHDEBINFO "${CMAKE_C_FLAGS_RELWITHDEBINFO}")
139+
string(REGEX REPLACE "/DNDEBUG[ \t\r\n]*" "" CMAKE_C_FLAGS_RELEASE "${CMAKE_C_FLAGS_RELEASE}")
140+
string(REGEX REPLACE "/DNDEBUG[ \t\r\n]*" "" CMAKE_C_FLAGS_MINSIZEREL "${CMAKE_C_FLAGS_MINSIZEREL}")
141+
else()
142+
string(REGEX REPLACE "-DNDEBUG[ \t\r\n]*" "" CMAKE_C_FLAGS_RELWITHDEBINFO "${CMAKE_C_FLAGS_RELWITHDEBINFO}")
143+
string(REGEX REPLACE "-DNDEBUG[ \t\r\n]*" "" CMAKE_C_FLAGS_RELEASE "${CMAKE_C_FLAGS_RELEASE}")
144+
string(REGEX REPLACE "-DNDEBUG[ \t\r\n]*" "" CMAKE_C_FLAGS_MINSIZEREL "${CMAKE_C_FLAGS_MINSIZEREL}")
145+
# Prefer -O2 optimization level. (-O3 is CMake's default for Release for many compilers.)
146+
string(REGEX REPLACE "-O3[ \t\r\n]*" "-O2" CMAKE_C_FLAGS_RELEASE "${CMAKE_C_FLAGS_RELEASE}")
147+
endif()
148+
149+
# Define custom "Coverage" build type.
150+
set(CMAKE_C_FLAGS_COVERAGE "${CMAKE_C_FLAGS_RELWITHDEBINFO} -O0 -DCOVERAGE=1 --coverage -Wno-unused-parameter" CACHE STRING
151+
"Flags used by the C compiler during \"Coverage\" builds."
152+
FORCE
153+
)
154+
set(CMAKE_EXE_LINKER_FLAGS_COVERAGE "${CMAKE_EXE_LINKER_FLAGS_RELWITHDEBINFO} --coverage" CACHE STRING
155+
"Flags used for linking binaries during \"Coverage\" builds."
156+
FORCE
157+
)
158+
set(CMAKE_SHARED_LINKER_FLAGS_COVERAGE "${CMAKE_SHARED_LINKER_FLAGS_RELWITHDEBINFO} --coverage" CACHE STRING
159+
"Flags used by the shared libraries linker during \"Coverage\" builds."
160+
FORCE
161+
)
162+
mark_as_advanced(
163+
CMAKE_C_FLAGS_COVERAGE
164+
CMAKE_EXE_LINKER_FLAGS_COVERAGE
165+
CMAKE_SHARED_LINKER_FLAGS_COVERAGE
166+
)
167+
168+
if(CMAKE_CONFIGURATION_TYPES)
169+
set(CMAKE_CONFIGURATION_TYPES "RelWithDebInfo" "Release" "Debug" "MinSizeRel" "Coverage")
170+
endif()
171+
172+
get_property(cached_cmake_build_type CACHE CMAKE_BUILD_TYPE PROPERTY TYPE)
173+
if(cached_cmake_build_type)
174+
set_property(CACHE CMAKE_BUILD_TYPE PROPERTY
175+
STRINGS "RelWithDebInfo" "Release" "Debug" "MinSizeRel" "Coverage"
176+
)
177+
endif()
178+
179+
set(default_build_type "RelWithDebInfo")
180+
if(NOT CMAKE_BUILD_TYPE AND NOT CMAKE_CONFIGURATION_TYPES)
181+
message(STATUS "Setting build type to \"${default_build_type}\" as none was specified")
182+
set(CMAKE_BUILD_TYPE "${default_build_type}" CACHE STRING "Choose the type of build." FORCE)
183+
endif()
184+
185+
include(TryAddCompileOption)
186+
if(MSVC)
187+
try_add_compile_option(/W2)
188+
try_add_compile_option(/wd4146)
189+
else()
190+
try_add_compile_option(-pedantic)
191+
try_add_compile_option(-Wall)
192+
try_add_compile_option(-Wcast-align)
193+
try_add_compile_option(-Wcast-align=strict)
194+
try_add_compile_option(-Wconditional-uninitialized)
195+
try_add_compile_option(-Wextra)
196+
try_add_compile_option(-Wnested-externs)
197+
try_add_compile_option(-Wno-long-long)
198+
try_add_compile_option(-Wno-overlength-strings)
199+
try_add_compile_option(-Wno-unused-function)
200+
try_add_compile_option(-Wreserved-identifier)
201+
try_add_compile_option(-Wshadow)
202+
try_add_compile_option(-Wstrict-prototypes)
203+
try_add_compile_option(-Wundef)
204+
endif()
205+
206+
if(CMAKE_VERSION VERSION_GREATER 3.2)
207+
# Honor visibility properties for all target types.
208+
# See: https://cmake.org/cmake/help/latest/policy/CMP0063.html
209+
cmake_policy(SET CMP0063 NEW)
210+
endif()
211+
set(CMAKE_C_VISIBILITY_PRESET hidden)
212+
213+
# Ask CTest to create a "check" target (e.g., make check) as alias for the "test" target.
214+
# CTEST_TEST_TARGET_ALIAS is not documented but supposed to be user-facing.
215+
# See: https://gitlab.kitware.com/cmake/cmake/-/commit/816c9d1aa1f2b42d40c81a991b68c96eb12b6d2
216+
set(CTEST_TEST_TARGET_ALIAS check)
217+
include(CTest)
218+
# We do not use CTest's BUILD_TESTING because a single toggle for all tests is too coarse for our needs.
219+
mark_as_advanced(BUILD_TESTING)
220+
if(SECP256K1_BUILD_BENCHMARK OR SECP256K1_BUILD_TESTS OR SECP256K1_BUILD_EXHAUSTIVE_TESTS OR SECP256K1_BUILD_CTIME_TESTS OR SECP256K1_BUILD_EXAMPLES)
221+
enable_testing()
222+
endif()
223+
224+
add_subdirectory(src)
225+
if(SECP256K1_BUILD_EXAMPLES)
226+
add_subdirectory(examples)
227+
endif()
228+
229+
message("\n")
230+
message("secp256k1 configure summary")
231+
message("===========================")
232+
message("Build artifacts:")
233+
message(" shared library ...................... ${SECP256K1_BUILD_SHARED}")
234+
message(" static library ...................... ${SECP256K1_BUILD_STATIC}")
235+
message("Optional modules:")
236+
message(" ECDH ................................ ${SECP256K1_ENABLE_MODULE_ECDH}")
237+
message(" ECDSA pubkey recovery ............... ${SECP256K1_ENABLE_MODULE_RECOVERY}")
238+
message(" extrakeys ........................... ${SECP256K1_ENABLE_MODULE_EXTRAKEYS}")
239+
message(" schnorrsig .......................... ${SECP256K1_ENABLE_MODULE_SCHNORRSIG}")
240+
message("Parameters:")
241+
message(" ecmult window size .................. ${SECP256K1_ECMULT_WINDOW_SIZE}")
242+
message(" ecmult gen precision bits ........... ${SECP256K1_ECMULT_GEN_PREC_BITS}")
243+
message("Optional features:")
244+
message(" assembly optimization ............... ${SECP256K1_ASM}")
245+
message(" external callbacks .................. ${SECP256K1_USE_EXTERNAL_DEFAULT_CALLBACKS}")
246+
if(SECP256K1_TEST_OVERRIDE_WIDE_MULTIPLY)
247+
message(" wide multiplication (test-only) ..... ${SECP256K1_TEST_OVERRIDE_WIDE_MULTIPLY}")
248+
endif()
249+
message("Optional binaries:")
250+
message(" benchmark ........................... ${SECP256K1_BUILD_BENCHMARK}")
251+
message(" noverify_tests ...................... ${SECP256K1_BUILD_TESTS}")
252+
set(tests_status "${SECP256K1_BUILD_TESTS}")
253+
if(CMAKE_BUILD_TYPE STREQUAL "Coverage")
254+
set(tests_status OFF)
255+
endif()
256+
message(" tests ............................... ${tests_status}")
257+
message(" exhaustive tests .................... ${SECP256K1_BUILD_EXHAUSTIVE_TESTS}")
258+
message(" ctime_tests ......................... ${SECP256K1_BUILD_CTIME_TESTS}")
259+
message(" examples ............................ ${SECP256K1_BUILD_EXAMPLES}")
260+
message("")
261+
if(CMAKE_CROSSCOMPILING)
262+
set(cross_status "TRUE, for ${CMAKE_SYSTEM_NAME}, ${CMAKE_SYSTEM_PROCESSOR}")
263+
else()
264+
set(cross_status "FALSE")
265+
endif()
266+
message("Cross compiling ....................... ${cross_status}")
267+
message("Valgrind .............................. ${SECP256K1_VALGRIND}")
268+
get_directory_property(definitions COMPILE_DEFINITIONS)
269+
string(REPLACE ";" " " definitions "${definitions}")
270+
message("Preprocessor defined macros ........... ${definitions}")
271+
message("C compiler ............................ ${CMAKE_C_COMPILER}")
272+
message("CFLAGS ................................ ${CMAKE_C_FLAGS}")
273+
get_directory_property(compile_options COMPILE_OPTIONS)
274+
string(REPLACE ";" " " compile_options "${compile_options}")
275+
message("Compile options ....................... " ${compile_options})
276+
if(DEFINED CMAKE_BUILD_TYPE)
277+
message("Build type:")
278+
message(" - CMAKE_BUILD_TYPE ................... ${CMAKE_BUILD_TYPE}")
279+
string(TOUPPER "${CMAKE_BUILD_TYPE}" build_type)
280+
message(" - CFLAGS ............................. ${CMAKE_C_FLAGS_${build_type}}")
281+
message(" - LDFLAGS for executables ............ ${CMAKE_EXE_LINKER_FLAGS_${build_type}}")
282+
message(" - LDFLAGS for shared libraries ....... ${CMAKE_SHARED_LINKER_FLAGS_${build_type}}")
283+
else()
284+
message("Available configurations .............. ${CMAKE_CONFIGURATION_TYPES}")
285+
message("RelWithDebInfo configuration:")
286+
message(" - CFLAGS ............................. ${CMAKE_C_FLAGS_RELWITHDEBINFO}")
287+
message(" - LDFLAGS for executables ............ ${CMAKE_EXE_LINKER_FLAGS_RELWITHDEBINFO}")
288+
message(" - LDFLAGS for shared libraries ....... ${CMAKE_SHARED_LINKER_FLAGS_RELWITHDEBINFO}")
289+
message("Debug configuration:")
290+
message(" - CFLAGS ............................. ${CMAKE_C_FLAGS_DEBUG}")
291+
message(" - LDFLAGS for executables ............ ${CMAKE_EXE_LINKER_FLAGS_DEBUG}")
292+
message(" - LDFLAGS for shared libraries ....... ${CMAKE_SHARED_LINKER_FLAGS_DEBUG}")
293+
endif()
294+
message("\n")
295+
if(SECP256K1_EXPERIMENTAL)
296+
message(
297+
" ******\n"
298+
" WARNING: experimental build\n"
299+
" Experimental features do not have stable APIs or properties, and may not be safe for production use.\n"
300+
" ******\n"
301+
)
302+
endif()

cmake/Check64bitAssembly.cmake

+14
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
include(CheckCSourceCompiles)
2+
3+
function(check_64bit_assembly)
4+
check_c_source_compiles("
5+
#include <stdint.h>
6+
7+
int main()
8+
{
9+
uint64_t a = 11, tmp;
10+
__asm__ __volatile__(\"movq $0x100000000,%1; mulq %%rsi\" : \"+a\"(a) : \"S\"(tmp) : \"cc\", \"%rdx\");
11+
}
12+
" HAS_64BIT_ASM)
13+
set(HAS_64BIT_ASM ${HAS_64BIT_ASM} PARENT_SCOPE)
14+
endfunction()

0 commit comments

Comments
 (0)