Skip to content

Commit 3ecaae6

Browse files
authored
Refactor SECP256K1_WIDEMUL setting in CMakeLists.txt
1 parent 530c239 commit 3ecaae6

File tree

1 file changed

+12
-16
lines changed

1 file changed

+12
-16
lines changed

CMakeLists.txt

Lines changed: 12 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -1,19 +1,6 @@
11
cmake_minimum_required(VERSION 3.16)
22
project(mpt-crypto C CXX)
33

4-
# --- Global Architecture Detection ---
5-
include(CheckTypeSize)
6-
# Check if the compiler supports __int128 (required for the optimized 64-bit code)
7-
check_type_size("__int128" HAVE___INT128)
8-
9-
if (HAVE___INT128)
10-
message(STATUS "Build: Detected 128-bit integer support.")
11-
set(MPT_ARCH_DEFS SECP256K1_WIDEMUL_INT128)
12-
else ()
13-
message(STATUS "Build: No 128-bit support detected.")
14-
set(MPT_ARCH_DEFS SECP256K1_WIDEMUL_INT64)
15-
endif ()
16-
174
# --- Find Dependencies ---
185
find_package(OpenSSL REQUIRED)
196
find_package(secp256k1 REQUIRED)
@@ -35,11 +22,20 @@ add_library(mpt-crypto
3522
target_include_directories(mpt-crypto PUBLIC include)
3623

3724
# --- Set Compile Definitions ---
38-
# Pass the architecture flags (MPT_ARCH_DEFS) to the compiler
39-
target_compile_definitions(mpt-crypto PUBLIC ${MPT_ARCH_DEFS})
25+
include(CheckTypeSize)
26+
# Check if the compiler supports __int128 (required for the optimized 64-bit code)
27+
check_type_size("__int128" HAVE___INT128)
28+
29+
if (HAVE___INT128)
30+
message(STATUS "Build: Detected 128-bit integer support.")
31+
target_compile_definitions(mpt-crypto PRIVATE SECP256K1_WIDEMUL_INT128)
32+
else ()
33+
message(STATUS "Build: No 128-bit support detected.")
34+
target_compile_definitions(mpt-crypto PRIVATE SECP256K1_WIDEMUL_INT64)
35+
endif ()
4036

4137
# --- Link Dependencies ---
42-
target_link_libraries(mpt-crypto PUBLIC secp256k1::secp256k1 PUBLIC OpenSSL::Crypto)
38+
target_link_libraries(mpt-crypto PUBLIC secp256k1::secp256k1 OpenSSL::Crypto)
4339

4440
# --- Testing ---
4541
option(ENABLE_TESTS "Enable building tests" ON)

0 commit comments

Comments
 (0)