]> granicus.if.org Git - json-c/commitdiff
To avoid target exe file export JSON functions.
authorssrlive <30760636+ssrlive@users.noreply.github.com>
Tue, 2 Mar 2021 06:27:40 +0000 (14:27 +0800)
committerssrlive <30760636+ssrlive@users.noreply.github.com>
Tue, 2 Mar 2021 06:27:40 +0000 (14:27 +0800)
CMakeLists.txt
debug.h
json_c_version.h
json_types.h
printbuf.h

index 79038aa3908cd7a411a06a212ddc56ad55572c9c..60fa7e10d821ea4a4f15e7eca319b63ce9735e05 100644 (file)
@@ -79,6 +79,10 @@ include(CMakePackageConfigHelpers)
 option(BUILD_SHARED_LIBS  "Default to building shared libraries" ON)
 option(BUILD_STATIC_LIBS  "Default to building static libraries" ON)
 
+if (BUILD_SHARED_LIBS)
+    add_definitions(-D JSON_C_DLL)
+endif()
+
 # Generate a release merge and test it to verify the correctness of republishing the package.
 ADD_CUSTOM_TARGET(distcheck
 COMMAND make package_source
diff --git a/debug.h b/debug.h
index a24136b8180b2c689182300548f67f1927299cc5..7463f863e3d7c8ecb45969a654def456cf41f2d9 100644 (file)
--- a/debug.h
+++ b/debug.h
@@ -24,7 +24,7 @@ extern "C" {
 #endif
 
 #ifndef JSON_EXPORT
-#if defined(_MSC_VER)
+#if defined(_MSC_VER) && defined(JSON_C_DLL)
 #define JSON_EXPORT __declspec(dllexport)
 #else
 #define JSON_EXPORT extern
index 00de4b3ff1033347e99447c5db9e6e71dae77258..d15ad64cb5934b19d9a24f995fcbef5c24fe1843 100644 (file)
@@ -24,7 +24,7 @@ extern "C" {
 #define JSON_C_VERSION "0.15.99"
 
 #ifndef JSON_EXPORT
-#if defined(_MSC_VER)
+#if defined(_MSC_VER) && defined(JSON_C_DLL)
 #define JSON_EXPORT __declspec(dllexport)
 #else
 #define JSON_EXPORT extern
index 67f4497f60c6713809a3b6be44d3c2888742cc2d..b7e55ada899c014e9dd195b23ff03652b199d318 100644 (file)
@@ -18,7 +18,7 @@ extern "C" {
 #endif
 
 #ifndef JSON_EXPORT
-#if defined(_MSC_VER)
+#if defined(_MSC_VER) && defined(JSON_C_DLL)
 #define JSON_EXPORT __declspec(dllexport)
 #else
 #define JSON_EXPORT extern
index bfcbd2b266f082a2b3dd720d8f020cd17bf9fccf..a0da668e6ebf442fc0c34ccf642e88615f00219a 100644 (file)
@@ -24,7 +24,7 @@
 #define _printbuf_h_
 
 #ifndef JSON_EXPORT
-#if defined(_MSC_VER)
+#if defined(_MSC_VER) && defined(JSON_C_DLL)
 #define JSON_EXPORT __declspec(dllexport)
 #else
 #define JSON_EXPORT extern