diff --git a/CMakeLists.txt b/CMakeLists.txt index e87a67076..3abc8ce7f 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -271,11 +271,35 @@ endif() # TODO: Fix these warnings. # -if(MSVC) +# TODO: Also cover linker warnings + +add_config_option(WERROR BOOL ADVANCED DEFAULT OFF + "Turn compile warnings into errors" +) + +# +# Note: If WERROR is enabled we change its value to be the actual compiler +# option to be used on the current platform. That is used for easier +# propagation to external builds. +# +# Note: In more recent cmake there is CMAKE_COMPILE_WARNING_AS_ERROR variable +# but at the moment we can't ensure using that recent cmake. +# + +if(WERROR) + set(WERROR -Werror) +endif() + +if(MSVC OR TOOLSET_MSVC) add_definitions(-D_CRT_SECURE_NO_WARNINGS -D_SCL_SECURE_NO_WARNINGS) if(CXX_FRONTEND_MSVC) + + if(WERROR) + set(WERROR /WX) # MSVC equivalent of -Werror + endif() + # Disable MSVC unreachable code warnings unless requested. add_compile_options(/wd4702) @@ -283,12 +307,14 @@ if(MSVC) # Seehttps://connect.microsoft.com/VisualStudio/feedback/details/897611/incorrect-warning-of-c4297-for-destructor-with-try-catch-statement add_compile_options(/wd4297) + endif() -endif() +elseif(SUNPRO) + # Note: For simplicity we do not handle WERROR on SunOS -if(SUNPRO) + set(WERROR) add_compile_options( -errtags=yes -erroff=hidevf,wvarhidemem @@ -296,7 +322,20 @@ if(SUNPRO) endif() -if (CMAKE_COMPILER_IS_GNUCC AND CMAKE_CXX_COMPILER_VERSION VERSION_GREATER 12.0) +if(NOT WERROR) + # clear if WERROR was set to something like OFF or FALSE + # message(STATUS "WERROR: cleared") + unset(WERROR CACHE) +else() + # overwrite cache entry with changed value + set(WERROR "${WERROR}" CACHE INTERNAL "WERROR flags" FORCE) +endif() + +# message(STATUS "WERROR: ${WERROR}") +add_compile_options(${WERROR}) + + +if (GCC AND GCC VERSION_GREATER 11) # Silence a warning produced by a regression in GCC 12.0 and newer # https://gcc.gnu.org/bugzilla/show_bug.cgi?id=106199 # Note: The stringop-overflow warnings are shown also during linking phase @@ -383,7 +422,8 @@ if(MAINTAINER_MODE) # (and this is the case for MSVC 2015). # See: http://en.cppreference.com/w/cpp/language/copy_assignment - add_compile_options(/W4 /wd4512 /wd4127) + set_warnings_level(4) + add_compile_options(/wd4512 /wd4127) elseif(SUNPRO) else() diff --git a/LICENSE.txt b/LICENSE.txt index 0603db9cc..8256a84c6 100644 --- a/LICENSE.txt +++ b/LICENSE.txt @@ -1,6 +1,6 @@ Licensing Information User Manual -MySQL Connector/C++ 9.2.0 Community +MySQL Connector/C++ 9.3.0 Community __________________________________________________________________ Introduction @@ -8,18 +8,18 @@ Introduction This License Information User Manual contains Oracle's product license and other licensing information, including licensing information for third-party software which may be included in this distribution of - MySQL Connector/C++ 9.2.0 Community. + MySQL Connector/C++ 9.3.0 Community. - Last updated: November 2024 + Last updated: March 2025 Licensing Information - This release of MySQL Connector/C++ 9.2.0 Community is brought to you + This release of MySQL Connector/C++ 9.3.0 Community is brought to you by the MySQL team at Oracle. This software is released under version 2 of the GNU General Public License (GPLv2), as set forth below, with the following additional permissions: - This distribution of MySQL Connector/C++ 9.2.0 Community is designed to + This distribution of MySQL Connector/C++ 9.3.0 Community is designed to work with certain software (including but not limited to OpenSSL) that is licensed under separate terms, as designated in a particular file or component or in the license documentation. Without limiting your rights @@ -34,7 +34,7 @@ Licensing Information a copy of which is reproduced below and can also be found along with its FAQ at http://oss.oracle.com/licenses/universal-foss-exception. - Copyright (c) 2008, 2024, Oracle and/or its affiliates. + Copyright (c) 2008, 2025, Oracle and/or its affiliates. Election of GPLv2 @@ -2142,49 +2142,20 @@ but the Oracle program might not operate properly or at all without it. // SPDX-License-Identifier: Apache-2.0 LICENSE: - Apache License - Version 2.0, January 2004 - http://www.apache.org/licenses/ -A copy of the Apache License v2.0, January 2004 license can be found -in the 'Standard Licenses' section. - - -4th party code included -======================= -exporters/etw -------------- -TraceLogging Dynamic for Windows - -Copyright (c) Microsoft Corporation. All rights reserved. - -MIT License - -Permission is hereby granted, free of charge, to any person obtaining a copy -of this software and associated documentation files (the "Software"), to deal -in the Software without restriction, including without limitation the rights -to use, copy, modify, merge, publish, distribute, sublicense, and/or sell -copies of the Software, and to permit persons to whom the Software is -furnished to do so, subject to the following conditions: -The above copyright notice and this permission notice shall be included in all -copies or substantial portions of the Software. - -THE SOFTWARE IS PROVIDED *AS IS*, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE -AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, -OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE -SOFTWARE. + Apache License + Version 2.0, January 2004 + http://www.apache.org/licenses/ +A copy of the Apache License v2.0, January 2004 license can be found +in the 'Standard Licenses' section. -4th Party Libraries -=================== +4th Party Dependencies +====================== opentelemetry-proto ------------------- // Copyright 2019, OpenTelemetry Authors -// Copyright 2020, OpenTelemetry Authors // // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. @@ -2198,48 +2169,75 @@ opentelemetry-proto // See the License for the specific language governing permissions and // limitations under the License. -Apache License Text as listed above +Some files include +// Copyright 2020, OpenTelemetry Authors +(same license header) + +A copy of the Apache License v2.0, January 2004 license can be found +in the 'Standard Licenses' section. + +================================================================================ +== ------------------------------------------------------------------------------- protobuf -------- +COPYRIGHT AND PERMISSION NOTICE -Copyright 2008 Google Inc. All rights reserved. +Copyright (c) 1996 - 2024, Daniel Stenberg, , and many +contributors, see the THANKS file. -Redistribution and use in source and binary forms, with or without -modification, are permitted provided that the following conditions are -met: +All rights reserved. - * Redistributions of source code must retain the above copyright -notice, this list of conditions and the following disclaimer. - * Redistributions in binary form must reproduce the above -copyright notice, this list of conditions and the following disclaimer -in the documentation and/or other materials provided with the -distribution. - * Neither the name of Google Inc. nor the names of its -contributors may be used to endorse or promote products derived from -this software without specific prior written permission. +Permission to use, copy, modify, and distribute this software for any purpose +with or without fee is hereby granted, provided that the above copyright +notice and this permission notice appear in all copies. -THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT OF THIRD PARTY RIGHTS. IN +NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, +DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR +OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE +OR OTHER DEALINGS IN THE SOFTWARE. -Code generated by the Protocol Buffer compiler is owned by the owner -of the input file used when generating it. This code is not -standalone and requires a support library to be linked with it. This -support library is itself covered by the above license. +Except as contained in this notice, the name of a copyright holder shall not +be used in advertising or otherwise to promote the sale, use or other dealings +in this Software without prior written authorization of the copyright holder. + +Protobuf dependency - abseil-cpp +-------------------------------- +=== Header in source files: +// Copyright 2017 The Abseil Authors. +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// https://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// +// This header file contains C++11 versions of standard header +// abstractions available within C++14 and C++17, and are designed to be drop-in +// replacement for code compliant with C++14 and C++17. + +=== License File + Apache License + Version 2.0, January 2004 + https://www.apache.org/licenses/ + +A copy of the Apache License v2.0, January 2004 license can be found +in the 'Standard Licenses' section. +================================================================================ +== ------------------------------------------------------------------------------- json (nlohmann) ---- + MIT License Copyright (c) 2013-2022 Niels Lohmann @@ -2262,14 +2260,14 @@ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. ------------------------------------------------------------------------------- - +================================================================================ +== curl ---- COPYRIGHT AND PERMISSION NOTICE -Copyright (c) 1996 - 2023, Daniel Stenberg, , and many +Copyright (c) 1996 - 2024, Daniel Stenberg, , and many contributors, see the THANKS file. All rights reserved. diff --git a/cdk/CMakeLists.txt b/cdk/CMakeLists.txt index dc8e3adc6..1e0fb41a7 100644 --- a/cdk/CMakeLists.txt +++ b/cdk/CMakeLists.txt @@ -28,9 +28,9 @@ -CMAKE_MINIMUM_REQUIRED(VERSION 3.8) +CMAKE_MINIMUM_REQUIRED(VERSION 3.15) -cmake_policy(VERSION 3.0) +cmake_policy(VERSION 3.15) if(POLICY CMP0022) cmake_policy(SET CMP0022 NEW) # consistently use INTERFACE_LINK_LIBRARIES property @@ -150,7 +150,7 @@ IF(MSVC) # TODO: move to /Wall when code base is ready for this - add_compile_options(/W4) + set_warnings_level(4) # Note: We disable warnings related to C++11 language because we want this # to be pure C++ code. diff --git a/cdk/cmake/DepFindProtobuf.cmake b/cdk/cmake/DepFindProtobuf.cmake index 1fc785e31..6e020fc87 100644 --- a/cdk/cmake/DepFindProtobuf.cmake +++ b/cdk/cmake/DepFindProtobuf.cmake @@ -115,7 +115,7 @@ function(mysqlx_protobuf_generate_cpp SRCS HDRS) ELSEIF(MSVC) set_source_files_properties(${srcs} APPEND_STRING PROPERTY COMPILE_FLAGS - "/W1 /wd4018 /wd4996 /wd4244 /wd4267" + "/wd4018 /wd4996 /wd4244 /wd4267" ) ENDIF() diff --git a/cdk/cmake/compiler/MSVC.cmake b/cdk/cmake/compiler/MSVC.cmake index 5a6d3d80d..71e8e10c6 100644 --- a/cdk/cmake/compiler/MSVC.cmake +++ b/cdk/cmake/compiler/MSVC.cmake @@ -89,6 +89,16 @@ function(set_visibility) endfunction() +function(set_warnings_level N) + + # Note: The /Wn flag must be set only once, otherwise msvc shows warnings + + string(REGEX REPLACE "/W[123456789]" "" CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS}") + set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} /W${N}") + +endfunction() + + function(set_msvcrt TYPE) if(TYPE MATCHES "^(STATIC|Static|static)$") diff --git a/cdk/cmake/dependency.cmake b/cdk/cmake/dependency.cmake index e3fec4ee2..1f4410329 100644 --- a/cdk/cmake/dependency.cmake +++ b/cdk/cmake/dependency.cmake @@ -60,6 +60,7 @@ set(EXT_FWD CMAKE_SYSTEM_PROCESSOR CMAKE_C_COMPILER CMAKE_CXX_COMPILER MSVC + WERROR ) set(EXT_DIR ${CMAKE_CURRENT_LIST_DIR}/ext CACHE INTERNAL "external project utils location") @@ -129,7 +130,7 @@ function(add_ext NAME HEADER) "${EXT_LIB} library name" ) - + #show_config_options() # Handle non-path value of WITH_X option diff --git a/cdk/cmake/gtest.cmake b/cdk/cmake/gtest.cmake index 3a79ad3a3..3e53ba29a 100644 --- a/cdk/cmake/gtest.cmake +++ b/cdk/cmake/gtest.cmake @@ -32,9 +32,6 @@ # Set up gtest for use by targets in given folder and its sub-folders. # MACRO(SETUP_GTEST) - IF (WITH_GTEST) - INCLUDE_DIRECTORIES(${GTEST_INCLUDE_DIRS}) - ENDIF (WITH_GTEST) ENDMACRO(SETUP_GTEST) @@ -135,6 +132,14 @@ MESSAGE("gtest_main location: ${gtest_main_location}") add_library(gtest STATIC IMPORTED) add_library(gtest_main STATIC IMPORTED) +target_include_directories(gtest INTERFACE ${GTEST_INCLUDE_DIRS}) + +# See: https://stackoverflow.com/questions/42847103/stdtr1-with-visual-studio-2017 + +target_compile_definitions(gtest INTERFACE + -DGTEST_LANG_CXX11=1 +) + set_target_properties(gtest PROPERTIES IMPORTED_LINK_INTERFACE_LANGUAGES "CXX" IMPORTED_LOCATION "${gtest_location}" diff --git a/cdk/cmake/platform.cmake b/cdk/cmake/platform.cmake index e76a45e7c..fc3fe6c00 100644 --- a/cdk/cmake/platform.cmake +++ b/cdk/cmake/platform.cmake @@ -115,6 +115,17 @@ macro(add_flags LANG) set(CMAKE_${LANG}_FLAGS "${CMAKE_${LANG}_FLAGS}" PARENT_SCOPE) endmacro() +include(CheckCXXCompilerFlag) + +# Set single compiler flag only if it is supported, ignore otherwise + +macro(set_compiler_flag FLAG) + unset(flag_supported CACHE) + CHECK_CXX_COMPILER_FLAG(${FLAG} flag_supported) + if(flag_supported) + add_compile_options(${FLAG}) + endif() +endmacro() # ----------------------------------------------------------------- diff --git a/cdk/cmake/testing.cmake b/cdk/cmake/testing.cmake index bfdc8d92c..662fba98d 100644 --- a/cdk/cmake/testing.cmake +++ b/cdk/cmake/testing.cmake @@ -144,6 +144,7 @@ IF(WITH_TESTS) set_global(test_tests ${test_tests}) add_library(${TEST} OBJECT ${ARGN}) + target_link_libraries(${TEST} gtest) set_target_properties(${TEST} PROPERTIES FOLDER "Tests") target_include_directories(${TEST} PRIVATE ${test_includes}) @@ -153,12 +154,11 @@ IF(WITH_TESTS) if (MSVC) target_compile_definitions(${TEST} PRIVATE + -D_CRT_SECURE_NO_WARNINGS -D_SCL_SECURE_NO_WARNINGS - -D_SILENCE_TR1_NAMESPACE_DEPRECATION_WARNING ) target_compile_options(${TEST} PRIVATE - /W3 /wd4244 /wd4267 /wd4701 @@ -166,8 +166,6 @@ IF(WITH_TESTS) /wd4456 # declaration of hides previous local declaration ) - target_compile_options(${TEST} PUBLIC /std:c++14) - if(STATIC_TESTS_MSVCRT) target_compile_options(${TEST} PRIVATE $<$:/MTd> @@ -295,10 +293,7 @@ IF(WITH_TESTS) if (MSVC) - target_compile_definitions(${target_run_unit_tests} PRIVATE - -D_SCL_SECURE_NO_WARNINGS - -D_SILENCE_TR1_NAMESPACE_DEPRECATION_WARNING - ) + set_warnings_level(3) target_compile_options(${target_run_unit_tests} PRIVATE /wd4244 diff --git a/cdk/extra/lz4/CMakeLists.txt b/cdk/extra/lz4/CMakeLists.txt index 7e5db8567..ebcf76173 100644 --- a/cdk/extra/lz4/CMakeLists.txt +++ b/cdk/extra/lz4/CMakeLists.txt @@ -34,6 +34,10 @@ include(platform) enable_pic() +if(WERROR) + add_compile_options(${WERROR}) +endif() + add_library(lz4 STATIC lib/lz4.c lib/lz4frame.c diff --git a/cdk/extra/protobuf/CMakeLists.txt b/cdk/extra/protobuf/CMakeLists.txt index adc19f55d..a787985f5 100644 --- a/cdk/extra/protobuf/CMakeLists.txt +++ b/cdk/extra/protobuf/CMakeLists.txt @@ -73,6 +73,10 @@ SET(PROTO_SRC_DIR "${PROJECT_SOURCE_DIR}/protobuf-3.19.6") enable_pic() enable_cxx17() +if(WERROR) + add_compile_options(${WERROR}) +endif() + # -O3 using GCC on SPARC leds to segfault on protoc if(SPARC AND GCC) foreach(LANG C CXX) @@ -90,12 +94,22 @@ endif() set_visibility(hidden) -if(NOT TOOLSET_MSVC AND NOT APPLE) - add_compile_options(-Wno-stringop-overflow -Wno-stringop-overread) +if(GCC AND GCC VERSION_GREATER 11) + # See: https://gcc.gnu.org/bugzilla/show_bug.cgi?id=106199 + set_compiler_flag(-Wno-stringop-overflow) + set_compiler_flag(-Wno-stringop-overread) +endif() + +if(NOT MSVC OR CLANG) + set_compiler_flag(-Wno-unused-const-variable) +endif() + +if(WIN32) + add_compile_definitions(_CRT_SECURE_NO_WARNINGS _SCL_SECURE_NO_WARNINGS) endif() if(APPLE) - add_compile_options(-Wno-deprecated-declarations) + set_compiler_flag(-Wno-deprecated-declarations) endif() diff --git a/cdk/extra/zlib/CMakeLists.txt b/cdk/extra/zlib/CMakeLists.txt index b3ebd214d..2c6928d25 100644 --- a/cdk/extra/zlib/CMakeLists.txt +++ b/cdk/extra/zlib/CMakeLists.txt @@ -7,8 +7,32 @@ set(CMAKE_ALLOW_LOOSE_LOOP_CONSTRUCTS ON) set(VERSION "1.3.1") project(zlib VERSION ${VERSION} LANGUAGES C) +include(../setup.cmake) +include(platform) -option(ZLIB_BUILD_EXAMPLES "Enable Zlib Examples" ON) +enable_pic() + +if(WERROR) + add_compile_options(${WERROR}) +endif() + +if(WIN32) + + add_compile_definitions(_CRT_SECURE_NO_WARNINGS _SCL_SECURE_NO_WARNINGS) + + # warning triggered by one of the sources: + # The POSIX name for this item is deprecated. Instead, use the ISO C and C++ + # conformant name: _open. See online help for details. + + if(CLANG) + add_compile_options(-Wno-deprecated-declarations) + else() + add_compile_options(/wd4996) + endif() + +endif() + +option(ZLIB_BUILD_EXAMPLES "Enable Zlib Examples" OFF) IF(DISABLE_THESE_LINES) set(INSTALL_BIN_DIR "${CMAKE_INSTALL_PREFIX}/bin" CACHE PATH "Installation directory for executables") @@ -148,8 +172,6 @@ file(READ ${CMAKE_CURRENT_SOURCE_DIR}/zlib.h _zlib_h_contents) string(REGEX REPLACE ".*#define[ \t]+ZLIB_VERSION[ \t]+\"([-0-9A-Za-z.]+)\".*" "\\1" ZLIB_FULL_VERSION ${_zlib_h_contents}) -add_compile_options(-fPIC) - add_library(zlib STATIC ${ZLIB_SRCS} ${ZLIB_PUBLIC_HDRS} ${ZLIB_PRIVATE_HDRS}) target_include_directories(zlib PUBLIC diff --git a/cdk/extra/zstd/CMakeLists.txt b/cdk/extra/zstd/CMakeLists.txt index 0ed58f630..af505f3b0 100644 --- a/cdk/extra/zstd/CMakeLists.txt +++ b/cdk/extra/zstd/CMakeLists.txt @@ -15,6 +15,16 @@ include(platform) enable_pic() +if(WERROR) + add_compile_options(${WERROR}) +endif() + +if(WIN32 AND CLANG) + # This warning shows only when building with clang on Win (clang 18): + # lib\compress\huf_compress.c(519,16): error : unused function 'HUF_isSorted' + set_compiler_flag(-Wno-unused-function) +endif() + SET(ZSTD_LIB_DIR "${PROJECT_SOURCE_DIR}/lib") diff --git a/cdk/mysqlx/CMakeLists.txt b/cdk/mysqlx/CMakeLists.txt index aa358f039..871740b82 100644 --- a/cdk/mysqlx/CMakeLists.txt +++ b/cdk/mysqlx/CMakeLists.txt @@ -31,14 +31,6 @@ ADD_DEFINITIONS(-DWIN32_LEAN_AND_MEAN -DNOGDI) ADD_DEFINITIONS(-DNOMINMAX) ADD_DEFINITIONS(-DSIZEOF_LONG=${SIZEOF_LONG} -DSIZEOF_LONG_LONG=${SIZEOF_LONG_LONG}) -# TODO: Fix compile warnings in auth_mysql41.cc - -if(MSVC) - set_property(SOURCE auth_hash.cc - PROPERTY COMPILE_FLAGS "/W3" - ) -endif() - file(GLOB HEADERS *.h) ADD_LIBRARY(cdk_mysqlx STATIC diff --git a/common/CMakeLists.txt b/common/CMakeLists.txt index 587340e3e..2114b6ede 100644 --- a/common/CMakeLists.txt +++ b/common/CMakeLists.txt @@ -29,6 +29,26 @@ file(GLOB HEADERS *.h) +#TODO: Remove -Wno-delete-non-abstract-non-virtual-dtor when bumping ABI and +# adding virtual destructor for DbDoc, Value and Column_detail + +if(CLANG) + +set_compiler_flag(-Wno-delete-non-abstract-non-virtual-dtor) + + # Note: GCC/clang and MSVC compilers have different rules for resolving + # relative paths in #include "..." directives [1]. The clang-cl compiler + # understands both conventions but gives warning when using MSVC rules. Since + # headers included by this code trigger the warning we disable it here (this + # is about version_info.h included from nysqlx/common_constants.h) + # + # [1] https://stackoverflow.com/questions/48538707/include-search-paths-from-included-header-varies-for-different-compilers + + set_compiler_flag(-Wno-microsoft-include) + +endif() + + add_library(common STATIC session.cc result.cc collection.cc value.cc ${HEADERS} @@ -36,13 +56,6 @@ add_library(common STATIC target_link_libraries(common cdk) -#TODO: Remove -Wno-delete-non-abstract-non-virtual-dtor when bumping ABI and - # adding virtual destructor for DbDoc, Value and Column_detail -if(CLANG) - target_compile_options(common PRIVATE - -Wno-delete-non-abstract-non-virtual-dtor - ) -endif() # # Note: generated version_info.h is placed in the build location diff --git a/common/tests/CMakeLists.txt b/common/tests/CMakeLists.txt index a70e13164..aac020043 100644 --- a/common/tests/CMakeLists.txt +++ b/common/tests/CMakeLists.txt @@ -36,14 +36,6 @@ set_property( PROPERTY COMPILE_DEFINITIONS "" ) -if(WIN32) - add_definitions( - -D_CRT_SECURE_NO_WARNINGS - -D_SILENCE_TR1_NAMESPACE_DEPRECATION_WARNING - ) - -endif() - #Add cdk includes because we are using their source tests add_test_includes(${PROJECT_SOURCE_DIR}/cdk/include) add_test_includes(${PROJECT_SOURCE_DIR}/cdk/extra/rapidjson/include) diff --git a/devapi/tests/CMakeLists.txt b/devapi/tests/CMakeLists.txt index 6c71501d4..d1201867f 100644 --- a/devapi/tests/CMakeLists.txt +++ b/devapi/tests/CMakeLists.txt @@ -38,13 +38,6 @@ set_property( PROPERTY COMPILE_DEFINITIONS "" ) -if(WIN32) - add_definitions( - -D_CRT_SECURE_NO_WARNINGS - -D_SILENCE_TR1_NAMESPACE_DEPRECATION_WARNING - ) - -endif() # # If linking with connector statically, define macro that indicates this diff --git a/doc/doxygen.cfg b/doc/doxygen.cfg index 2468e4ff0..495d48568 100644 --- a/doc/doxygen.cfg +++ b/doc/doxygen.cfg @@ -75,7 +75,7 @@ PROJECT_NAME = "MySQL Connector/C++" # could be handy for archiving the generated documentation or if some version # control system is used. -PROJECT_NUMBER = 9.2.0 +PROJECT_NUMBER = 9.3.0 # Using the PROJECT_BRIEF tag one can provide an optional one line description # for a project that appears at the top of each page and should give viewer a diff --git a/include/mysqlx/devapi/document.h b/include/mysqlx/devapi/document.h index 442dab71c..95c29358f 100644 --- a/include/mysqlx/devapi/document.h +++ b/include/mysqlx/devapi/document.h @@ -360,6 +360,7 @@ class Value CATCH_AND_WRAP } + virtual ~Value() {} public: diff --git a/include/mysqlx/devapi/result.h b/include/mysqlx/devapi/result.h index 3c9e4f971..904636e74 100644 --- a/include/mysqlx/devapi/result.h +++ b/include/mysqlx/devapi/result.h @@ -484,6 +484,9 @@ class Column public: + virtual ~Column() + {} + friend RowResult; struct INTERNAL Access; friend Access; diff --git a/jdbc/CMakeLists.txt b/jdbc/CMakeLists.txt index 60e36e42d..11fc3e4e1 100644 --- a/jdbc/CMakeLists.txt +++ b/jdbc/CMakeLists.txt @@ -215,10 +215,8 @@ if(NOT SHOW_JDBC_WARNINGS) else() - add_compile_options( - -Wno-unused-parameter - -Wno-deprecated-declarations - ) + set_compiler_flag(-Wno-unused-parameter) + set_compiler_flag(-Wno-deprecated-declarations) endif() @@ -266,25 +264,12 @@ add_version_info(connector-jdbc "Implements MySQL Connector/C++ legacy JDBC API." ) +# Note: The MySQL::client target works (and is needed) both when linking +# to the MySQL client library dynamically and statically. In the latter case +# it brings additional linker options that are required (e.g. to resolve +# dependencies of the client library code). - -# Note: When connector links statically to the client library, targets using -# the connector must be able to find dependencies of the client library, such -# as openssl libs. The MYSQL_EXTERNAL_SEARCHPATH variable set by DepFindMySQL. -# cmake stores detected locations where client library dependencies that -# are bundled with it can be found. We add it here as interface property -# so that other targets that link with the connector will have library search -# path correctly set in the compile line. -# -# TODO: Modify merge_libraries() logic to autmatically detect transitive link -# directory path properties of merged targets and then set them on the merged -# library target. - -if(MYSQLCLIENT_STATIC_LINKING) - target_link_directories(connector-jdbc INTERFACE - ${MYSQL_EXTERNAL_SEARCHPATH} - ) -endif() +target_link_libraries(connector-jdbc PUBLIC MySQL::client) # @@ -573,6 +558,18 @@ function(bundle_lib lib) DESTINATION "${INSTALL_LIB_DIR}" COMPONENT JDBCDll ) + # Symlinks need to be created to allow authenticating + # plugins to load dependencies in MacOS + # + # NOTE: in Linux the dependencies are adressed in + # a different way + install(CODE " + execute_process( + COMMAND ${CMAKE_COMMAND} -E create_symlink ../${lib_name} ${lib_name} + WORKING_DIRECTORY \"\$ENV{DESTDIR}\${CMAKE_INSTALL_PREFIX}/${INSTALL_LIB_DIR}/plugin\" + ) + ") + else() install(FILES ${lib} DESTINATION "${INSTALL_LIB_DIR}/private" @@ -663,6 +660,26 @@ macro(bundle_libs to_bundle ignored) endforeach() + if(APPLE) + # Create symlinks for OpenSSL dependencies in MacOS. + # The actual OpenSSL libraries should already be + # installed with XDevAPI connector. + # Other dependencies such as fido2 already have symlinks + # created at this stage. + install(CODE " + foreach(openssl_lib ssl crypto) + file(GLOB found_libs \"\$ENV{DESTDIR}\${CMAKE_INSTALL_PREFIX}/${INSTALL_LIB_DIR}/lib\${openssl_lib}.*dylib\") + foreach(lib_file \${found_libs}) + get_filename_component(openssl_lib_name \${lib_file} NAME) + execute_process( + COMMAND ${CMAKE_COMMAND} -E create_symlink ../\${openssl_lib_name} \${openssl_lib_name} + WORKING_DIRECTORY \"\$ENV{DESTDIR}\${CMAKE_INSTALL_PREFIX}/${INSTALL_LIB_DIR}/plugin\" + ) + endforeach(lib_file) + endforeach(openssl_lib) + ") + endif() + endmacro(bundle_libs) diff --git a/jdbc/cmake/DepFindMySQL.cmake b/jdbc/cmake/DepFindMySQL.cmake index 971bfd58c..c94b770cd 100644 --- a/jdbc/cmake/DepFindMySQL.cmake +++ b/jdbc/cmake/DepFindMySQL.cmake @@ -297,7 +297,6 @@ function(main) if(MYSQL_LIB_STATIC) target_link_libraries(mysql-client-if INTERFACE MySQL::client-static) - target_link_libraries(mysql-client-if INTERFACE OpenSSL::SSL) else() target_link_libraries(mysql-client-if INTERFACE MySQL::client-shared) endif() @@ -379,7 +378,7 @@ function(main) # # If external dependencies were found, add them to the static target - # as any code that liks to static library should also link with the + # as any code that links to static library should also link with the # external dependencies. # @@ -531,7 +530,8 @@ function(use_mysql_config) # option. if(NOT lib MATCHES - "(mysqlclient|libmysql|^stdc|^gcc|^CrunG3|^c$|^statomic|^ssl|^crypto)" + "(mysqlclient|libmysql|^stdc|^gcc|^CrunG3|^c$|^statomic)" + #|^ssl|^crypto)" ) list(APPEND MYSQL_EXTERNAL_DEPENDENCIES ${lib}) diff --git a/jdbc/cppconn/callback.h b/jdbc/cppconn/callback.h index af555326b..0ff7f3aa1 100644 --- a/jdbc/cppconn/callback.h +++ b/jdbc/cppconn/callback.h @@ -133,6 +133,8 @@ class WebAuthn_Callback ActionRequested(msg); } + virtual ~WebAuthn_Callback() {} + }; @@ -188,6 +190,8 @@ class Fido_Callback FidoActionRequested(msg); } + virtual ~Fido_Callback() {} + friend class mysql::MySQL_Connection; friend class mysql::MySQL_Driver; }; diff --git a/jdbc/extra/otel/CMakeLists.txt b/jdbc/extra/otel/CMakeLists.txt index bbed9bdf4..0d3708fa7 100644 --- a/jdbc/extra/otel/CMakeLists.txt +++ b/jdbc/extra/otel/CMakeLists.txt @@ -19,6 +19,14 @@ if(NOT (WIN32 OR APPLE OR CMAKE_SYSTEM_NAME MATCHES "SunOS")) if(WIN32) # Note: warning C4996 is triggered by OTel headers (as of version 1.10.0) target_compile_definitions(otel_api INTERFACE _SILENCE_CXX17_RESULT_OF_DEPRECATION_WARNING) + + else() + + # Note: warning triggered by OTel headers reported by clang 18: + # builtin __has_trivial_copy is deprecated; use __is_trivially_copyable instead + + target_compile_options(otel_api INTERFACE -Wno-deprecated-builtins) + endif() endif() diff --git a/jdbc/test/CMakeLists.txt b/jdbc/test/CMakeLists.txt index a35b906fc..c8259b973 100644 --- a/jdbc/test/CMakeLists.txt +++ b/jdbc/test/CMakeLists.txt @@ -79,9 +79,6 @@ IF(MSBUILD) ADD_DEFINITIONS("-D_CRT_SECURE_NO_WARNINGS") ENDIF() -if(NOT MYSQLCLIENT_STATIC_LINKING) - list(APPEND MY_TARGET_LINK_LIBRARIES MySQL::client) -endif() IF(CMAKE_COMPILER_IS_GNUCC AND MYSQLCPPCONN_GCOV_ENABLE) SET(MY_GCOV_LINK_LIBRARIES gcov) diff --git a/mysql-concpp-config.cmake.in b/mysql-concpp-config.cmake.in index 7e04f0221..a6cbf3b8f 100644 --- a/mysql-concpp-config.cmake.in +++ b/mysql-concpp-config.cmake.in @@ -479,11 +479,12 @@ function(find_includes) #message(STATUS "Looking for headers at: ${INCLUDE_DIR}") + unset(MYSQL_CONCPP_INCLUDE_DIR CACHE) find_path(MYSQL_CONCPP_INCLUDE_DIR NAMES mysqlx/xdevapi.h PATHS ${INCLUDE_DIR} NO_DEFAULT_PATH - NO_CACHE + # NO_CACHE # Note: requires cmake 3.21 ) if(NOT MYSQL_CONCPP_INCLUDE_DIR) @@ -697,7 +698,7 @@ function(add_connector_target which tgt base_name) find_library(lib_path NAMES ${lib_name} ${find_lib_paths} ${win_opts} - NO_CACHE + # NO_CACHE ) if(lib_path) @@ -740,7 +741,7 @@ function(add_connector_target which tgt base_name) PATHS "${LIBRARY_DIR}/debug" ${win_opts} NO_DEFAULT_PATH - NO_CACHE + # NO_CACHE ) if(lib_path_debug) @@ -880,12 +881,13 @@ function(find_imp_lib var base_name path) set(CMAKE_FIND_LIBRARY_SUFFIXES .lib) #message("!!! Looking for import library for: ${path}") + unset(${var} CACHE) find_library(${var} NAMES ${base_name} PATHS ${base_path} PATH_SUFFIXES ${vs_suffix} NO_DEFAULT_PATH - NO_CACHE + # NO_CACHE ) if(NOT ${var}) @@ -918,19 +920,19 @@ function(find_deps) unset(ssl_lib CACHE) find_library(ssl_lib NAMES ssl libssl - PATHS ${LIB_PATH} + PATHS ${LIBRARY_DIR} PATH_SUFFIXES private ${vs_suffix} NO_DEFAULT_PATH - NO_CACHE + # NO_CACHE ) unset(ssl_crypto CACHE) find_library(ssl_crypto NAMES crypto libcrypto - PATHS ${LIB_PATH} + PATHS ${LIBRARY_DIR} PATH_SUFFIXES private ${vs_suffix} NO_DEFAULT_PATH - NO_CACHE + # NO_CACHE ) if(NOT ssl_lib OR NOT ssl_crypto) diff --git a/packaging/compat.patch b/packaging/compat.patch index be2cdc0bd..5b4befee7 100644 --- a/packaging/compat.patch +++ b/packaging/compat.patch @@ -33,7 +33,7 @@ index 8b960402..37fac11d 100644 # # Set higher warning level for the main connector code. diff --git a/doc/doxygen.cfg b/doc/doxygen.cfg -index 7bf32bcf..870d6ada 100644 +index 7bf32bcf..b3f2bee6 100644 --- a/doc/doxygen.cfg +++ b/doc/doxygen.cfg @@ -66,7 +66,7 @@ PROJECT_NAME = "MySQL Connector/C++" @@ -41,12 +41,12 @@ index 7bf32bcf..870d6ada 100644 # control system is used. -PROJECT_NUMBER = 8.0.23 -+PROJECT_NUMBER = 9.2.0 ++PROJECT_NUMBER = 9.3.0 # Using the PROJECT_BRIEF tag one can provide an optional one line description # for a project that appears at the top of each page and should give viewer a diff --git a/version.cmake b/version.cmake -index 53f8f540..54bc21b2 100644 +index 53f8f540..7e589341 100644 --- a/version.cmake +++ b/version.cmake @@ -34,8 +34,8 @@ set(COPYRIGHT_YEAR "2024" CACHE INTERNAL "version info") @@ -56,7 +56,7 @@ index 53f8f540..54bc21b2 100644 -set(CONCPP_VERSION_MAJOR 8 CACHE INTERNAL "version info") -set(CONCPP_VERSION_MINOR 4 CACHE INTERNAL "version info") +set(CONCPP_VERSION_MAJOR 9 CACHE INTERNAL "version info") -+set(CONCPP_VERSION_MINOR 2 CACHE INTERNAL "version info") ++set(CONCPP_VERSION_MINOR 3 CACHE INTERNAL "version info") set(CONCPP_VERSION_MICRO 0 CACHE INTERNAL "version info") # Level is "-alpha", "-beta", empty if GA set(CONCPP_VERSION_LEVEL "" CACHE INTERNAL "version info") diff --git a/testapp/CMakeLists.txt b/testapp/CMakeLists.txt index d70939162..2942c7693 100644 --- a/testapp/CMakeLists.txt +++ b/testapp/CMakeLists.txt @@ -75,12 +75,13 @@ function(find_openssl where) endif() endif() + unset(openssl CACHE) find_library(openssl NAMES ssl PATHS "${WITH_SSL}" PATH_SUFFIXES "" "lib" "lib64" NO_DEFAULT_PATH - NO_CACHE + # NO_CACHE # Note: requires cmake 3.21 ) if(NOT openssl) diff --git a/testing/CMakeLists.txt b/testing/CMakeLists.txt index 73c901b69..b8d76e616 100644 --- a/testing/CMakeLists.txt +++ b/testing/CMakeLists.txt @@ -49,25 +49,13 @@ endif() add_library(test_harness STATIC test_harness.cc) set_target_properties(test_harness PROPERTIES FOLDER "Tests") +target_link_libraries(test_harness PUBLIC gtest) + add_test_libraries(test_harness connector) add_test_includes(${CMAKE_CURRENT_SOURCE_DIR}) -if(MSVC) - - set(TEST_COMPILE_FLAGS - -D_SILENCE_TR1_NAMESPACE_DEPRECATION_WARNING - -D_CRT_SECURE_NO_WARNINGS - -D_SCL_SECURE_NO_WARNINGS - ) - - target_compile_definitions(test_harness PUBLIC - -D_SILENCE_TR1_NAMESPACE_DEPRECATION_WARNING - ) - - target_compile_options(test_harness PUBLIC /std:c++14) - -else() +if(NOT MSVC) set(TEST_COMPILE_FLAGS -Wno-sign-compare diff --git a/testing/find_package/CMakeLists.txt b/testing/find_package/CMakeLists.txt index e92ea2127..7135f04d3 100644 --- a/testing/find_package/CMakeLists.txt +++ b/testing/find_package/CMakeLists.txt @@ -124,11 +124,12 @@ macro(add_version_tests) if(WITH_CONCPP) - find_file(INFO_SRC + unset(INFO_SRC CACHE) + find_file(INFO_SRC NAME INFO_SRC PATHS ${WITH_CONCPP} NO_DEFAULT_PATH - NO_CACHE + #NO_CACHE # Note: requires cmake 3.21 ) else() @@ -210,7 +211,7 @@ macro(add_version_tests) # Prepare options for run_test.cmake - set(test_opts + set(test_opts "-DVERSION=${VERSION_${A}}" "-DWITH_DEBUG=${WITH_DEBUG}" ) @@ -256,12 +257,13 @@ macro(add_tests) if(WITH_SSL) + unset(openssl_lib CACHE) find_library(openssl_lib NAMES ssl libssl PATHS ${WITH_SSL} PATH_SUFFIXES lib NO_DEFAULT_PATH - NO_CACHE + # NO_CACHE ) endif() @@ -287,8 +289,8 @@ macro(add_tests) # Note: On Windows scenarios which build in Debug mode with static # connector library are added only if debug package is available. - if(WIN32 - AND A STREQUAL "static" + if(WIN32 + AND A STREQUAL "static" AND B STREQUAL "Debug" AND NOT WITH_DEBUG ) @@ -332,7 +334,7 @@ macro(add_tests) # # They are implemented by run_test.cmake -- see there. - add_test("config_${name_suffix}" + add_test("config_${name_suffix}" ${CMAKE_COMMAND} "-DCDK_DIR=${CDK_DIR}" "-DCONCPP_SRC_DIR=${HOME_DIR}/../.." @@ -347,7 +349,7 @@ macro(add_tests) FIXTURES_SETUP "${name_suffix}_configured" ) - add_test("build_${name_suffix}" + add_test("build_${name_suffix}" ${CMAKE_COMMAND} "-DCDK_DIR=${CDK_DIR}" "-DCONCPP_SRC_DIR=${HOME_DIR}/../.." @@ -365,7 +367,7 @@ macro(add_tests) message(STATUS "# added test: build_${name_suffix}") - add_test("check_${name_suffix}" + add_test("check_${name_suffix}" ${CMAKE_COMMAND} "-DCDK_DIR=${CDK_DIR}" "-DCONCPP_SRC_DIR=${HOME_DIR}/../.." diff --git a/testing/find_package/run_test.cmake b/testing/find_package/run_test.cmake index d4a2e0550..f3ca4b7bf 100644 --- a/testing/find_package/run_test.cmake +++ b/testing/find_package/run_test.cmake @@ -182,11 +182,11 @@ function(action_check) foreach(exec devapi_test xapi_test jdbc_test) set(exec_path) - find_program(exec_path + find_program(exec_path NAMES ${exec} PATHS "config_test/${out_dir}" NO_DEFAULT_PATH - NO_CACHE + # NO_CACHE # note: requires cmake 3.21 ) if(NOT EXISTS "${exec_path}") diff --git a/testing/tests.cmake b/testing/tests.cmake index 5258ce48a..edd8b7e3e 100644 --- a/testing/tests.cmake +++ b/testing/tests.cmake @@ -191,7 +191,12 @@ if(NOT DEFINED ABI_CHECK AND MSVC AND MAINTAINER_MODE) set(ABI_CHECK 1) endif() -if(ABI_CHECK) +# Note: The machinery we use to perform ABI checks works only +# with the original MSVC compiler which can produce required +# export map file, not with clang-cl (for which MSVC is also +# defined) + +if(ABI_CHECK AND MSVC AND NOT CLANG) add_abi_check() endif() diff --git a/version.cmake b/version.cmake index 1e24bb325..11a196aad 100644 --- a/version.cmake +++ b/version.cmake @@ -35,7 +35,7 @@ set(COPYRIGHT_YEAR "2025" CACHE INTERNAL "version info") # set(CONCPP_VERSION_MAJOR 9 CACHE INTERNAL "version info") -set(CONCPP_VERSION_MINOR 2 CACHE INTERNAL "version info") +set(CONCPP_VERSION_MINOR 3 CACHE INTERNAL "version info") set(CONCPP_VERSION_MICRO 0 CACHE INTERNAL "version info") # Level is "-alpha", "-beta", empty if GA set(CONCPP_VERSION_LEVEL "" CACHE INTERNAL "version info") diff --git a/xapi/tests/CMakeLists.txt b/xapi/tests/CMakeLists.txt index 1beda2812..5b1220455 100644 --- a/xapi/tests/CMakeLists.txt +++ b/xapi/tests/CMakeLists.txt @@ -36,12 +36,6 @@ set_property( PROPERTY COMPILE_DEFINITIONS "" ) -IF(WIN32) - add_definitions( - -D_SILENCE_TR1_NAMESPACE_DEPRECATION_WARNING - ) -ENDIF() - if(BUILD_STATIC) add_definitions(-DSTATIC_CONCPP) endif() diff --git a/xapi/tests/xapi-t.cc b/xapi/tests/xapi-t.cc index 11d22dcb4..95b2ec206 100644 --- a/xapi/tests/xapi-t.cc +++ b/xapi/tests/xapi-t.cc @@ -67,13 +67,15 @@ void check_compress(mysqlx_session_t *sess) buf_len = 65536; memset(buf, 0, buf_len); - EXPECT_NE(nullptr, row = mysqlx_row_fetch_one(res)); + row = mysqlx_row_fetch_one(res); + EXPECT_FALSE(nullptr == row); EXPECT_EQ(RESULT_OK, mysqlx_get_bytes(row, 0, 0, buf, &buf_len)); test_row("Test ", buf); buf_len = 65536; memset(buf, 0, buf_len); - EXPECT_NE(nullptr, row = mysqlx_row_fetch_one(res)); + row = mysqlx_row_fetch_one(res); + EXPECT_FALSE(nullptr == row); EXPECT_EQ(RESULT_OK, mysqlx_get_bytes(row, 0, 0, buf, &buf_len)); test_row("0123 ", buf); @@ -2552,7 +2554,6 @@ TEST_F(xapi, dns_srv) //Specifying a port number with DNS SRV lookup is not allowed. { - EXPECT_EQ(nullptr, mysqlx_get_client_from_url("mysqlx+srv://root@_mysqlx._tcp.localhost:33060", nullptr, &error)); std::cout << "Expected Error: " << mysqlx_error_message(error) << std::endl; @@ -2949,7 +2950,7 @@ TEST_F(xapi, tls_ver_ciphers) error = NULL; sess = mysqlx_get_session_from_options(opt, &error); mysqlx_free(error); - EXPECT_NE(NULL, sess); + EXPECT_FALSE(NULL == sess); mysqlx_session_close(sess); diff --git a/xapi/tests/xapi_crud-t.cc b/xapi/tests/xapi_crud-t.cc index 211ab8e50..82809858f 100644 --- a/xapi/tests/xapi_crud-t.cc +++ b/xapi/tests/xapi_crud-t.cc @@ -754,7 +754,7 @@ TEST_F(xapi, basic) const char *col_schema = mysqlx_column_get_schema(res, i); const char *col_cat = mysqlx_column_get_catalog(res, i); - EXPECT_NE(nullptr, col_cat); + EXPECT_FALSE(nullptr == col_cat); printf("\n Column # %d", i + 1); printf("\n * name: %s, orig name: %s, table: %s, orig table: %s, schema: %s, catalog: %s",