mxe/src/qjson-1-static.patch

77 lines
2.5 KiB
Diff

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