From 30dadc71434b2f514d65231c02a660ffce1300ae Mon Sep 17 00:00:00 2001 From: Chun-wei Fan Date: Wed, 15 Apr 2020 18:29:50 +0800 Subject: cairommconfig.h.[in|meson]: Add CAIROMM_API This macro can be used to decorate public class and API prototypes, so that we can use it to export symbols with compiler directives, such as __declspec(dllexport) in the case of Visual Studio-style builds. We can even decide to not use it by keeping CAIROMM_API empty, such as in the case of building static libraries or when using GCC's autoexporting mechanism. --- cairommconfig.h.in | 18 ++++++++++++++++++ cairommconfig.h.meson | 18 ++++++++++++++++++ 2 files changed, 36 insertions(+) diff --git a/cairommconfig.h.in b/cairommconfig.h.in index f88ed99..f01a2e9 100644 --- a/cairommconfig.h.in +++ b/cairommconfig.h.in @@ -11,3 +11,21 @@ /* Micro version number of cairomm. */ #undef CAIROMM_MICRO_VERSION + +/* Enable DLL-specific stuff only when not building a static library */ +#if !defined(__CYGWIN__) && \ + (defined(__MINGW32__) || defined (_MSC_VER)) && \ + !defined(CAIROMM_STATIC_LIB) +# define CAIROMM_DLL 1 +#endif + +#ifdef CAIROMM_DLL +# if defined(CAIROMM_BUILD) +# define CAIROMM_API __declspec(dllexport) +# else +# define CAIROMM_API __declspec(dllimport) +# endif +/* Build a static or non-native-Windows library */ +#else +# define CAIROMM_API +#endif /* CAIROMM_DLL */ diff --git a/cairommconfig.h.meson b/cairommconfig.h.meson index 8923c96..5a1e7b9 100644 --- a/cairommconfig.h.meson +++ b/cairommconfig.h.meson @@ -18,4 +18,22 @@ /* Micro version number of cairomm. */ #mesondefine CAIROMM_MICRO_VERSION +/* Enable DLL-specific stuff only when not building a static library */ +#if !defined(__CYGWIN__) && \ + (defined(__MINGW32__) || defined (_MSC_VER)) && \ + !defined(CAIROMM_STATIC_LIB) +# define CAIROMM_DLL 1 +#endif + +#ifdef CAIROMM_DLL +# if defined(CAIROMM_BUILD) +# define CAIROMM_API __declspec(dllexport) +# else +# define CAIROMM_API __declspec(dllimport) +# endif +/* Build a static or non-native-Windows library */ +#else +# define CAIROMM_API +#endif /* CAIROMM_DLL */ + #endif /* _CAIROMM_CONFIG_H */ -- cgit v1.2.3