Fix CMake Build process improved for MinGW and MSYS2tags/json-c-0.13-20171207
@@ -10,6 +10,21 @@ if(MSVC) | |||||
file(RENAME ${CMAKE_CURRENT_BINARY_DIR}/include/config.h.win32 ${CMAKE_CURRENT_BINARY_DIR}/include/config.h) | 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(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) | 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) | elseif(UNIX) | ||||
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Werror") | set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Werror") | ||||
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -Werror -D_GNU_SOURCE") | set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -Werror -D_GNU_SOURCE") | ||||
@@ -8,24 +8,24 @@ | |||||
/* Define to 1 if you have the declaration of `INFINITY', and to 0 if you | /* Define to 1 if you have the declaration of `INFINITY', and to 0 if you | ||||
don't. */ | don't. */ | ||||
#if defined(_MSC_VER) && _MSC_VER >= 1800 | |||||
#if (defined(_MSC_VER) && _MSC_VER >= 1800) || defined(__MINGW32__) | |||||
#define HAVE_DECL_INFINITY 1 | #define HAVE_DECL_INFINITY 1 | ||||
#endif | #endif | ||||
/* Define to 1 if you have the declaration of `isinf', and to 0 if you don't. | /* Define to 1 if you have the declaration of `isinf', and to 0 if you don't. | ||||
*/ | */ | ||||
#if defined(_MSC_VER) && _MSC_VER >= 1800 | |||||
#if (defined(_MSC_VER) && _MSC_VER >= 1800) || defined(__MINGW32__) | |||||
#define HAVE_DECL_ISINF 1 | #define HAVE_DECL_ISINF 1 | ||||
#endif | #endif | ||||
/* Define to 1 if you have the declaration of `isnan', and to 0 if you don't. | /* Define to 1 if you have the declaration of `isnan', and to 0 if you don't. | ||||
*/ | */ | ||||
#if defined(_MSC_VER) && _MSC_VER >= 1800 | |||||
#if (defined(_MSC_VER) && _MSC_VER >= 1800) || defined(__MINGW32__) | |||||
#define HAVE_DECL_ISNAN 1 | #define HAVE_DECL_ISNAN 1 | ||||
#endif | #endif | ||||
/* Define to 1 if you have the declaration of `nan', and to 0 if you don't. */ | /* Define to 1 if you have the declaration of `nan', and to 0 if you don't. */ | ||||
#if defined(_MSC_VER) && _MSC_VER >= 1800 | |||||
#if (defined(_MSC_VER) && _MSC_VER >= 1800) || defined(__MINGW32__) | |||||
#define HAVE_DECL_NAN 1 | #define HAVE_DECL_NAN 1 | ||||
#endif | #endif | ||||
@@ -76,7 +76,11 @@ | |||||
#define HAVE_SETLOCALE 1 | #define HAVE_SETLOCALE 1 | ||||
/* Define to 1 if you have the `snprintf' function. */ | /* Define to 1 if you have the `snprintf' function. */ | ||||
#if defined(__MINGW32__) | |||||
#define HAVE_SNPRINTF 1 | |||||
#else | |||||
#undef HAVE_SNPRINTF | #undef HAVE_SNPRINTF | ||||
#endif | |||||
/* Define to 1 if you have the <stdarg.h> header file. */ | /* Define to 1 if you have the <stdarg.h> header file. */ | ||||
#define HAVE_STDARG_H 1 | #define HAVE_STDARG_H 1 | ||||
@@ -103,7 +107,11 @@ | |||||
#define HAVE_STRING_H 1 | #define HAVE_STRING_H 1 | ||||
/* Define to 1 if you have the `strncasecmp' function. */ | /* Define to 1 if you have the `strncasecmp' function. */ | ||||
#if defined(__MINGW32__) | |||||
#define HAVE_STRNCASECMP 1 | |||||
#else | |||||
#undef HAVE_STRNCASECMP | #undef HAVE_STRNCASECMP | ||||
#endif | |||||
/* Define to 1 if you have the <syslog.h> header file. */ | /* Define to 1 if you have the <syslog.h> header file. */ | ||||
#undef HAVE_SYSLOG_H | #undef HAVE_SYSLOG_H | ||||
@@ -112,7 +120,11 @@ | |||||
#define HAVE_SYS_CDEFS_H 1 | #define HAVE_SYS_CDEFS_H 1 | ||||
/* Define to 1 if you have the <sys/param.h> header file. */ | /* Define to 1 if you have the <sys/param.h> header file. */ | ||||
#if defined(__MINGW32__) | |||||
#define HAVE_SYS_PARAM_H 1 | |||||
#else | |||||
#undef HAVE_SYS_PARAM_H | #undef HAVE_SYS_PARAM_H | ||||
#endif | |||||
/* Define to 1 if you have the <sys/stat.h> header file. */ | /* Define to 1 if you have the <sys/stat.h> header file. */ | ||||
#define HAVE_SYS_STAT_H 1 | #define HAVE_SYS_STAT_H 1 | ||||
@@ -121,10 +133,18 @@ | |||||
#define HAVE_SYS_TYPES_H 1 | #define HAVE_SYS_TYPES_H 1 | ||||
/* Define to 1 if you have the <unistd.h> header file. */ | /* Define to 1 if you have the <unistd.h> header file. */ | ||||
#if defined(__MINGW32__) | |||||
#define HAVE_UNISTD_H 1 | |||||
#else | |||||
#undef HAVE_UNISTD_H | #undef HAVE_UNISTD_H | ||||
#endif | |||||
/* Define to 1 if you have the `vasprintf' function. */ | /* Define to 1 if you have the `vasprintf' function. */ | ||||
#if defined(__MINGW32__) | |||||
#define HAVE_VASPRINTF 1 | |||||
#else | |||||
#undef HAVE_VASPRINTF | #undef HAVE_VASPRINTF | ||||
#endif | |||||
/* Define to 1 if you have the `vprintf' function. */ | /* Define to 1 if you have the `vprintf' function. */ | ||||
#define HAVE_VPRINTF 1 | #define HAVE_VPRINTF 1 | ||||
@@ -23,7 +23,7 @@ | |||||
# include <endian.h> /* attempt to define endianness */ | # include <endian.h> /* attempt to define endianness */ | ||||
#endif | #endif | ||||
#ifdef _MSC_VER | |||||
#if defined(_MSC_VER) || defined(__MINGW32__) | |||||
# define WIN32_LEAN_AND_MEAN | # define WIN32_LEAN_AND_MEAN | ||||
# include <windows.h> /* Get InterlockedCompareExchange */ | # include <windows.h> /* Get InterlockedCompareExchange */ | ||||
#endif | #endif | ||||
@@ -452,7 +452,7 @@ static unsigned long lh_perllike_str_hash(const void *k) | |||||
static unsigned long lh_char_hash(const void *k) | static unsigned long lh_char_hash(const void *k) | ||||
{ | { | ||||
#if defined _MSC_VER | |||||
#if defined _MSC_VER || defined __MINGW32__ | |||||
#define RANDOM_SEED_TYPE LONG | #define RANDOM_SEED_TYPE LONG | ||||
#else | #else | ||||
#define RANDOM_SEED_TYPE int | #define RANDOM_SEED_TYPE int | ||||
@@ -474,7 +474,7 @@ static unsigned long lh_char_hash(const void *k) | |||||
#endif | #endif | ||||
#if defined USE_SYNC_COMPARE_AND_SWAP | #if defined USE_SYNC_COMPARE_AND_SWAP | ||||
(void)__sync_val_compare_and_swap(&random_seed, -1, seed); | (void)__sync_val_compare_and_swap(&random_seed, -1, seed); | ||||
#elif defined _MSC_VER | |||||
#elif defined _MSC_VER || defined __MINGW32__ | |||||
InterlockedCompareExchange(&random_seed, seed, -1); | InterlockedCompareExchange(&random_seed, seed, -1); | ||||
#else | #else | ||||
#warning "racy random seed initializtion if used by multiple threads" | #warning "racy random seed initializtion if used by multiple threads" | ||||