From 9042a91e0a121e63943a4389468975a3cb6fa905 Mon Sep 17 00:00:00 2001
From: Anonymous Maarten <[EMAIL REDACTED]>
Date: Thu, 14 Dec 2023 21:07:52 +0100
Subject: [PATCH] cmake: export symbols when building a shared library
---
CMakeLists.txt | 1 +
jmorecfg.h | 8 ++++++++
2 files changed, 9 insertions(+)
diff --git a/CMakeLists.txt b/CMakeLists.txt
index edc1206..d4ee40a 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -23,6 +23,7 @@ add_library(jpeg
jquant2.c jutils.c jmemmgr.c
)
add_library(JPEG::JPEG ALIAS jpeg)
+set_property(TARGET jpeg PROPERTY DEFINE_SYMBOL JPEG_SHARED)
set(jpeg_headers
jconfig.h
diff --git a/jmorecfg.h b/jmorecfg.h
index 679d68b..09a6c43 100644
--- a/jmorecfg.h
+++ b/jmorecfg.h
@@ -243,9 +243,17 @@ typedef unsigned int JDIMENSION;
/* a function used only in its module: */
#define LOCAL(type) static type
/* a function referenced thru EXTERNs: */
+#if defined(_WIN32) && defined(JPEG_SHARED)
+#define GLOBAL(type) __declspec(dllexport) type
+#else
#define GLOBAL(type) type
+#endif
/* a reference to a GLOBAL function: */
+#if defined(_WIN32) && defined(JPEG_SHARED)
+#define EXTERN(type) extern __declspec(dllexport) type
+#else
#define EXTERN(type) extern type
+#endif
/* This macro is used to declare a "method", that is, a function pointer.