Skip to content

Commit 86eac71

Browse files
committed
build: Introduce SECP256k1_DLL_EXPORT macro
This change provides a way to build a shared library that is not tired to the Libtool-specific `DLL_EXPORT` macro.
1 parent 3e6078c commit 86eac71

File tree

2 files changed

+7
-6
lines changed

2 files changed

+7
-6
lines changed

include/secp256k1.h

+5-3
Original file line numberDiff line numberDiff line change
@@ -134,10 +134,12 @@ typedef int (*secp256k1_nonce_function)(
134134
#endif
135135

136136
/* Symbol visibility. See https://gcc.gnu.org/wiki/Visibility */
137-
/* DLL_EXPORT is defined internally for shared builds */
138137
#if defined(_WIN32)
139-
# ifdef SECP256K1_BUILD
140-
# ifdef DLL_EXPORT
138+
# if defined(SECP256K1_BUILD)
139+
# if defined(DLL_EXPORT) || defined(SECP256K1_DLL_EXPORT)
140+
/* Building libsecp256k1 as a DLL.
141+
* 1. If using Libtool, it defines DLL_EXPORT automatically.
142+
* 2. In other cases, SECP256k1_DLL_EXPORT must be defined. */
141143
# define SECP256K1_API extern __declspec (dllexport)
142144
# endif
143145
/* The user must define SECP256K1_STATIC when consuming libsecp256k1 as a static

src/CMakeLists.txt

+2-3
Original file line numberDiff line numberDiff line change
@@ -20,10 +20,9 @@ if(SECP256K1_ASM STREQUAL "arm32")
2020
target_link_libraries(secp256k1_asm INTERFACE secp256k1_asm_arm)
2121
endif()
2222

23-
# Define our export symbol only for Win32 and only for shared libs.
24-
# This matches libtool's usage of DLL_EXPORT
23+
# Define our export symbol only for Win32.
2524
if(WIN32)
26-
set_target_properties(secp256k1 PROPERTIES DEFINE_SYMBOL "DLL_EXPORT")
25+
set_target_properties(secp256k1 PROPERTIES DEFINE_SYMBOL SECP256k1_DLL_EXPORT)
2726
target_compile_definitions(secp256k1 INTERFACE $<$<NOT:$<BOOL:${BUILD_SHARED_LIBS}>>:SECP256K1_STATICLIB>)
2827
endif()
2928

0 commit comments

Comments
 (0)