@@ -54,27 +54,16 @@ add_library(secp256k1_precomputed OBJECT EXCLUDE_FROM_ALL
54
54
# from being exported.
55
55
target_sources (secp256k1 PRIVATE secp256k1.c $< TARGET_OBJECTS:secp256k1_precomputed> )
56
56
57
- # Create a helper lib that parent projects can use to link secp256k1 into a
58
- # static lib.
59
- add_library (secp256k1_objs INTERFACE )
60
- target_sources (secp256k1_objs INTERFACE $< TARGET_OBJECTS:secp256k1> $< TARGET_OBJECTS:secp256k1_precomputed> )
61
-
62
- add_library (secp256k1_asm INTERFACE )
63
57
if (SECP256K1_ASM STREQUAL "arm32" )
64
- add_library (secp256k1_asm_arm OBJECT EXCLUDE_FROM_ALL )
65
- target_sources (secp256k1_asm_arm PUBLIC
66
- asm/field_10x26_arm.s
67
- )
68
- target_sources (secp256k1 PRIVATE $< TARGET_OBJECTS:secp256k1_asm_arm> )
69
- target_sources (secp256k1_objs INTERFACE $< TARGET_OBJECTS:secp256k1_asm_arm> )
70
- target_link_libraries (secp256k1_asm INTERFACE secp256k1_asm_arm )
58
+ add_library (secp256k1_asm OBJECT EXCLUDE_FROM_ALL asm/field_10x26_arm.s )
59
+ else ()
60
+ add_library (secp256k1_asm INTERFACE )
71
61
endif ()
72
62
73
- if (WIN32 )
74
- # Define our export symbol only for shared libs.
75
- set_target_properties (secp256k1 PROPERTIES DEFINE_SYMBOL SECP256K1_DLL_EXPORT )
76
- target_compile_definitions (secp256k1 INTERFACE $< $< NOT:$< BOOL:${BUILD_SHARED_LIBS} > > :SECP256K1_STATIC> )
77
- endif ()
63
+ # When building a static libary, SECP256K1_STATIC must be defined both for itself and downstream.
64
+ # Note that the generator expression is evaluated in the context of the consuming target!
65
+ target_compile_definitions (secp256k1 PUBLIC $< $< STREQUAL:$< TARGET_PROPERTY:secp256k1,TYPE> ,STATIC_LIBRARY> :SECP256K1_STATIC> )
66
+ set_target_properties (secp256k1 PROPERTIES C_VISIBILITY_PRESET hidden VISIBILITY_INLINES_HIDDEN ON )
78
67
79
68
# Object libs don't know if they're being built for a shared or static lib.
80
69
# Grab the PIC property from secp256k1 which knows.
@@ -85,9 +74,6 @@ set_target_properties(secp256k1_precomputed PROPERTIES POSITION_INDEPENDENT_CODE
85
74
target_include_directories (secp256k1 INTERFACE
86
75
$< BUILD_INTERFACE:$< $< NOT:$< BOOL:${PROJECT_IS_TOP_LEVEL} > > :${PROJECT_SOURCE_DIR} /include> >
87
76
)
88
- set_target_properties (secp256k1_objs PROPERTIES
89
- INTERFACE_INCLUDE_DIRECTORIES "$<TARGET_PROPERTY:secp256k1,INTERFACE_INCLUDE_DIRECTORIES>"
90
- )
91
77
92
78
# This emulates Libtool to make sure Libtool and CMake agree on the ABI version,
93
79
# see below "Calculate the version variables" in build-aux/ltmain.sh.
@@ -123,18 +109,21 @@ if(SECP256K1_BUILD_BENCHMARK)
123
109
add_executable (bench bench.c )
124
110
target_link_libraries (bench secp256k1 )
125
111
add_executable (bench_internal bench_internal.c )
112
+ target_compile_definitions (bench_internal PRIVATE $< TARGET_PROPERTY:secp256k1,INTERFACE_COMPILE_DEFINITIONS> )
126
113
target_link_libraries (bench_internal secp256k1_precomputed secp256k1_asm )
127
114
add_executable (bench_ecmult bench_ecmult.c )
115
+ target_compile_definitions (bench_ecmult PRIVATE $< TARGET_PROPERTY:secp256k1,INTERFACE_COMPILE_DEFINITIONS> )
128
116
target_link_libraries (bench_ecmult secp256k1_precomputed secp256k1_asm )
129
117
endif ()
130
118
131
119
if (SECP256K1_BUILD_TESTS )
132
120
add_executable (noverify_tests tests.c )
121
+ target_compile_definitions (noverify_tests PRIVATE $< TARGET_PROPERTY:secp256k1,INTERFACE_COMPILE_DEFINITIONS> )
133
122
target_link_libraries (noverify_tests secp256k1_precomputed secp256k1_asm )
134
123
add_test (NAME secp256k1_noverify_tests COMMAND noverify_tests )
135
124
if (NOT CMAKE_BUILD_TYPE STREQUAL "Coverage" )
136
125
add_executable (tests tests.c )
137
- target_compile_definitions (tests PRIVATE VERIFY )
126
+ target_compile_definitions (tests PRIVATE VERIFY $< TARGET_PROPERTY:secp256k1,INTERFACE_COMPILE_DEFINITIONS > )
138
127
target_link_libraries (tests secp256k1_precomputed secp256k1_asm )
139
128
add_test (NAME secp256k1_tests COMMAND tests )
140
129
endif ()
@@ -144,7 +133,10 @@ if(SECP256K1_BUILD_EXHAUSTIVE_TESTS)
144
133
# Note: do not include secp256k1_precomputed in exhaustive_tests (it uses runtime-generated tables).
145
134
add_executable (exhaustive_tests tests_exhaustive.c )
146
135
target_link_libraries (exhaustive_tests secp256k1_asm )
147
- target_compile_definitions (exhaustive_tests PRIVATE $< $< NOT:$< CONFIG:Coverage> > :VERIFY> )
136
+ target_compile_definitions (exhaustive_tests PRIVATE
137
+ $< $< NOT:$< CONFIG:Coverage> > :VERIFY>
138
+ $< TARGET_PROPERTY:secp256k1,INTERFACE_COMPILE_DEFINITIONS>
139
+ )
148
140
add_test (NAME secp256k1_exhaustive_tests COMMAND exhaustive_tests )
149
141
endif ()
150
142
0 commit comments