Skip to content

Commit 256a5af

Browse files
author
Bogdan Degtyariov
committed
Improvements for preprocessor and cmake related to compiler and platform detection
1 parent 53a239f commit 256a5af

File tree

9 files changed

+22
-7
lines changed

9 files changed

+22
-7
lines changed

cdk/cmake/DepFindProtobuf.cmake

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

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

100110
message("==== Configuring Protobuf build using cmake generator: ${CMAKE_GENERATOR} ${set_arch} ${set_toolset}")
@@ -114,6 +124,8 @@ if(NOT EXISTS "${PB_BINARY_DIR}/exports.cmake")
114124
${set_arch}
115125
${set_toolset}
116126
${set_build_type}
127+
${set_system_name}
128+
${set_system_processor}
117129
-DSTATIC_MSVCRT=${STATIC_MSVCRT}
118130
-DCMAKE_POSITION_INDEPENDENT_CODE=${CMAKE_POSITION_INDEPENDENT_CODE}
119131
-DCMAKE_CXX_COMPILER=${CMAKE_CXX_COMPILER}
@@ -322,7 +334,7 @@ function(mysqlx_protobuf_generate_cpp SRCS HDRS)
322334
set_source_files_properties(${srcs}
323335
APPEND_STRING PROPERTY COMPILE_FLAGS "-w"
324336
)
325-
ELSE(WIN32)
337+
ELSEIF(MSVC)
326338
set_source_files_properties(${srcs}
327339
APPEND_STRING PROPERTY COMPILE_FLAGS
328340
"/W1 /wd4018 /wd4996 /wd4244 /wd4267"

cdk/extra/zlib/CMakeLists.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -141,7 +141,7 @@ string(REGEX REPLACE ".*#define[ \t]+ZLIB_VERSION[ \t]+\"([-0-9A-Za-z.]+)\".*"
141141
# -------------------------------------------------------------------------
142142
# Disable compile warnings
143143

144-
if(WIN32)
144+
if(MSVC)
145145

146146
add_compile_options(
147147
/wd4996

cdk/foundation/CMakeLists.txt

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

9696
IF(WIN32)
97-
target_link_libraries(cdk_foundation PRIVATE Dnsapi)
97+
target_link_libraries(cdk_foundation PRIVATE dnsapi)
9898
ELSEIF(NOT FREEBSD)
9999
target_link_libraries(cdk_foundation PRIVATE resolv)
100100
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 & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -73,6 +73,7 @@ namespace detail {
7373
7474
Used for handling Winsock errors.
7575
*/
76+
const error_category& winsock_error_category();
7677

7778
class error_category_winsock : public error_category_base
7879
{

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.

cdk/protobuf/CMakeLists.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -163,7 +163,7 @@ if(APPLE)
163163

164164
endif()
165165

166-
if(WIN32)
166+
if(MSVC)
167167

168168
add_compile_options(
169169
/wd4018

common/session.cc

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

0 commit comments

Comments
 (0)