Changeset: 278153609e9a for MonetDB
URL: https://dev.monetdb.org/hg/MonetDB?cmd=changeset;node=278153609e9a
Modified Files:
        CMakeLists.txt
        monetdb_config.h.in
Branch: cmake-fun
Log Message:

Check for iconv earlier due to compilation flags incompatibility.

Also added defensive lines.


diffs (251 lines):

diff --git a/CMakeLists.txt b/CMakeLists.txt
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -224,10 +224,12 @@ endif()
 if(${CMAKE_C_COMPILER_ID} STREQUAL "Intel")
        add_compile_options(-no-gcc) # Intel compiler hack
 elseif(${CMAKE_C_COMPILER_ID} STREQUAL "GNU")
-       add_compile_definitions(_GNU_SOURCE)
+       add_compile_definitions(_GNU_SOURCE _XOPEN_SOURCE)
+       set(CMAKE_REQUIRED_DEFINITIONS "${CMAKE_REQUIRED_DEFINITIONS} 
-D_GNU_SOURCE -D_XOPEN_SOURCE")
 endif()
 if(NOT MSVC)
        add_compile_definitions(_REENTRANT)
+       set(CMAKE_REQUIRED_DEFINITIONS "${CMAKE_REQUIRED_DEFINITIONS} 
-D_REENTRANT")
 endif()
 
 opj_test_large_files(_LARGE_FILES)
@@ -327,6 +329,45 @@ if(NOT NAN_CAN_BE_USED_AS_INITIALIZER)
        set(NAN_CANNOT_BE_USED_AS_INITIALIZER ON)
 endif()
 
+# Iconv - Check before adding any new compiler flag
+set(ICONV_INCLUDE_DIR "")
+set(ICONV_LIBRARIES "")
+include(FindIconv)
+if(Iconv_FOUND)
+       set(HAVE_ICONV ON)
+       set(HAVE_ICONV_H ON)
+       cmake_push_check_state()
+       if(NOT Iconv_IS_BUILT_IN)
+               set(ICONV_INCLUDE_DIR "${Iconv_INCLUDE_DIR}")
+               set(ICONV_LIBRARIES "${Iconv_LIBRARY}")
+               set(CMAKE_REQUIRED_LIBRARIES 
"${CMAKE_REQUIRED_LIBRARIES};${ICONV_LIBRARIES}")
+       endif()
+
+       if(MSVC)
+               set(ICONV_CONST " ")
+       else()
+               message(STATUS "Check if second iconv argument requires const")
+               check_c_source_compiles("
+                       #include <iconv.h>
+
+                       int main(int argc, char **argv) {
+                               iconv_t conv = 0;
+                               char* in, *out = 0;
+                               size_t ilen = 0, olen = 0;
+                               (void) argc; (void) argv;
+                               iconv(conv, &in, &ilen, &out, &olen);
+                               return 0;
+                       }
+               " ICONV_NOT_REQUIRES_CONST)
+               if(ICONV_NOT_REQUIRES_CONST)
+                       set(ICONV_CONST " ")
+               else()
+                       set(ICONV_CONST const)
+               endif()
+       endif()
+       cmake_pop_check_state()
+endif()
+
 if(${CMAKE_C_COMPILER_ID} STREQUAL "Intel" AND EXISTS 
"${ROOT}/usr/include/math.h") # see 
https://software.intel.com/en-us/forums/intel-c-compiler/topic/760979
        file(READ "${ROOT}/usr/include/math.h" TMPTXT)
        string(FIND "${TMPTXT}" "_LIB_VERSION_TYPE" FOUND_VERSION)
@@ -1001,45 +1042,6 @@ if(NOT ${WITH_READLINE} STREQUAL "NO")
        cmake_pop_check_state()
 endif()
 
-# Iconv
-set(ICONV_INCLUDE_DIR "")
-set(ICONV_LIBRARIES "")
-include(FindIconv)
-if(Iconv_FOUND)
-       set(HAVE_ICONV ON)
-       set(HAVE_ICONV_H ON)
-       cmake_push_check_state()
-       if(NOT Iconv_IS_BUILT_IN)
-               set(ICONV_INCLUDE_DIR "${Iconv_INCLUDE_DIR}")
-               set(ICONV_LIBRARIES "${Iconv_LIBRARY}")
-               set(CMAKE_REQUIRED_LIBRARIES 
"${CMAKE_REQUIRED_LIBRARIES};${ICONV_LIBRARIES}")
-       endif()
-
-       if(NOT MSVC)
-               message(STATUS "Check if second iconv argument requires const")
-               check_c_source_compiles("
-                       #include <iconv.h>
-
-                       int main(int argc, char **argv) {
-                               iconv_t conv = 0;
-                               const char* in = 0;
-                               size_t ilen = 0;
-                               char* out = 0;
-                               size_t olen = 0;
-                               (void) argc; (void) argv;
-                               iconv(conv, &in, &ilen, &out, &olen);
-                               return 0;
-                       }
-               " ICONV_REQUIRES_CONST)
-       endif()
-       cmake_pop_check_state()
-       if(ICONV_REQUIRES_CONST)
-               set(ICONV_CONST const)
-       else()
-               set(ICONV_CONST " ")
-       endif()
-endif()
-
 # UUID
 set(UUID_LIBRARIES "")
 set(WITH_UUID "YES" CACHE STRING "Include UUID support (default=YES)") # Check 
with HAVE_UUID
@@ -2039,7 +2041,7 @@ check_symbol_exists("sigaction" "signal.
 check_symbol_exists("stpcpy" "string.h" HAVE_STPCPY)
 check_symbol_exists("strcasestr" "string.h" HAVE_STRCASESTR)
 check_symbol_exists("strncasecmp" "strings.h" HAVE_STRNCASECMP)
-check_symbol_exists("strptime" "time.h" HAVE_STRPTIME) # TODO check 
_XOPEN_SOURCE ?
+check_symbol_exists("strptime" "time.h" HAVE_STRPTIME)
 check_symbol_exists("strtok_r" "string.h" HAVE_STRTOK_R)
 check_symbol_exists("strtok_s" "string.h" HAVE_STRTOK_S)
 check_symbol_exists("sysconf" "unistd.h" HAVE_SYSCONF)
diff --git a/monetdb_config.h.in b/monetdb_config.h.in
--- a/monetdb_config.h.in
+++ b/monetdb_config.h.in
@@ -4,7 +4,9 @@
 #define _SEEN_MONETDB_CONFIG_H 1
 
 /* Define if you do not want assertions */
+#ifndef NDEBUG
 #cmakedefine NDEBUG
+#endif
 
 /* Define if you have the <sys/types.h> header file. */
 #cmakedefine HAVE_SYS_TYPES_H
@@ -43,8 +45,12 @@
 #define NATIVE_WIN32
 #endif
 
+#ifndef ftruncate
 #define ftruncate(fd, sz) (-(_chsize_s((fd), (__int64) (sz)) != 0))
+#endif
+#ifndef strdup
 #define strdup _strdup
+#endif
 #ifndef strcasecmp
 #define strcasecmp  _stricmp
 #endif
@@ -680,13 +686,19 @@
 #endif
 
 /* Number of bits in a file offset, on hosts where this is settable. */
+#ifndef _FILE_OFFSET_BITS
 #cmakedefine _FILE_OFFSET_BITS
+#endif
 
 /* Define to make fseeko visible on some hosts (e.g. glibc 2.2). */
+#ifndef _LARGEFILE_SOURCE
 #cmakedefine _LARGEFILE_SOURCE
+#endif
 
 /* Define for large files, on AIX-style hosts. */
+#ifndef _LARGE_FILES
 #cmakedefine _LARGE_FILES
+#endif
 
 /* Define if type `char' is unsigned and you are not using gcc.  */
 #ifndef __CHAR_UNSIGNED__
@@ -695,37 +707,55 @@
 
 /* If the compiler does not support function attributes via __attribute__,
    we just define __attribute__(a) to nothing. */
+#ifndef __attribute__
 #cmakedefine __attribute__(a)
+#endif
 
 /* Does your compiler support the `__hidden' specifier? */
+#ifndef __hidden
 #cmakedefine __hidden
+#endif
 
 /* Does your compiler support the `_Noreturn' specifier? */
+#ifndef _Noreturn
 #cmakedefine _Noreturn @_Noreturn@
+#endif
 
 /* Define to `__inline__' or `__inline' if that's what the C compiler
    calls it, or to nothing if 'inline' is not supported under any name.  */
 #ifndef __cplusplus
+#ifndef inline
 #cmakedefine inline
+#endif
 #ifndef restrict
 #cmakedefine restrict @restrict@
 #endif
 #endif
 
 /* Define to `long int' if <sys/types.h> does not define. */
+#ifndef off_t
 #cmakedefine off_t @off_t@
+#endif
 
 /* Define to `int' if <sys/types.h> does not define. */
+#ifndef pid_t
 #cmakedefine pid_t @pid_t@
+#endif
 
 /* Define to `unsigned int' if <sys/types.h> does not define. */
+#ifndef size_t
 #cmakedefine size_t @size_t@
+#endif
 
 /* type used by connect */
+#ifndef socklen_t
 #cmakedefine socklen_t @socklen_t@
+#endif
 
 /* Define to `int' if <sys/types.h> does not define. */
+#ifndef ssize_t
 #cmakedefine ssize_t @ssize_t@
+#endif
 
 #ifdef INTEL_MATH_H_HACK
 /* see https://software.intel.com/en-us/forums/intel-c-compiler/topic/760979 */
@@ -768,21 +798,24 @@ typedef __uint128_t uhge;
 #define SIZEOF_HGE SIZEOF___INT128_T
 #endif
 
-#ifndef HAVE_WINSOCK_H
+#if !defined(HAVE_WINSOCK_H) && !defined(closesocket)
 /* on Windows use closesocket, otherwise just close */
 #define closesocket close
 #endif
 
-#if !defined(WIN32) && !defined(_In_z_)
+#ifndef WIN32
 /* see 
https://docs.microsoft.com/en-us/visualstudio/code-quality/using-sal-annotations-to-reduce-c-cpp-code-defects
  * and Visual Studio include file <sal.h> */
-# define _In_z_
-# define _Printf_format_string_
+#ifndef _In_z_
+#define _In_z_
 #endif
-
-#ifndef WIN32
+#ifndef _Printf_format_string_
+#define _Printf_format_string_
+#endif
+#ifndef __declspec
 #define __declspec(x)
 #endif
+#endif
 
 #define PROMPT1                "\001\001\n"    /* prompt: ready for new query 
*/
 #define PROMPT2                "\001\002\n"    /* prompt: more data needed */
_______________________________________________
checkin-list mailing list
[email protected]
https://www.monetdb.org/mailman/listinfo/checkin-list

Reply via email to