This file is part of mingw-cross-env. See doc/index.html for further information. This patch 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 4ed5478..9a378a1 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -30,6 +30,13 @@ IF(QJSON_VERBOSE_DEBUG_OUTPUT) ADD_DEFINITIONS("-DQJSON_VERBOSE_DEBUG_OUTPUT") endif(QJSON_VERBOSE_DEBUG_OUTPUT) +# 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 ) @@ -51,13 +58,13 @@ set(QJSON_LIB_VERSION_STRING "${QJSON_LIB_MAJOR_VERSION}.${QJSON_LIB_MINOR_VERSI set(LIBRARY_OUTPUT_PATH "${CMAKE_BINARY_DIR}/lib${LIB_SUFFIX}" ) # pkg-config -IF (NOT WIN32) +if (NOT WIN32 OR MINGW) CONFIGURE_FILE (${CMAKE_CURRENT_SOURCE_DIR}/QJson.pc.in ${CMAKE_CURRENT_BINARY_DIR}/QJson.pc @ONLY) INSTALL (FILES ${CMAKE_CURRENT_BINARY_DIR}/QJson.pc DESTINATION lib${LIB_SUFFIX}/pkgconfig) -ENDIF (NOT WIN32) +endif() # Include the cmake file needed to use qt4 INCLUDE( ${QT_USE_FILE} ) 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 ced213d..d0d9c68 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -26,7 +26,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) -add_library (qjson SHARED ${qjson_SRCS} ${qjson_MOC_SRCS}) +IF(LIBTYPE STREQUAL "STATIC") + add_library (qjson STATIC ${qjson_SRCS} ${qjson_MOC_SRCS}) +else() + add_library (qjson SHARED ${qjson_SRCS} ${qjson_MOC_SRCS}) +endif() + target_link_libraries( qjson ${QT_LIBRARIES}) set_target_properties(qjson PROPERTIES diff --git a/src/qjson_export.h b/src/qjson_export.h index c7f5325..d5871e2 100644 --- a/src/qjson_export.h +++ b/src/qjson_export.h @@ -23,7 +23,9 @@ #include #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