@@ -51,29 +51,37 @@ endif()
51
51
52
52
option (SECP256K1_INSTALL "Enable installation." ${PROJECT_IS_TOP_LEVEL} )
53
53
54
- option (SECP256K1_ENABLE_MODULE_ECDH "Enable ECDH module." ON )
55
- if (SECP256K1_ENABLE_MODULE_ECDH)
56
- add_compile_definitions (ENABLE_MODULE_ECDH=1)
57
- endif ()
54
+ ## Modules
58
55
56
+ # We declare all options before processing them, to make sure we can express
57
+ # dependendencies while processing.
58
+ option (SECP256K1_ENABLE_MODULE_ECDH "Enable ECDH module." ON )
59
59
option (SECP256K1_ENABLE_MODULE_RECOVERY "Enable ECDSA pubkey recovery module." OFF )
60
- if (SECP256K1_ENABLE_MODULE_RECOVERY)
61
- add_compile_definitions (ENABLE_MODULE_RECOVERY=1)
62
- endif ()
63
-
64
60
option (SECP256K1_ENABLE_MODULE_EXTRAKEYS "Enable extrakeys module." ON )
65
61
option (SECP256K1_ENABLE_MODULE_SCHNORRSIG "Enable schnorrsig module." ON )
62
+ option (SECP256K1_ENABLE_MODULE_ELLSWIFT "Enable ElligatorSwift module." ON )
63
+
64
+ # Processing must be done in a topological sorting of the dependency graph
65
+ # (dependent module first).
66
+ if (SECP256K1_ENABLE_MODULE_ELLSWIFT)
67
+ add_compile_definitions (ENABLE_MODULE_ELLSWIFT=1)
68
+ endif ()
69
+
66
70
if (SECP256K1_ENABLE_MODULE_SCHNORRSIG)
67
71
set (SECP256K1_ENABLE_MODULE_EXTRAKEYS ON )
68
72
add_compile_definitions (ENABLE_MODULE_SCHNORRSIG=1)
69
73
endif ()
74
+
70
75
if (SECP256K1_ENABLE_MODULE_EXTRAKEYS)
71
76
add_compile_definitions (ENABLE_MODULE_EXTRAKEYS=1)
72
77
endif ()
73
78
74
- option (SECP256K1_ENABLE_MODULE_ELLSWIFT "Enable ElligatorSwift module." ON )
75
- if (SECP256K1_ENABLE_MODULE_ELLSWIFT)
76
- add_compile_definitions (ENABLE_MODULE_ELLSWIFT=1)
79
+ if (SECP256K1_ENABLE_MODULE_RECOVERY)
80
+ add_compile_definitions (ENABLE_MODULE_RECOVERY=1)
81
+ endif ()
82
+
83
+ if (SECP256K1_ENABLE_MODULE_ECDH)
84
+ add_compile_definitions (ENABLE_MODULE_ECDH=1)
77
85
endif ()
78
86
79
87
option (SECP256K1_USE_EXTERNAL_DEFAULT_CALLBACKS "Enable external default callback functions." OFF )
0 commit comments