Changeset: b32b5df23d78 for MonetDB URL: https://dev.monetdb.org/hg/MonetDB?cmd=changeset;node=b32b5df23d78 Modified Files: CMakeLists.txt common/stream/stream_socket.h gdk/gdk_posix.h monetdb5/modules/mal/mal_mapi.c monetdb_config.h.in Branch: cmake-fun Log Message:
Several changes. - We will support Visual Studio versions from 2015 up. - Perform a better test for _Noreturn keyword and __attribute__ extensions. - FindOpenSSL script works fine on Windows on cmake 3.7 up. - Use winsock2.h instead of the deprecated winsock.h - -g3 is available on clang (Previously I check the documentation for an old version). diffs (221 lines): diff --git a/CMakeLists.txt b/CMakeLists.txt --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -7,7 +7,9 @@ #]] if(WIN32) - cmake_minimum_required(VERSION 3.1) # The $<TARGET_PDB_FILE:tgt> generator expression appears on cmake 3.1 + # The $<TARGET_PDB_FILE:tgt> generator expression appears on cmake 3.1 + # FindOpenSSL scripts works fine on Windows from cmake 3.7 up + cmake_minimum_required(VERSION 3.7) else() cmake_minimum_required(VERSION 3.0) endif() @@ -176,12 +178,10 @@ if(${CMAKE_C_COMPILER_ID} STREQUAL "Inte set(INTEL_MATH_H_HACK ON CACHE INTERNAL "must use intel math.h hack") endif() endif() - set(__attribute__(a) ON) set(NAN_CANNOT_BE_USED_AS_INITIALIZER ON CACHE INTERNAL "NaN cannot be used as an initializer") # This hack is only required by the Intel compiler elseif(MSVC) - set(_Noreturn "__declspec(noreturn)") - set(__attribute__(a) ON) - set(restrict "__restrict") + set(restrict "__restrict") # C99 feature not present in MSVC + set(inline "__inline") # C99 feature only available on C++ compiler in MSVC https://docs.microsoft.com/en-us/cpp/cpp/inline-functions-cpp?view=vs-2015 add_definitions(/D_CRT_SECURE_NO_WARNINGS) if(CMAKE_SIZEOF_VOID_P EQUAL 8) # Windows 64 bit set(HAVE__MUL128 ON CACHE INTERNAL "mul128 function is available") @@ -211,8 +211,10 @@ check_c_source_compiles(" return 0; }" HAVE___BUILTIN_ADD_OVERFLOW) -if(NOT MSVC) - #Test if _Noreturn keyword is supported +#Test if _Noreturn keyword is supported +if(MSVC) + set(_Noreturn "__declspec(noreturn)") +else() check_c_source_compiles(" #include <stdlib.h> @@ -223,11 +225,17 @@ if(NOT MSVC) (void) argc; (void) argv; foo (\"%s\", \"\"); return 0; - }" HAVE_NORETURN) - if(NOT HAVE_NORETURN) - set(_Noreturn "__attribute__((__noreturn__))") + }" HAVE_NORETURN_KEYWORD) + if(NOT HAVE_NORETURN_KEYWORD) + check_symbol_exists("__has_attribute(__noreturn__)" "" HAVE_NORETURN_ATTRIBUTE) + if(HAVE_NORETURN_ATTRIBUTE) # If the compiler supports the attribute + set(_Noreturn "__attribute__((__noreturn__))") + else() + set(_Noreturn " ") # remove keyword + endif() endif() endif() + #Test if compiler has usable <stdatomic.h> check_c_source_compiles(" #include <stdatomic.h> @@ -302,7 +310,7 @@ if(Python3_Interpreter_FOUND) math(EXPR LEN1 "${LIBDIR_LENGTH}+1") # add the / separator string(SUBSTRING "${PYTHON3_LIBDIR}" ${LEN1} -1 PYTHON_LIBDIR) # remove the prefix else() - message(WARNING "Could not find Python 3 library directory") + message(WARNING "Could not determine MonetDB Python testing files instalation directory") endif() set(HAVE_PYTHON3 ON CACHE INTERNAL "python3 is available") endif() @@ -479,12 +487,13 @@ cmake_push_check_state() set(CMAKE_EXTRA_INCLUDE_FILES "${CMAKE_EXTRA_INCLUDE_FILES};sys/types.h") check_type_size(size_t SIZEOF_SIZE_T LANGUAGE C) #On C99, but we have to calculate the size check_type_size(ssize_t SIZEOF_SSIZE_T LANGUAGE C) -if(NOT HAVE_SIZEOF_SSIZE_T AND MSVC AND CMAKE_SIZEOF_VOID_P EQUAL 8) # Windows 64 bit - set(ssize_t "int64_t") - set(SIZEOF_SSIZE_T 8) -elseif(MSVC) - set(ssize_t "int32_t") - set(SIZEOF_SSIZE_T 4) +if(NOT HAVE_SIZEOF_SSIZE_T) # Set a default value + if(CMAKE_SIZEOF_VOID_P EQUAL 8) + set(ssize_t "int64_t") + else() + set(ssize_t "int32_t") + endif() + set(SIZEOF_SSIZE_T ${CMAKE_SIZEOF_VOID_P}) endif() check_type_size(char SIZEOF_CHAR LANGUAGE C) check_type_size(short SIZEOF_SHORT LANGUAGE C) @@ -625,12 +634,10 @@ else() # GCC, Clang and Apple clang MT_addCompilerFlag("-O3" "-O3" "${CMAKE_C_FLAGS_RELEASE}" "Release" CMAKE_C_FLAGS_RELEASE) MT_addCompilerFlag("-Os" "-Os" "${CMAKE_C_FLAGS_MINSIZEREL}" "MinSizeRel" CMAKE_C_FLAGS_MINSIZEREL) # Replace -g flag with -g3 - if(${CMAKE_C_COMPILER_ID} STREQUAL "GNU") - MT_removeCompilerFlag("-g([ ]|$)" "-g" "${CMAKE_C_FLAGS_DEBUG}" "Debug" CMAKE_C_FLAGS_DEBUG) - MT_removeCompilerFlag("-g([ ]|$)" "-g" "${CMAKE_C_FLAGS_RELWITHDEBINFO}" "RelWithDebugInfo" CMAKE_C_FLAGS_RELWITHDEBINFO) - MT_addCompilerFlag("-g3" "-g3" "${CMAKE_C_FLAGS_DEBUG}" "Debug" CMAKE_C_FLAGS_DEBUG) - MT_addCompilerFlag("-g3" "-g3" "${CMAKE_C_FLAGS_RELWITHDEBINFO}" "RelWithDebugInfo" CMAKE_C_FLAGS_RELWITHDEBINFO) - endif() + MT_removeCompilerFlag("-g([ ]|$)" "-g" "${CMAKE_C_FLAGS_DEBUG}" "Debug" CMAKE_C_FLAGS_DEBUG) + MT_removeCompilerFlag("-g([ ]|$)" "-g" "${CMAKE_C_FLAGS_RELWITHDEBINFO}" "RelWithDebugInfo" CMAKE_C_FLAGS_RELWITHDEBINFO) + MT_addCompilerFlag("-g3" "-g3" "${CMAKE_C_FLAGS_DEBUG}" "Debug" CMAKE_C_FLAGS_DEBUG) + MT_addCompilerFlag("-g3" "-g3" "${CMAKE_C_FLAGS_RELWITHDEBINFO}" "RelWithDebugInfo" CMAKE_C_FLAGS_RELWITHDEBINFO) if(NOT ${CMAKE_C_FLAGS_RELEASE} MATCHES "D_FORTIFY_SOURCE") set(CMAKE_C_FLAGS_RELEASE "${CMAKE_C_FLAGS_RELEASE} -D_FORTIFY_SOURCE=2") @@ -713,7 +720,7 @@ if(${ENABLE_STRICT} STREQUAL "YES") MT_checkCompilerFlag("${COMPILER_OPTION}${INTEL_OPTION_EXTRA}we140,147,181,266,271,593,810") MT_checkCompilerFlag("${COMPILER_OPTION}${INTEL_OPTION_EXTRA}wd193,279,981,1357,1418,1419,2259") elseif(MSVC) - MT_checkCompilerFlag("/WX") + MT_addCompilerFlag("/WX" "/WX" "${CMAKE_C_FLAGS}" "all" CMAKE_C_FLAGS) endif() endif() diff --git a/common/stream/stream_socket.h b/common/stream/stream_socket.h --- a/common/stream/stream_socket.h +++ b/common/stream/stream_socket.h @@ -13,7 +13,7 @@ #define _STREAM_SOCKET_H_ #ifdef NATIVE_WIN32 -# include <winsock.h> +# include <winsock2.h> #else #include <sys/socket.h> #endif diff --git a/gdk/gdk_posix.h b/gdk/gdk_posix.h --- a/gdk/gdk_posix.h +++ b/gdk/gdk_posix.h @@ -22,7 +22,7 @@ #include "gdk_system.h" /* gdk_export */ #ifdef NATIVE_WIN32 -#include <winsock.h> /* for timeval */ +#include <winsock2.h> #include <io.h> #include <direct.h> #endif diff --git a/monetdb5/modules/mal/mal_mapi.c b/monetdb5/modules/mal/mal_mapi.c --- a/monetdb5/modules/mal/mal_mapi.c +++ b/monetdb5/modules/mal/mal_mapi.c @@ -42,7 +42,7 @@ # include <CommonCrypto/CommonRandom.h> #endif #ifdef NATIVE_WIN32 /* Windows specific */ -# include <winsock.h> +# include <winsock2.h> #else /* UNIX specific */ # include <unistd.h> /* gethostname() */ # include <sys/select.h> diff --git a/monetdb_config.h.in b/monetdb_config.h.in --- a/monetdb_config.h.in +++ b/monetdb_config.h.in @@ -21,8 +21,8 @@ #include <assert.h> #ifdef _MSC_VER -#if _MSC_VER < 1800 -#error old versions of Visual Studio are no longer supported +#if _MSC_VER < 1900 +#error Versions bellow Visual Studio 2015 are no longer supported #endif /* Prevent pollution through excessive inclusion of include files by Windows.h. */ @@ -404,11 +404,6 @@ /* Compiling for static code analysis */ #cmakedefine STATIC_CODE_ANALYSIS -/* Define on Microsoft Windows (also under Cygwin) */ -#ifndef WIN32 -#cmakedefine WIN32 -#endif - /* Define WORDS_BIGENDIAN to 1 if your processor stores words with the most significant byte first (like Motorola and SPARC, unlike Intel). */ #ifndef WORDS_BIGENDIAN @@ -435,10 +430,9 @@ #cmakedefine _LARGE_FILES #endif -/* If the compiler does not support function attributes via __attribute__, - we just define __attribute__(a) to nothing. */ -#ifndef __attribute__ -#cmakedefine __attribute__(a) +/* Does your compiler support `__attribute__'? */ +#if !defined(__has_attribute) && !defined(__attribute__) +#define __attribute__(a) #endif /* Disable __GNUC__ on Intel compiler */ @@ -446,17 +440,23 @@ #undef __GNUC__ #endif -/* Does your compiler support the `_Noreturn' specifier? (C11 feature) */ +/* Does your compiler support `_Noreturn' keyword? (C11 feature) */ #ifndef _Noreturn #cmakedefine _Noreturn @_Noreturn@ #endif -/* Does your compiler support the `__restrict' specifier? */ +#ifndef __cplusplus +/* Does your compiler support `inline' keyword? (C99 feature) */ +#ifndef inline +#cmakedefine inline @inline@ +#endif +/* Does your compiler support `restrict' keyword? (C99 feature) */ #ifndef restrict #cmakedefine restrict @restrict@ #endif +#endif -/* Define to `int' if <sys/types.h> does not define. */ +/* Does your compiler support `ssize_t' type? (Posix type) */ #ifndef ssize_t #cmakedefine ssize_t @ssize_t@ #endif _______________________________________________ checkin-list mailing list checkin-list@monetdb.org https://www.monetdb.org/mailman/listinfo/checkin-list