summaryrefslogtreecommitdiffstats
path: root/src/qjson-1-static.patch
blob: 54377a739ebc41c9db43dcab043279013e92091b (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
This file is part of MXE.
See index.html for further information.

From d456ebfe73b1a06beb8423c94f3b01edb6bc7507 Mon Sep 17 00:00:00 2001
From: Mark Brand <mabrand@mabrand.nl>
Date: Fri, 23 Nov 2012 08:41:43 +0100
Subject: [PATCH] build as static lib

taken from:
http://sourceforge.net/mailarchive/forum.php?thread_name=4E1DBC0D.10000%40jrit.at&forum_name=qjson-devel

diff --git a/CMakeLists.txt b/CMakeLists.txt
index 13e65f1..99fd8e6 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -31,6 +31,13 @@ SET(FRAMEWORK_INSTALL_DIR "${CMAKE_INSTALL_PREFIX}/Library/Frameworks"
 # (This will have no effect with CMake < 2.8)
 SET(QT_USE_IMPORTED_TARGETS TRUE)
 
+# For Static builds
+IF(LIBTYPE STREQUAL "STATIC")
+    ADD_DEFINITIONS("-DQJSON_STATIC")
+    ADD_DEFINITIONS("-DQT_NODLL")
+    SET(PKG_CONFIG_CFLAGS -DQJSON_STATIC ${PKG_CONFIG_CFLAGS})
+endif()
+
 # Find Qt4
 FIND_PACKAGE( Qt4 REQUIRED )
 
diff --git a/QJson.pc.in b/QJson.pc.in
index e4704bd..bf5fd01 100644
--- a/QJson.pc.in
+++ b/QJson.pc.in
@@ -8,4 +8,4 @@ Description: QJson is a qt-based library that maps JSON data to QVariant objects
 Version: @QJSON_LIB_MAJOR_VERSION@.@QJSON_LIB_MINOR_VERSION@.@QJSON_LIB_PATCH_VERSION@
 Requires: QtCore
 Libs: -L${libdir} -lqjson
-Cflags: -I${includedir}
\ No newline at end of file
+Cflags: -I${includedir} @PKG_CONFIG_CFLAGS@
diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt
index e2e8a13..c164b04 100644
--- a/src/CMakeLists.txt
+++ b/src/CMakeLists.txt
@@ -15,7 +15,12 @@ qt4_wrap_cpp(qjson_MOC_SRCS ${qjson_MOC_HDRS})
 set (qjson_SRCS parser.cpp qobjecthelper.cpp json_scanner.cpp json_parser.cc parserrunnable.cpp serializer.cpp serializerrunnable.cpp)
 set (qjson_HEADERS parser.h parserrunnable.h qobjecthelper.h serializer.h serializerrunnable.h qjson_export.h)
 
-add_library (qjson SHARED ${qjson_SRCS} ${qjson_MOC_SRCS} ${qjson_HEADERS})
+IF(LIBTYPE STREQUAL "STATIC")
+    add_library (qjson STATIC ${qjson_SRCS} ${qjson_MOC_SRCS} ${qjson_HEADERS})
+else()
+    add_library (qjson SHARED ${qjson_SRCS} ${qjson_MOC_SRCS} ${qjson_HEADERS})
+endif()
+
 target_link_libraries( qjson ${QT_LIBRARIES})
 
 if(NOT android)
diff --git a/src/qjson_export.h b/src/qjson_export.h
index 9a807b9..7e6646a 100644
--- a/src/qjson_export.h
+++ b/src/qjson_export.h
@@ -23,7 +23,9 @@
 #include <QtCore/qglobal.h>
 
 #ifndef QJSON_EXPORT
-# if defined(QJSON_MAKEDLL)
+# ifdef QJSON_STATIC
+#  define QJSON_EXPORT
+# elif defined(QJSON_MAKEDLL)
    /* We are building this library */
 #  define QJSON_EXPORT Q_DECL_EXPORT
 # else
-- 
1.7.10.4