Skip to content

Commit ea7c6a5

Browse files
committed
cmake: Use recommended add_compile_definitions command
Available in CMake 3.12+.
1 parent 3dd065a commit ea7c6a5

File tree

1 file changed

+11
-11
lines changed

1 file changed

+11
-11
lines changed

CMakeLists.txt

+11-11
Original file line numberDiff line numberDiff line change
@@ -40,27 +40,27 @@ endif()
4040

4141
option(SECP256K1_ENABLE_MODULE_ECDH "Enable ECDH module." ON)
4242
if(SECP256K1_ENABLE_MODULE_ECDH)
43-
add_definitions(-DENABLE_MODULE_ECDH=1)
43+
add_compile_definitions(ENABLE_MODULE_ECDH=1)
4444
endif()
4545

4646
option(SECP256K1_ENABLE_MODULE_RECOVERY "Enable ECDSA pubkey recovery module." OFF)
4747
if(SECP256K1_ENABLE_MODULE_RECOVERY)
48-
add_definitions(-DENABLE_MODULE_RECOVERY=1)
48+
add_compile_definitions(ENABLE_MODULE_RECOVERY=1)
4949
endif()
5050

5151
option(SECP256K1_ENABLE_MODULE_EXTRAKEYS "Enable extrakeys module." ON)
5252
option(SECP256K1_ENABLE_MODULE_SCHNORRSIG "Enable schnorrsig module." ON)
5353
if(SECP256K1_ENABLE_MODULE_SCHNORRSIG)
5454
set(SECP256K1_ENABLE_MODULE_EXTRAKEYS ON)
55-
add_definitions(-DENABLE_MODULE_SCHNORRSIG=1)
55+
add_compile_definitions(ENABLE_MODULE_SCHNORRSIG=1)
5656
endif()
5757
if(SECP256K1_ENABLE_MODULE_EXTRAKEYS)
58-
add_definitions(-DENABLE_MODULE_EXTRAKEYS=1)
58+
add_compile_definitions(ENABLE_MODULE_EXTRAKEYS=1)
5959
endif()
6060

6161
option(SECP256K1_USE_EXTERNAL_DEFAULT_CALLBACKS "Enable external default callback functions." OFF)
6262
if(SECP256K1_USE_EXTERNAL_DEFAULT_CALLBACKS)
63-
add_definitions(-DUSE_EXTERNAL_DEFAULT_CALLBACKS=1)
63+
add_compile_definitions(USE_EXTERNAL_DEFAULT_CALLBACKS=1)
6464
endif()
6565

6666
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]")
@@ -70,22 +70,22 @@ check_string_option_value(SECP256K1_ECMULT_WINDOW_SIZE)
7070
if(SECP256K1_ECMULT_WINDOW_SIZE STREQUAL "AUTO")
7171
set(SECP256K1_ECMULT_WINDOW_SIZE 15)
7272
endif()
73-
add_definitions(-DECMULT_WINDOW_SIZE=${SECP256K1_ECMULT_WINDOW_SIZE})
73+
add_compile_definitions(ECMULT_WINDOW_SIZE=${SECP256K1_ECMULT_WINDOW_SIZE})
7474

7575
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]")
7676
set_property(CACHE SECP256K1_ECMULT_GEN_PREC_BITS PROPERTY STRINGS "AUTO" 2 4 8)
7777
check_string_option_value(SECP256K1_ECMULT_GEN_PREC_BITS)
7878
if(SECP256K1_ECMULT_GEN_PREC_BITS STREQUAL "AUTO")
7979
set(SECP256K1_ECMULT_GEN_PREC_BITS 4)
8080
endif()
81-
add_definitions(-DECMULT_GEN_PREC_BITS=${SECP256K1_ECMULT_GEN_PREC_BITS})
81+
add_compile_definitions(ECMULT_GEN_PREC_BITS=${SECP256K1_ECMULT_GEN_PREC_BITS})
8282

8383
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]")
8484
set_property(CACHE SECP256K1_TEST_OVERRIDE_WIDE_MULTIPLY PROPERTY STRINGS "OFF" "int128_struct" "int128" "int64")
8585
check_string_option_value(SECP256K1_TEST_OVERRIDE_WIDE_MULTIPLY)
8686
if(SECP256K1_TEST_OVERRIDE_WIDE_MULTIPLY)
8787
string(TOUPPER "${SECP256K1_TEST_OVERRIDE_WIDE_MULTIPLY}" widemul_upper_value)
88-
add_definitions(-DUSE_FORCE_WIDEMUL_${widemul_upper_value}=1)
88+
add_compile_definitions(USE_FORCE_WIDEMUL_${widemul_upper_value}=1)
8989
endif()
9090
mark_as_advanced(FORCE SECP256K1_TEST_OVERRIDE_WIDE_MULTIPLY)
9191

@@ -94,13 +94,13 @@ set_property(CACHE SECP256K1_ASM PROPERTY STRINGS "AUTO" "OFF" "x86_64" "arm")
9494
check_string_option_value(SECP256K1_ASM)
9595
if(SECP256K1_ASM STREQUAL "arm")
9696
enable_language(ASM)
97-
add_definitions(-DUSE_EXTERNAL_ASM=1)
97+
add_compile_definitions(USE_EXTERNAL_ASM=1)
9898
elseif(SECP256K1_ASM)
9999
include(Check64bitAssembly)
100100
check_64bit_assembly()
101101
if(HAS_64BIT_ASM)
102102
set(SECP256K1_ASM "x86_64")
103-
add_definitions(-DUSE_ASM_X86_64=1)
103+
add_compile_definitions(USE_ASM_X86_64=1)
104104
elseif(SECP256K1_ASM STREQUAL "AUTO")
105105
set(SECP256K1_ASM "OFF")
106106
else()
@@ -123,7 +123,7 @@ if(SECP256K1_VALGRIND)
123123
if(Valgrind_FOUND)
124124
set(SECP256K1_VALGRIND ON)
125125
include_directories(${Valgrind_INCLUDE_DIR})
126-
add_definitions(-DVALGRIND)
126+
add_compile_definitions(VALGRIND)
127127
elseif(SECP256K1_VALGRIND STREQUAL "AUTO")
128128
set(SECP256K1_VALGRIND OFF)
129129
else()

0 commit comments

Comments
 (0)