Skip to content

Commit

Permalink
build: Introduce SECP256k1_DLL_EXPORT macro
Browse files Browse the repository at this point in the history
This change provides a way to build a shared library that is not tired
to the Libtool-specific `DLL_EXPORT` macro.
  • Loading branch information
hebasto committed Jun 29, 2023
1 parent d74b0be commit 7dc79e5
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 6 deletions.
8 changes: 5 additions & 3 deletions include/secp256k1.h
Original file line number Diff line number Diff line change
Expand Up @@ -134,10 +134,12 @@ typedef int (*secp256k1_nonce_function)(
#endif

/* Symbol visibility. See https://gcc.gnu.org/wiki/Visibility */
/* DLL_EXPORT is defined internally for shared builds */
#if defined(_WIN32)
# ifdef SECP256K1_BUILD
# ifdef DLL_EXPORT
# if defined(SECP256K1_BUILD)
# if defined(DLL_EXPORT) || defined(SECP256k1_DLL_EXPORT)
/* Building libsecp256k1 as a DLL.
* 1. If using Libtool, it defines DLL_EXPORT internally.
* 2. In other cases, SECP256k1_DLL_EXPORT must be defined. */
# define SECP256K1_API __declspec (dllexport)
# endif
/* The user must define SECP256K1_STATIC when consuming libsecp256k1 as a static
Expand Down
5 changes: 2 additions & 3 deletions src/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -20,10 +20,9 @@ if(SECP256K1_ASM STREQUAL "arm32")
target_link_libraries(secp256k1_asm INTERFACE secp256k1_asm_arm)
endif()

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

Expand Down

0 comments on commit 7dc79e5

Please sign in to comment.