Skip to content

Commit a742c23

Browse files
committed
Add some fix to allow MinGW32 compilation
1 parent 5937d61 commit a742c23

File tree

7 files changed

+26
-6
lines changed

7 files changed

+26
-6
lines changed

cdk/cmake/DepFindProtobuf.cmake

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -95,6 +95,17 @@ if(CMAKE_GENERATOR_TOOLSET)
9595
set(set_toolset -T ${CMAKE_GENERATOR_TOOLSET})
9696
endif()
9797

98+
# CMAKE_HOST_SYSTEM_NAME
99+
set(set_system_name)
100+
if(CMAKE_SYSTEM_NAME)
101+
set(set_system_name -DCMAKE_SYSTEM_NAME=${CMAKE_SYSTEM_NAME})
102+
endif()
103+
104+
set(set_system_processor)
105+
if(CMAKE_SYSTEM_PROCESSOR)
106+
set(set_system_processor -DCMAKE_SYSTEM_PROCESSOR=${CMAKE_SYSTEM_PROCESSOR})
107+
endif()
108+
98109
if(NOT EXISTS "${PB_BINARY_DIR}/exports.cmake")
99110

100111
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")
114125
${set_arch}
115126
${set_toolset}
116127
${set_build_type}
128+
${set_system_name}
129+
${set_system_processor}
117130
-DSTATIC_MSVCRT=${STATIC_MSVCRT}
118131
-DCMAKE_POSITION_INDEPENDENT_CODE=${CMAKE_POSITION_INDEPENDENT_CODE}
119132
-DCMAKE_CXX_COMPILER=${CMAKE_CXX_COMPILER}
@@ -322,7 +335,8 @@ function(mysqlx_protobuf_generate_cpp SRCS HDRS)
322335
set_source_files_properties(${srcs}
323336
APPEND_STRING PROPERTY COMPILE_FLAGS "-w"
324337
)
325-
ELSE(WIN32)
338+
ENDIF()
339+
IF(MSVC)
326340
set_source_files_properties(${srcs}
327341
APPEND_STRING PROPERTY COMPILE_FLAGS
328342
"/W1 /wd4018 /wd4996 /wd4244 /wd4267"

cdk/foundation/CMakeLists.txt

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -94,7 +94,11 @@ target_link_libraries(cdk_foundation
9494
)
9595

9696
IF(WIN32)
97-
target_link_libraries(cdk_foundation PRIVATE Dnsapi)
97+
if(MSVC)
98+
target_link_libraries(cdk_foundation PRIVATE Dnsapi)
99+
else()
100+
target_link_libraries(cdk_foundation PRIVATE dnsapi)
101+
endif()
98102
ELSEIF(NOT FREEBSD)
99103
target_link_libraries(cdk_foundation PRIVATE resolv)
100104
ENDIF()

cdk/foundation/connection_openssl.cc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,7 @@ POP_SYS_WARNINGS_CDK
4949
#pragma comment directive.
5050
*/
5151

52-
#ifdef _WIN32
52+
#ifdef _MSC_VER
5353
#pragma comment(lib,"ws2_32")
5454
#if defined(WITH_SSL)
5555
#if OPENSSL_VERSION_NUMBER < 0x10100000L

cdk/foundation/socket_detail.cc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -844,7 +844,7 @@ int poll_one(Socket socket, Poll_mode mode, bool wait,
844844

845845
DIAGNOSTIC_PUSH_CDK
846846

847-
#ifdef _WIN32
847+
#ifdef _MSC_VER
848848
// 4548 = expression has no effect
849849
// This warning is generated by FD_SET
850850
DISABLE_WARNING_CDK(4548)

cdk/mysqlx/CMakeLists.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ ADD_DEFINITIONS(-DSIZEOF_LONG=${SIZEOF_LONG} -DSIZEOF_LONG_LONG=${SIZEOF_LONG_LO
3333

3434
# TODO: Fix compile warnings in auth_mysql41.cc
3535

36-
if(WIN32)
36+
if(MSVC)
3737
set_property(SOURCE auth_hash.cc
3838
PROPERTY COMPILE_FLAGS "/W3"
3939
)

cdk/parser/parser.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@
3535
#include "tokenizer.h"
3636

3737

38-
#ifdef _WIN32
38+
#ifdef _MSC_VER
3939

4040
/*
4141
4061 = enum constant not explicitly handled by switch() case.

common/session.cc

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -119,7 +119,9 @@ std::string get_os_version_info(std::string &platform)
119119
else
120120
{
121121
PUSH_SYS_WARNINGS
122+
#ifdef _MSC_VER
122123
DISABLE_WARNING(4996)
124+
#endif
123125
if (GetVersionEx(&ver) == 0)
124126
ver_info << "<unknown>";
125127
POP_SYS_WARNINGS

0 commit comments

Comments
 (0)