]> granicus.if.org Git - json-c/commitdiff
Fix CMake Build process for MinGW and MSYS2
authorPablo Sanabria <pablo.s.q1.4.1991@gmail.com>
Sat, 25 Mar 2017 19:31:22 +0000 (16:31 -0300)
committerPablo Sanabria <pablo.s.q1.4.1991@gmail.com>
Mon, 27 Mar 2017 02:14:37 +0000 (23:14 -0300)
This fix includes some fixes for config.h.win32 that was generating
some compiling errors on MinGW64 and also fix CMakeLists.txt in order to
give better support to MinGW and MSYS2

CMakeLists.txt
config.h.win32

index 8ae09504b92b74aa097734bd82abd8dd13233840..4cd9e2ed67ec685f7fffb7fe8f9f89352d4e7045 100644 (file)
@@ -10,6 +10,21 @@ if(MSVC)
   file(RENAME ${CMAKE_CURRENT_BINARY_DIR}/include/config.h.win32 ${CMAKE_CURRENT_BINARY_DIR}/include/config.h)
   file(COPY ./json_config.h.win32 DESTINATION ${CMAKE_CURRENT_BINARY_DIR}/include/)
   file(RENAME ${CMAKE_CURRENT_BINARY_DIR}/include/json_config.h.win32 ${CMAKE_CURRENT_BINARY_DIR}/include/json_config.h)
+elseif(MINGW)
+  set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Werror -D_GNU_SOURCE=1")
+  set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -Werror -D_GNU_SOURCE=1")
+  if (MSYS OR CMAKE_GENERATOR STREQUAL "Unix Makefiles")
+    execute_process(COMMAND echo ${CMAKE_CURRENT_SOURCE_DIR} WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR})
+    execute_process(COMMAND sh autogen.sh WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR})
+    execute_process(COMMAND sh ./configure WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR})
+    file(COPY ./config.h DESTINATION ${CMAKE_CURRENT_BINARY_DIR}/include/)
+    file(COPY ./json_config.h DESTINATION ${CMAKE_CURRENT_BINARY_DIR}/include/)
+  else()
+    file(COPY ./config.h.win32 DESTINATION ${CMAKE_CURRENT_BINARY_DIR}/include/)
+    file(RENAME ${CMAKE_CURRENT_BINARY_DIR}/include/config.h.win32 ${CMAKE_CURRENT_BINARY_DIR}/include/config.h)
+    file(COPY ./json_config.h.win32 DESTINATION ${CMAKE_CURRENT_BINARY_DIR}/include/)
+    file(RENAME ${CMAKE_CURRENT_BINARY_DIR}/include/json_config.h.win32 ${CMAKE_CURRENT_BINARY_DIR}/include/json_config.h)
+  endif()
 elseif(UNIX)
   set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Werror")
   set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -Werror")
index e721aaf7d78add006972e505a38de689a88d1044..2a70a9cc0d5e033a4a773239a1668b571f32e26b 100644 (file)
@@ -8,24 +8,24 @@
 \r
 /* Define to 1 if you have the declaration of `INFINITY', and to 0 if you\r
    don't. */\r
-#if defined(_MSC_VER) && _MSC_VER >= 1800\r
+#if (defined(_MSC_VER) && _MSC_VER >= 1800) || defined(__MINGW32__)\r
 #define HAVE_DECL_INFINITY 1\r
 #endif\r
 \r
 /* Define to 1 if you have the declaration of `isinf', and to 0 if you don't.\r
    */\r
-#if defined(_MSC_VER) && _MSC_VER >= 1800\r
+#if (defined(_MSC_VER) && _MSC_VER >= 1800) || defined(__MINGW32__)\r
 #define HAVE_DECL_ISINF 1\r
 #endif\r
 \r
 /* Define to 1 if you have the declaration of `isnan', and to 0 if you don't.\r
    */\r
-#if defined(_MSC_VER) && _MSC_VER >= 1800\r
+#if (defined(_MSC_VER) && _MSC_VER >= 1800) || defined(__MINGW32__)\r
 #define HAVE_DECL_ISNAN 1\r
 #endif\r
 \r
 /* Define to 1 if you have the declaration of `nan', and to 0 if you don't. */\r
-#if defined(_MSC_VER) && _MSC_VER >= 1800\r
+#if (defined(_MSC_VER) && _MSC_VER >= 1800) || defined(__MINGW32__)\r
 #define HAVE_DECL_NAN 1\r
 #endif\r
 \r
 #define HAVE_SETLOCALE 1\r
 \r
 /* Define to 1 if you have the `snprintf' function. */\r
+#if defined(__MINGW32__)\r
+#define HAVE_SNPRINTF 1\r
+#else\r
 #undef HAVE_SNPRINTF\r
+#endif\r
 \r
 /* Define to 1 if you have the <stdarg.h> header file. */\r
 #define HAVE_STDARG_H 1\r
 #define HAVE_STRING_H 1\r
 \r
 /* Define to 1 if you have the `strncasecmp' function. */\r
+#if defined(__MINGW32__)\r
+#define HAVE_STRNCASECMP 1\r
+#else\r
 #undef HAVE_STRNCASECMP\r
+#endif\r
 \r
 /* Define to 1 if you have the <syslog.h> header file. */\r
 #undef HAVE_SYSLOG_H\r
 #define HAVE_SYS_CDEFS_H 1\r
 \r
 /* Define to 1 if you have the <sys/param.h> header file. */\r
+#if defined(__MINGW32__)\r
+#define HAVE_SYS_PARAM_H 1\r
+#else\r
 #undef HAVE_SYS_PARAM_H\r
+#endif\r
 \r
 /* Define to 1 if you have the <sys/stat.h> header file. */\r
 #define HAVE_SYS_STAT_H 1\r
 #define HAVE_SYS_TYPES_H 1\r
 \r
 /* Define to 1 if you have the <unistd.h> header file. */\r
+#if defined(__MINGW32__)\r
+#define HAVE_UNISTD_H 1\r
+#else\r
 #undef HAVE_UNISTD_H\r
+#endif\r
 \r
 /* Define to 1 if you have the `vasprintf' function. */\r
+#if defined(__MINGW32__)\r
+#define HAVE_VASPRINTF 1\r
+#else\r
 #undef HAVE_VASPRINTF\r
+#endif\r
 \r
 /* Define to 1 if you have the `vprintf' function. */\r
 #define HAVE_VPRINTF 1\r