Skip to content

Commit de8e968

Browse files
committed
Use CLANG to build windows.
Change-Id: I8c3ab3bdc3f6b03c449a77af8ea630e14f2fe99a
1 parent e08e7ce commit de8e968

32 files changed

+185
-1982
lines changed

CMakeLists.txt

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -274,13 +274,15 @@ if(MSVC)
274274

275275
add_definitions(-D_CRT_SECURE_NO_WARNINGS -D_SCL_SECURE_NO_WARNINGS)
276276

277-
# Disable MSVC unreachable code warnings unless requested.
278-
add_compile_options(/wd4702)
277+
if(CXX_FRONTEND_MSVC)
278+
# Disable MSVC unreachable code warnings unless requested.
279+
add_compile_options(/wd4702)
279280

280-
# Disable MSVC warning C4297 as it seems to be buggy.
281-
# Seehttps://connect.microsoft.com/VisualStudio/feedback/details/897611/incorrect-warning-of-c4297-for-destructor-with-try-catch-statement
281+
# Disable MSVC warning C4297 as it seems to be buggy.
282+
# Seehttps://connect.microsoft.com/VisualStudio/feedback/details/897611/incorrect-warning-of-c4297-for-destructor-with-try-catch-statement
282283

283-
add_compile_options(/wd4297)
284+
add_compile_options(/wd4297)
285+
endif()
284286

285287
endif()
286288

cdk/cmake/DepFindSSL.cmake

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -116,8 +116,9 @@ function(main)
116116

117117
set_target_properties(openssl-applink PROPERTIES FOLDER "Misc")
118118
# Remove warnings from openssl applink.c
119-
target_compile_options(openssl-applink PRIVATE /wd4152 /wd4996)
120-
119+
if(CXX_FRONTEND_MSVC)
120+
target_compile_options(openssl-applink PRIVATE /wd4152 /wd4996)
121+
endif()
121122
endif()
122123

123124

cdk/cmake/compiler/CLANG.cmake

Lines changed: 28 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
# Copyright (c) 2019, 2022, Oracle and/or its affiliates. All rights reserved.
1+
# Copyright (c) 2019, 2023, Oracle and/or its affiliates. All rights reserved.
22
#
33
# This program is free software; you can redistribute it and/or modify
44
# it under the terms of the GNU General Public License, version 2.0, as
@@ -26,6 +26,28 @@
2626
# along with this program; if not, write to the Free Software Foundation, Inc.,
2727
# 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
2828

29+
#
30+
# TOOLSET and CXX_FRONTEND
31+
#
32+
if(WIN32)
33+
set(TOOLSET "MSVC" CACHE INTERNAL "")
34+
set(TOOLSET_MSVC "1" CACHE INTERNAL "")
35+
if(CMAKE_CXX_COMPILER_FRONTEND_VARIANT STREQUAL "MSVC")
36+
set(CXX_FRONTEND "MSVC" CACHE INTERNAL "")
37+
set(CXX_FRONTEND_MSVC "1" CACHE INTERNAL "")
38+
# clang-cl behaves has MSVC
39+
set(MSVC ${compiler_version} CACHE INTERNAL "")
40+
else()
41+
set(CXX_FRONTEND "GCC" CACHE INTERNAL "")
42+
set(CXX_FRONTEND_GCC "1" CACHE INTERNAL "")
43+
endif()
44+
else()
45+
set(TOOLSET "GCC" CACHE INTERNAL "")
46+
set(CXX_FRONTEND "GCC" CACHE INTERNAL "")
47+
set(TOOLSET_GCC "1" CACHE INTERNAL "")
48+
set(CXX_FRONTEND_GCC "1" CACHE INTERNAL "")
49+
endif()
50+
2951
function(enable_cxx17)
3052

3153
add_flags(CXX -std=c++17)
@@ -48,6 +70,11 @@ function(enable_cxx17)
4870

4971
endfunction()
5072

73+
function(enable_pic)
74+
if(TOOLSET_GCC)
75+
add_compile_options(-fPIC)
76+
endif()
77+
endfunction()
5178

5279
function(set_visibility)
5380
add_compile_options(-fvisibility-ms-compat)

cdk/cmake/compiler/GCC.cmake

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,14 @@
2828

2929
##########################################################################
3030

31+
#
32+
# TOOLSET and CXX_FRONTEND
33+
#
34+
set(TOOLSET "GCC" CACHE INTERNAL "")
35+
set(CXX_FRONTEND "GCC" CACHE INTERNAL "")
36+
set(TOOLSET_GCC "1" CACHE INTERNAL "")
37+
set(CXX_FRONTEND_GCC "1" CACHE INTERNAL "")
38+
3139
#
3240
# Ensure relative source locations in debug entries
3341
#

cdk/cmake/compiler/MSVC.cmake

Lines changed: 16 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,14 @@
3333

3434
set(ARCH ${MSVC_CXX_ARCHITECTURE_ID} CACHE INTERNAL "architecture id")
3535

36+
#
37+
# If clang-cl is used, we should still set CLANG variable
38+
#
39+
40+
if(compiler_id MATCHES "Clang")
41+
set(CLANG ${compiler_version} CACHE INTERNAL "")
42+
endif()
43+
3644
#
3745
# Set VS and VS_VER (MSVC toolset version)
3846
#
@@ -50,10 +58,14 @@ else()
5058

5159
endif()
5260

53-
#message("-- vs: ${VS}")
61+
#
62+
# TOOLSET and CXX_FRONTEND
63+
#
64+
set(TOOLSET "MSVC" CACHE INTERNAL "")
65+
set(CXX_FRONTEND "MSVC" CACHE INTERNAL "")
66+
set(TOOLSET_MSVC "1" CACHE INTERNAL "")
67+
set(CXX_FRONTEND_MSVC "1" CACHE INTERNAL "")
5468

55-
set(VS_VER ${VS} CACHE INTERNAL "")
56-
set(VS "vs${VS}" CACHE INTERNAL "")
5769

5870
#
5971
# Commands for global compiler options.
@@ -63,13 +75,7 @@ function(enable_pic)
6375
endfunction()
6476

6577
function(enable_cxx17)
66-
67-
# Note: std::shared_ptr<>::unique is deprecated in C++17 [1].
68-
# TODO: Remove Supression once WL15527 is implemented
69-
# [1] https://en.cppreference.com/w/cpp/memory/shared_ptr/unique
70-
71-
add_flags(CXX /std:c++17
72-
-D_SILENCE_CXX17_SHARED_PTR_UNIQUE_DEPRECATION_WARNING)
78+
add_flags(CXX /std:c++17)
7379
endfunction()
7480

7581
# Note: Needs to be implemented if we ever want to change the default

cdk/cmake/dependency.cmake

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -57,6 +57,7 @@ set(EXT_FWD
5757
CMAKE_SYSTEM_NAME CMAKE_SYSTEM_VERSION
5858
CMAKE_SYSTEM_PROCESSOR
5959
CMAKE_C_COMPILER CMAKE_CXX_COMPILER
60+
MSVC
6061
)
6162

6263
set(EXT_DIR ${CMAKE_CURRENT_LIST_DIR}/ext CACHE INTERNAL "external project utils location")

cdk/cmake/platform.cmake

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,16 @@
3838
# MSVC/GCC/CLANG/SUNPRO - if defined, set to compiler version
3939
# SPARC
4040
#
41+
# Variables used to define TOOLSET used to build connector
42+
# TOOLSET - currently GCC OR MSVC
43+
# TOOLSET_GCC - defined if TOOLSET = GCC
44+
# TOOLSET_MSVC - defined if TOOLSET = MSVC
45+
46+
# Variables used to define compiler frontend (command-line interface)
47+
# CXX_FRONTEND - currently GCC OR MSVC
48+
# CXX_FRONTEND_GCC - defined if CXX_FRONTEND = GCC
49+
# CXX_FRONTEND_MSVC - defined if CXX_FRONTEND = MSVC
50+
#
4151
# Defines the following commands:
4252
#
4353
# enable_pic()
@@ -196,6 +206,15 @@ else()
196206
endif()
197207

198208

209+
# Note: std::shared_ptr<>::unique is deprecated in C++17 [1].
210+
# TODO: Remove Supression once WL15527 is implemented
211+
# [1] https://en.cppreference.com/w/cpp/memory/shared_ptr/unique
212+
213+
if(TOOLSET_MSVC)
214+
add_flags(CXX -D_SILENCE_CXX17_SHARED_PTR_UNIQUE_DEPRECATION_WARNING)
215+
endif()
216+
217+
199218
########################################################################
200219

201220
function(platform_detection_completed)

cdk/extra/protobuf/CMakeLists.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -89,7 +89,7 @@ endif()
8989

9090
set_visibility(hidden)
9191

92-
if(NOT MSVC AND NOT APPLE)
92+
if(NOT TOOLSET_MSVC AND NOT APPLE)
9393
add_compile_options(-Wno-stringop-overflow -Wno-stringop-overread)
9494
endif()
9595

cdk/extra/protobuf/protobuf-3.19.6/cmake/CMakeLists.txt

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -149,7 +149,7 @@ find_package(Threads REQUIRED)
149149
### set(ZLIB_LIBRARIES)
150150
### endif (ZLIB_FOUND)
151151
### endif (protobuf_WITH_ZLIB)
152-
###
152+
###
153153
### if (HAVE_ZLIB)
154154
### add_definitions(-DHAVE_ZLIB)
155155
### endif (HAVE_ZLIB)
@@ -162,7 +162,7 @@ endif (protobuf_WITH_ZLIB)
162162
# We need to link with libatomic on systems that do not have builtin atomics, or
163163
# don't have builtin support for 8 byte atomics
164164
set(protobuf_LINK_LIBATOMIC false)
165-
if (NOT MSVC)
165+
if (TOOLSET_GCC)
166166
include(CheckCXXSourceCompiles)
167167
set(OLD_CMAKE_REQUIRED_FLAGS ${CMAKE_REQUIRED_FLAGS})
168168
set(CMAKE_REQUIRED_FLAGS ${CMAKE_REQUIRED_FLAGS} -std=c++11)
@@ -176,7 +176,7 @@ if (NOT MSVC)
176176
set(protobuf_LINK_LIBATOMIC true)
177177
endif (NOT protobuf_HAVE_BUILTIN_ATOMICS)
178178
set(CMAKE_REQUIRED_FLAGS ${OLD_CMAKE_REQUIRED_FLAGS})
179-
endif (NOT MSVC)
179+
endif ()
180180

181181
if (protobuf_BUILD_SHARED_LIBS)
182182
set(protobuf_SHARED_OR_STATIC "SHARED")

cdk/foundation/CMakeLists.txt

Lines changed: 0 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -36,34 +36,6 @@ set(CMAKE_REQUIRED_FLAGS "${CMAKE_REQUIRED_FLAGS} -std=c++17")
3636
include(CheckCXXSourceCompiles)
3737
include(CheckTypeSize)
3838

39-
CHECK_CXX_SOURCE_COMPILES(
40-
"#include <memory>
41-
void test(std::shared_ptr<int>) {};
42-
int main() { return 0; }"
43-
HAVE_SHARED_PTR
44-
)
45-
#message("HAVE_SHARED_PTR: ${HAVE_SHARED_PTR}")
46-
ADD_CONFIG(HAVE_SHARED_PTR)
47-
48-
if (NOT HAVE_SHARED_PTR)
49-
message(FATAL_ERROR "Type std::shared_ptr required by CDK is not available")
50-
endif()
51-
52-
53-
CHECK_CXX_SOURCE_COMPILES(
54-
"#include <system_error>
55-
void test(std::system_error) {};
56-
int main() { return 0; }"
57-
HAVE_SYSTEM_ERROR
58-
)
59-
#message("HAVE_SYSTEM_ERROR: ${HAVE_SYSTEM_ERROR}")
60-
ADD_CONFIG(HAVE_SYSTEM_ERROR)
61-
62-
if (NOT HAVE_SYSTEM_ERROR)
63-
message(FATAL_ERROR "Type std::system_error required by CDK is not available")
64-
endif()
65-
66-
6739
check_type_size("wchar_t" WCHAR_SIZE)
6840
add_config(WCHAR_SIZE ${WCHAR_SIZE})
6941

cdk/include/mysql/cdk/foundation/CMakeLists.txt

Lines changed: 0 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -26,32 +26,6 @@
2626
# along with this program; if not, write to the Free Software Foundation, Inc.,
2727
# 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
2828

29-
30-
set(CMAKE_REQUIRED_FLAGS "${CMAKE_REQUIRED_FLAGS} -std=c++11")
31-
32-
INCLUDE(CheckCXXSourceCompiles)
33-
34-
#
35-
# Required for static_assert.h
36-
#
37-
38-
#
39-
# Note: on OSX with clang compiler, it seems that <string> header
40-
# brings in definition of static-assert. I (Rafal) could not find
41-
# a better header that would work
42-
#
43-
44-
CHECK_CXX_SOURCE_COMPILES(
45-
"#include <string>
46-
int main() { static_assert(true,\"Ok\"); }"
47-
HAVE_STATIC_ASSERT)
48-
ADD_CONFIG(HAVE_STATIC_ASSERT)
49-
50-
CHECK_CXX_SOURCE_COMPILES(
51-
"void main() { return is_same<bool,char>::value; }"
52-
HAVE_IS_SAME)
53-
ADD_CONFIG(HAVE_IS_SAME)
54-
5529
FILE(GLOB headers *.h)
5630

5731
ADD_HEADERS(${headers})

cdk/include/mysql/cdk/foundation/common.h

Lines changed: 9 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,15 @@
3535
Macros used to disable warnings for fragments of code.
3636
*/
3737

38-
#if defined __GNUC__ || defined __clang__
38+
#if defined _MSC_VER
39+
40+
#define PRAGMA_CDK(X) __pragma(X)
41+
#define DISABLE_WARNING_CDK(W) PRAGMA_CDK(warning (disable:W))
42+
43+
#define DIAGNOSTIC_PUSH_CDK PRAGMA_CDK(warning (push))
44+
#define DIAGNOSTIC_POP_CDK PRAGMA_CDK(warning (pop))
45+
46+
#elif defined __GNUC__ || defined __clang__
3947

4048
#define PRAGMA_CDK(X) _Pragma(#X)
4149
#define DISABLE_WARNING_CDK(W) PRAGMA_CDK(GCC diagnostic ignored #W)
@@ -48,14 +56,7 @@
4856
#define DIAGNOSTIC_POP_CDK
4957
#endif
5058

51-
#elif defined _MSC_VER
52-
5359

54-
#define PRAGMA_CDK(X) __pragma(X)
55-
#define DISABLE_WARNING_CDK(W) PRAGMA_CDK(warning (disable:W))
56-
57-
#define DIAGNOSTIC_PUSH_CDK PRAGMA_CDK(warning (push))
58-
#define DIAGNOSTIC_POP_CDK PRAGMA_CDK(warning (pop))
5960

6061
#else
6162

cdk/include/mysql/cdk/foundation/opaque_impl.i

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,6 @@
4343
*/
4444

4545
#include "opaque_impl.h"
46-
#include "static_assert.h"
4746

4847
namespace cdk {
4948
namespace foundation {

0 commit comments

Comments
 (0)