From 5937d61c1058728488ea9b027857be5f5459c625 Mon Sep 17 00:00:00 2001 From: Eric Beuque Date: Mon, 13 Jul 2020 12:16:58 +0000 Subject: [PATCH 1/3] Set some compiler option only for MSVC --- cdk/extra/zlib/CMakeLists.txt | 2 +- cdk/protobuf/CMakeLists.txt | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/cdk/extra/zlib/CMakeLists.txt b/cdk/extra/zlib/CMakeLists.txt index b80a084a..f6fb4bdc 100644 --- a/cdk/extra/zlib/CMakeLists.txt +++ b/cdk/extra/zlib/CMakeLists.txt @@ -141,7 +141,7 @@ string(REGEX REPLACE ".*#define[ \t]+ZLIB_VERSION[ \t]+\"([-0-9A-Za-z.]+)\".*" # ------------------------------------------------------------------------- # Disable compile warnings -if(WIN32) +if(MSVC) add_compile_options( /wd4996 diff --git a/cdk/protobuf/CMakeLists.txt b/cdk/protobuf/CMakeLists.txt index c5fb588a..11727b40 100644 --- a/cdk/protobuf/CMakeLists.txt +++ b/cdk/protobuf/CMakeLists.txt @@ -163,7 +163,7 @@ if(APPLE) endif() -if(WIN32) +if(MSVC) add_compile_options( /wd4018 From a742c23a499cc4d3d0c06156bf6bbde65bebf733 Mon Sep 17 00:00:00 2001 From: Eric Beuque Date: Mon, 13 Jul 2020 12:16:58 +0000 Subject: [PATCH 2/3] Add some fix to allow MinGW32 compilation --- cdk/cmake/DepFindProtobuf.cmake | 16 +++++++++++++++- cdk/foundation/CMakeLists.txt | 6 +++++- cdk/foundation/connection_openssl.cc | 2 +- cdk/foundation/socket_detail.cc | 2 +- cdk/mysqlx/CMakeLists.txt | 2 +- cdk/parser/parser.h | 2 +- common/session.cc | 2 ++ 7 files changed, 26 insertions(+), 6 deletions(-) diff --git a/cdk/cmake/DepFindProtobuf.cmake b/cdk/cmake/DepFindProtobuf.cmake index e3726831..0dd5b4d5 100644 --- a/cdk/cmake/DepFindProtobuf.cmake +++ b/cdk/cmake/DepFindProtobuf.cmake @@ -95,6 +95,17 @@ if(CMAKE_GENERATOR_TOOLSET) set(set_toolset -T ${CMAKE_GENERATOR_TOOLSET}) endif() +# CMAKE_HOST_SYSTEM_NAME +set(set_system_name) +if(CMAKE_SYSTEM_NAME) + set(set_system_name -DCMAKE_SYSTEM_NAME=${CMAKE_SYSTEM_NAME}) +endif() + +set(set_system_processor) +if(CMAKE_SYSTEM_PROCESSOR) + set(set_system_processor -DCMAKE_SYSTEM_PROCESSOR=${CMAKE_SYSTEM_PROCESSOR}) +endif() + if(NOT EXISTS "${PB_BINARY_DIR}/exports.cmake") message("==== Configuring Protobuf build using cmake generator: ${CMAKE_GENERATOR} ${set_arch} ${set_toolset}") @@ -114,6 +125,8 @@ if(NOT EXISTS "${PB_BINARY_DIR}/exports.cmake") ${set_arch} ${set_toolset} ${set_build_type} + ${set_system_name} + ${set_system_processor} -DSTATIC_MSVCRT=${STATIC_MSVCRT} -DCMAKE_POSITION_INDEPENDENT_CODE=${CMAKE_POSITION_INDEPENDENT_CODE} -DCMAKE_CXX_COMPILER=${CMAKE_CXX_COMPILER} @@ -322,7 +335,8 @@ function(mysqlx_protobuf_generate_cpp SRCS HDRS) set_source_files_properties(${srcs} APPEND_STRING PROPERTY COMPILE_FLAGS "-w" ) - ELSE(WIN32) + ENDIF() + IF(MSVC) set_source_files_properties(${srcs} APPEND_STRING PROPERTY COMPILE_FLAGS "/W1 /wd4018 /wd4996 /wd4244 /wd4267" diff --git a/cdk/foundation/CMakeLists.txt b/cdk/foundation/CMakeLists.txt index 0a34c7d7..f9b7c00e 100644 --- a/cdk/foundation/CMakeLists.txt +++ b/cdk/foundation/CMakeLists.txt @@ -94,7 +94,11 @@ target_link_libraries(cdk_foundation ) IF(WIN32) - target_link_libraries(cdk_foundation PRIVATE Dnsapi) + if(MSVC) + target_link_libraries(cdk_foundation PRIVATE Dnsapi) + else() + target_link_libraries(cdk_foundation PRIVATE dnsapi) + endif() ELSEIF(NOT FREEBSD) target_link_libraries(cdk_foundation PRIVATE resolv) ENDIF() diff --git a/cdk/foundation/connection_openssl.cc b/cdk/foundation/connection_openssl.cc index 2f00503f..95aa4de5 100644 --- a/cdk/foundation/connection_openssl.cc +++ b/cdk/foundation/connection_openssl.cc @@ -49,7 +49,7 @@ POP_SYS_WARNINGS_CDK #pragma comment directive. */ -#ifdef _WIN32 +#ifdef _MSC_VER #pragma comment(lib,"ws2_32") #if defined(WITH_SSL) #if OPENSSL_VERSION_NUMBER < 0x10100000L diff --git a/cdk/foundation/socket_detail.cc b/cdk/foundation/socket_detail.cc index 1bb2b7b4..71854455 100644 --- a/cdk/foundation/socket_detail.cc +++ b/cdk/foundation/socket_detail.cc @@ -844,7 +844,7 @@ int poll_one(Socket socket, Poll_mode mode, bool wait, DIAGNOSTIC_PUSH_CDK -#ifdef _WIN32 +#ifdef _MSC_VER // 4548 = expression has no effect // This warning is generated by FD_SET DISABLE_WARNING_CDK(4548) diff --git a/cdk/mysqlx/CMakeLists.txt b/cdk/mysqlx/CMakeLists.txt index c92d8004..afacde65 100644 --- a/cdk/mysqlx/CMakeLists.txt +++ b/cdk/mysqlx/CMakeLists.txt @@ -33,7 +33,7 @@ ADD_DEFINITIONS(-DSIZEOF_LONG=${SIZEOF_LONG} -DSIZEOF_LONG_LONG=${SIZEOF_LONG_LO # TODO: Fix compile warnings in auth_mysql41.cc -if(WIN32) +if(MSVC) set_property(SOURCE auth_hash.cc PROPERTY COMPILE_FLAGS "/W3" ) diff --git a/cdk/parser/parser.h b/cdk/parser/parser.h index 84dc3189..e1e31cc9 100644 --- a/cdk/parser/parser.h +++ b/cdk/parser/parser.h @@ -35,7 +35,7 @@ #include "tokenizer.h" -#ifdef _WIN32 +#ifdef _MSC_VER /* 4061 = enum constant not explicitly handled by switch() case. diff --git a/common/session.cc b/common/session.cc index 1cc891e9..7b1806c2 100644 --- a/common/session.cc +++ b/common/session.cc @@ -119,7 +119,9 @@ std::string get_os_version_info(std::string &platform) else { PUSH_SYS_WARNINGS +#ifdef _MSC_VER DISABLE_WARNING(4996) +#endif if (GetVersionEx(&ver) == 0) ver_info << ""; POP_SYS_WARNINGS From 82e81dd0e39cb43634268a2e288e09004d204892 Mon Sep 17 00:00:00 2001 From: Eric Beuque Date: Wed, 15 Jul 2020 12:20:06 +0000 Subject: [PATCH 3/3] More fix for MingGW32 compilation --- cdk/extra/uuid/src/uuid_gen.cc | 2 ++ cdk/foundation/socket_detail.cc | 2 ++ 2 files changed, 4 insertions(+) diff --git a/cdk/extra/uuid/src/uuid_gen.cc b/cdk/extra/uuid/src/uuid_gen.cc index dca7c896..6bf20cfc 100644 --- a/cdk/extra/uuid/src/uuid_gen.cc +++ b/cdk/extra/uuid/src/uuid_gen.cc @@ -41,6 +41,7 @@ #ifdef _WIN32 +#ifndef __WINPTHREADS_VERSION typedef CRITICAL_SECTION pthread_mutex_t; typedef DWORD pthread_t; typedef struct thread_attr { @@ -55,6 +56,7 @@ typedef struct thread_attr { #define pthread_mutex_trylock(A) win_pthread_mutex_trylock((A)) #define pthread_mutex_unlock(A) (LeaveCriticalSection(A), 0) #define pthread_mutex_destroy(A) (DeleteCriticalSection(A), 0) +#endif #else diff --git a/cdk/foundation/socket_detail.cc b/cdk/foundation/socket_detail.cc index 71854455..9ba45aa3 100644 --- a/cdk/foundation/socket_detail.cc +++ b/cdk/foundation/socket_detail.cc @@ -74,6 +74,8 @@ namespace detail { Used for handling Winsock errors. */ +const error_category& winsock_error_category(); + class error_category_winsock : public error_category_base { error_category_winsock() {}