diff --git a/CMakeLists.txt b/CMakeLists.txt index 855b3b9..fa9af0b 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -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 () diff --git a/include/dmusic.h b/include/dmusic.h index 852a1c0..7165d1e 100644 --- a/include/dmusic.h +++ b/include/dmusic.h @@ -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