Skip to content

Fix MinGW cross-compilation #24

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
wants to merge 4 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 15 additions & 1 deletion cdk/cmake/DepFindProtobuf.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -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}")
Expand All @@ -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}
Expand Down Expand Up @@ -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"
Expand Down
2 changes: 1 addition & 1 deletion cdk/extra/zlib/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
6 changes: 5 additions & 1 deletion cdk/foundation/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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()
Expand Down
2 changes: 1 addition & 1 deletion cdk/foundation/connection_openssl.cc
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
4 changes: 3 additions & 1 deletion cdk/foundation/socket_detail.cc
Original file line number Diff line number Diff line change
Expand Up @@ -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() {}
Expand Down Expand Up @@ -844,7 +846,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)
Expand Down
2 changes: 1 addition & 1 deletion cdk/mysqlx/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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"
)
Expand Down
2 changes: 1 addition & 1 deletion cdk/parser/parser.h
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@
#include "tokenizer.h"


#ifdef _WIN32
#ifdef _MSC_VER

/*
4061 = enum constant not explicitly handled by switch() case.
Expand Down
2 changes: 1 addition & 1 deletion cdk/protobuf/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -163,7 +163,7 @@ if(APPLE)

endif()

if(WIN32)
if(MSVC)

add_compile_options(
/wd4018
Expand Down
2 changes: 2 additions & 0 deletions common/session.cc
Original file line number Diff line number Diff line change
Expand Up @@ -118,7 +118,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 << "<unknown>";
POP_SYS_WARNINGS
Expand Down