diff --git a/meson.build b/meson.build index 3bbe6c2..04de5c3 100644 --- a/meson.build +++ b/meson.build @@ -27,6 +27,7 @@ plugin_sources = files( ) libs = [] +api_args = [] p2p_args = [] if host_machine.cpu_family().startswith('x86') @@ -68,9 +69,16 @@ if meson.get_compiler('cpp').get_linker_id() in ['ld.bfd', 'ld.gold', 'ld.mold'] link_args += ['-Wl,-Bsymbolic'] endif +if get_option('default_library') == 'static' + api_args += ['-DBSSHARED_API_STATIC'] +else + api_args += ['-DBSSHARED_API_BUILDING'] +endif + libbestsource = library('libbestsource', api_sources, dependencies: deps, install: true, + cpp_args: api_args, link_args: link_args, link_with: libs, name_prefix: '', diff --git a/src/bsshared.h b/src/bsshared.h index 0959268..b894f2a 100644 --- a/src/bsshared.h +++ b/src/bsshared.h @@ -28,13 +28,33 @@ #include #include +#if (defined(_WIN32) || defined(__CYGWIN__)) && !defined(BSSHARED_API_STATIC) +# define BSSHARED_API_EXPORT __declspec(dllexport) +# define BSSHARED_API_IMPORT __declspec(dllimport) +#elif defined(__OS2__) && !defined(BSSHARED_API_STATIC) +# define BSSHARED_API_EXPORT __declspec(dllexport) +# define BSSHARED_API_IMPORT +#elif __GNUC__ >= 4 +# define BSSHARED_API_EXPORT __attribute__((visibility("default"))) +# define BSSHARED_API_IMPORT __attribute__((visibility("default"))) +#else +# define BSSHARED_API_EXPORT +# define BSSHARED_API_IMPORT +#endif + +#ifdef BSSHARED_API_BUILDING +# define BSSHARED_API BSSHARED_API_EXPORT +#else +# define BSSHARED_API BSSHARED_API_IMPORT +#endif + constexpr size_t HashSize = 8; -class BestSourceException : public std::runtime_error { +class BSSHARED_API BestSourceException : public std::runtime_error { using std::runtime_error::runtime_error; }; -class BestSourceHWDecoderException : public BestSourceException { +class BSSHARED_API BestSourceHWDecoderException : public BestSourceException { using BestSourceException::BestSourceException; };