summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorChun-wei Fan <fanchunwei@src.gnome.org>2020-04-15 18:29:50 +0800
committerChun-wei Fan <fanchunwei@src.gnome.org>2020-05-05 16:38:47 +0800
commit30dadc71434b2f514d65231c02a660ffce1300ae (patch)
tree51d0c0b71446a506fd5e5fbe33d3db7a681da538
parent572d5feb6ee2bad762abc7f79ee563d52e5fa785 (diff)
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.
-rw-r--r--cairommconfig.h.in18
-rw-r--r--cairommconfig.h.meson18
2 files changed, 36 insertions, 0 deletions
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 */