Skip to content

Commit

Permalink
[#5] fix(build): when building as a static library, don't define `dll…
Browse files Browse the repository at this point in the history
…export`/`dllimport`
  • Loading branch information
lmichaelis committed Aug 2, 2024
1 parent 86df366 commit cbd6d5f
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 13 deletions.
1 change: 1 addition & 0 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,7 @@ bs_select_cflags(${DM_ENABLE_ASAN} _DM_COMPILE_FLAGS _DM_LINK_FLAGS)

if (${DM_BUILD_STATIC})
add_library(dmusic STATIC)
target_compile_definitions(dmusic PUBLIC DM_STATIC=1)
else ()
add_library(dmusic SHARED)
endif ()
Expand Down
32 changes: 19 additions & 13 deletions include/dmusic.h
Original file line number Diff line number Diff line change
Expand Up @@ -11,25 +11,31 @@
#define DM_EXTERN
#endif

#if defined(_WIN32) || defined(__CYGWIN__)
#ifdef DM_BUILD
#ifdef __GNUC__
#define DMAPI DM_EXTERN __attribute__((dllexport))
#ifndef DM_STATIC
#if defined(_WIN32) || defined(__CYGWIN__)
#ifdef DM_BUILD
#ifdef __GNUC__
#define DMAPI DM_EXTERN __attribute__((dllexport))
#else
#define DMAPI DM_EXTERN __declspec(dllexport)
#endif
#else
#define DMAPI DM_EXTERN __declspec(dllexport)
#ifdef __GNUC__
#define DMAPI DM_EXTERN __attribute__((dllimport))
#else
#define DMAPI DM_EXTERN __declspec(dllimport)
#endif
#endif
#define DMINT
#else
#ifdef __GNUC__
#define DMAPI DM_EXTERN __attribute__((dllimport))
#else
#define DMAPI DM_EXTERN __declspec(dllimport)
#endif
#define DMAPI DM_EXTERN __attribute__((visibility("default")))
#define DMINT DM_EXTERN __attribute__((visibility("hidden")))
#endif
#define DMINT
#else
#define DMAPI DM_EXTERN __attribute__((visibility("default")))
#define DMINT DM_EXTERN __attribute__((visibility("hidden")))
#define DMAPI DM_EXTERN
#define DMINT DM_EXTERN
#endif

/// \endcond

/// \defgroup DmCommonGroup Common
Expand Down

0 comments on commit cbd6d5f

Please sign in to comment.