diff --git a/CMakeLists.txt b/CMakeLists.txt index c6ab664b6..2a27dacc4 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -65,8 +65,6 @@ set_property(GLOBAL PROPERTY USE_FOLDERS ON) PROJECT(MySQL_CONCPP) -include(version.cmake) - # Load cmake modules include(cdk/cmake/setup.cmake) @@ -77,6 +75,26 @@ include(dependency) # find_dependency() include(config_options) # add_config_option() include(libutils) # merge_libraries() +# +# Detect if we are configured as stand-alone project, or sub-project. +# + +if(PROJECT_NAME STREQUAL CMAKE_PROJECT_NAME) + + SET(concpp_stand_alone 1) + +else() + + MESSAGE("Building Connector/C++ as part of ${CMAKE_PROJECT_NAME} project") + SET(concpp_stand_alone 0) + set(WITH_TESTS OFF) + set(WITH_DOC OFF) + set(WITH_HEADER_CHECKS OFF) + +endif() + +include(version.cmake) + message("Building on system: ${CMAKE_SYSTEM} (${CMAKE_SYSTEM_PROCESSOR})") message("Using cmake generator: ${CMAKE_GENERATOR}") #message("Compiler identification: ${CMAKE_CXX_COMPILER_ID}") @@ -330,6 +348,17 @@ add_config_option(WITH_JDBC BOOL DEFAULT OFF if(WITH_JDBC) add_subdirectory(jdbc) + + # Note: These include paths are to be used in a build tree. In + # this situation the jdbc public headers are not installed yet and + # we use a copy of them placed inside the build tree. + + target_include_directories(connector-jdbc + PUBLIC "${PROJECT_BINARY_DIR}/jdbc/cppconn" + PUBLIC "${PROJECT_SOURCE_DIR}/include" + PUBLIC "${PROJECT_BINARY_DIR}/jdbc/include/jdbc" + ) + endif() @@ -416,6 +445,13 @@ add_custom_command(TARGET libconcpp POST_BUILD ) endif() +# +# Stop here if this is a sub-project of a bigger project. +# + +if (NOT concpp_stand_alone) + return() +endif() # # Install specifications @@ -488,18 +524,6 @@ if(BUILD_STATIC) add_definitions(-DSTATIC_CONCPP) endif() - -# Auto-generated test targets - -IF (WITH_TESTS) - # Unit tests declared with ADD_NG_TEST() (see cdk/cmake/testing.cmake) - ADD_TEST_TARGET() - - # Test for public headers declared with ADD_HEADERS() - # (see cdk/cmake/headers.cmake) - ADD_HEADERS_TEST() -ENDIF (WITH_TESTS) - # # Sample code to try things out # @@ -512,10 +536,6 @@ if(WITH_JDBC) add_executable(try_jdbc EXCLUDE_FROM_ALL try_jdbc.cc) target_link_libraries(try_jdbc connector-jdbc) - target_include_directories(try_jdbc - PRIVATE "${PROJECT_BINARY_DIR}/include/mysql" - PRIVATE "${PROJECT_BINARY_DIR}/include/jdbc/cppconn" - ) endif() @@ -555,67 +575,11 @@ endif() endif() # -# Linking test -# ------------ -# -# This test compiles test application using internal installation of built -# connector. It is important to work with installed files because otherwise -# cmake does its magic to resolve missing dependencies when building test code. -# We don't want this to happen to make sure that test code can be built with -# connector library only, as we distribute it. -# -# Note: internal installation into /install is done by directly -# executing cmake_install.cmake script which is generated by cmake. -# -# TODO: Also test dynamic linking (requires adopting test app project) +# Other tests. # -file(REMOVE_RECURSE ${PROJECT_BINARY_DIR}/link_test) -file(MAKE_DIRECTORY ${PROJECT_BINARY_DIR}/link_test) +include(testing/tests.cmake) -unset(jdbc_options) -if(WITH_JDBC) - #message("-- BOOST_ROOT: ${BOOST_ROOT}") - list(APPEND jdbc_options -DWITH_JDBC=ON -DWITH_BOOST=${BOOST_ROOT}) -endif() - -add_custom_target(link_test - COMMAND ${CMAKE_COMMAND} -E remove_directory ${PROJECT_BINARY_DIR}/install - COMMAND ${CMAKE_COMMAND} -E make_directory ${PROJECT_BINARY_DIR}/install - COMMAND ${CMAKE_COMMAND} - -D CMAKE_INSTALL_PREFIX=${PROJECT_BINARY_DIR}/install - -D CMAKE_INSTALL_CONFIG_NAME=$<$>:$>$<$>>:Release> - -P ${PROJECT_BINARY_DIR}/cmake_install.cmake - COMMAND ${CMAKE_COMMAND} -E remove -f ${PROJECT_BINARY_DIR}/link_test/CMakeCache.txt - COMMAND ${CMAKE_COMMAND} - -G "${CMAKE_GENERATOR}" - -D WITH_CONCPP=${PROJECT_BINARY_DIR}/install - -D WITH_SSL="${WITH_SSL}" - -D BUILD_STATIC=${BUILD_STATIC} - -D STATIC_MSVCRT=${STATIC_MSVCRT} - ${jdbc_options} - ${PROJECT_SOURCE_DIR}/testapp - COMMAND ${CMAKE_COMMAND} --build . --config $ --clean-first - WORKING_DIRECTORY ${PROJECT_BINARY_DIR}/link_test - VERBATIM -) - -set_target_properties(link_test PROPERTIES FOLDER "Tests") - -add_dependencies(link_test connector) -#if(TARGET connector-merge) -# add_dependencies(link_test connector-merge) -#endif() -#if(WITH_JDBC) -# add_dependencies(link_test build_jdbc) -#endif() - -# TDOD: Use ${CMAKE_COMMAND}, but evaluated at test time, not here. - -add_test(NAME Link_test - COMMAND cmake --build . --target link_test --config $ - WORKING_DIRECTORY ${PROJECT_BINARY_DIR} -) # # Create the INFO_SRC and INFO_BIN files diff --git a/LICENSE.txt b/LICENSE.txt index 4649957c5..def51a891 100644 --- a/LICENSE.txt +++ b/LICENSE.txt @@ -10,7 +10,7 @@ Introduction third-party software which may be included in this distribution of MySQL Connector/C++ 8.0. - Last updated: March 2020 + Last updated: June 2020 Licensing Information @@ -33,8 +33,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, 2020, Oracle and/or its affiliates. All rights - reserved. + Copyright (c) 2008, 2020, Oracle and/or its affiliates. Election of GPLv2 @@ -921,33 +920,38 @@ zlib Oracle gratefully acknowledges the contributions of Jean-loup Gailly and Mark Adler in creating the zlib general purpose compression library which is used in this product. -zlib.h -- interface of the 'zlib' general purpose compression library -Copyright (C) 1995-2004 Jean-loup Gailly and Mark Adler - -zlib.h -- interface of the 'zlib' general purpose compression library -version 1.2.3, July 18th, 2005 -Copyright (C) 1995-2005 Jean-loup Gailly and Mark Adler - -zlib.h -- interface of the 'zlib' general purpose compression library -version 1.2.5, April 19th, 2010 -Copyright (C) 1995-2010 Jean-loup Gailly and Mark Adler - -This software is provided 'as-is', without any express or implied warranty. -In no event will the authors be held liable for any damages arising from the -use of this software. Permission is granted to anyone to use this software -for any purpose,including commercial applications, and to alter it and -redistribute it freely, subject to the following restrictions: - -1. The origin of this software must not be misrepresented; you must not - claim that you wrote the original software. If you use this software - in a product, an acknowledgment in the product documentation would - be appreciated but is not required. -2. Altered source versions must be plainly marked as such, and must not - be misrepresented as being the original software. -3. This notice may not be removed or altered from any source distribution. - -Jean-loup Gailly jloup@gzip.org -Mark Adler madler@alumni.caltech.edu +(C) 1995-2017 Jean-loup Gailly and Mark Adler + + This software is provided 'as-is', without any express or implied + warranty. In no event will the authors be held liable for any damages + arising from the use of this software. + + Permission is granted to anyone to use this software for any purpose, + including commercial applications, and to alter it and redistribute it + freely, subject to the following restrictions: + + + 1. The origin of this software must not be misrepresented; you must not + claim that you wrote the original software. If you use this software + in a product, an acknowledgment in the product documentation would be + appreciated but is not required. + + 2. Altered source versions must be plainly marked as such, and must not be + misrepresented as being the original software. + + 3. This notice may not be removed or altered from any source distribution. + + Jean-loup Gailly Mark Adler + jloup@gzip.org madler@alumni.caltech.edu + +If you use the zlib library in a product, we would appreciate *not* receiving +lengthy legal documents to sign. The sources are provided for free but without +warranty of any kind. The library has been entirely written by Jean-loup +Gailly and Mark Adler; it does not include third-party code. + +If you redistribute modified sources, we would appreciate that you include in +the file ChangeLog history information documenting your changes. Please read +the FAQ for more information on the distribution of modified source versions. ZSTD diff --git a/buildinfo.cmake b/buildinfo.cmake index 82dadc704..7d038cb5c 100644 --- a/buildinfo.cmake +++ b/buildinfo.cmake @@ -100,7 +100,7 @@ FUNCTION(GENERATE_INFO_SRC) MESSAGE("Generating INFO_SRC") IF (NOT EXISTS INFO_SRC) - SET(INFO_VERSION "${CONCPP_PACKAGE_VERSION}") + SET(INFO_VERSION "${CONCPP_VERSION}") find_program(GIT_FOUND NAMES git) diff --git a/cdk/cmake/DepFindProtobuf.cmake b/cdk/cmake/DepFindProtobuf.cmake index e3726831f..0dd5b4d53 100644 --- a/cdk/cmake/DepFindProtobuf.cmake +++ b/cdk/cmake/DepFindProtobuf.cmake @@ -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}") @@ -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} @@ -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" diff --git a/cdk/extra/CMakeLists.txt b/cdk/extra/CMakeLists.txt index 8962067cf..ae16c5384 100644 --- a/cdk/extra/CMakeLists.txt +++ b/cdk/extra/CMakeLists.txt @@ -36,9 +36,13 @@ endif() enable_pic() add_subdirectory(zlib) +# Note: zlib writes configuration header into build location +# and this location needs to be added to include path when +# using zlib. + target_include_directories(zlib PUBLIC - ${PROJECT_BINARY_DIR}/extra/zlib - ${PROJECT_SOURCE_DIR}/extra/zlib + ${CMAKE_CURRENT_BINARY_DIR}/zlib + zlib ) @@ -55,7 +59,4 @@ target_include_directories(lz4 PUBLIC lz4) add_subdirectory(zstd) -target_include_directories(zstd PUBLIC - ${PROJECT_BINARY_DIR}/extra/zstd/lib - ${PROJECT_SOURCE_DIR}/extra/zstd/lib -) +target_include_directories(zstd PUBLIC zstd/lib) diff --git a/cdk/extra/zlib/CMakeLists.txt b/cdk/extra/zlib/CMakeLists.txt index b80a084af..f6fb4bdca 100644 --- a/cdk/extra/zlib/CMakeLists.txt +++ b/cdk/extra/zlib/CMakeLists.txt @@ -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 diff --git a/cdk/extra/zstd/CMakeLists.txt b/cdk/extra/zstd/CMakeLists.txt index f74c4b58d..737f69663 100644 --- a/cdk/extra/zstd/CMakeLists.txt +++ b/cdk/extra/zstd/CMakeLists.txt @@ -11,7 +11,7 @@ PROJECT(zstd) CMAKE_MINIMUM_REQUIRED(VERSION 2.8.9) SET(ZSTD_LIB_DIR - "${CMAKE_SOURCE_DIR}/cdk/extra/zstd/lib") + "${PROJECT_SOURCE_DIR}/lib") INCLUDE_DIRECTORIES( ${ZSTD_LIB_DIR} ${ZSTD_LIB_DIR}/common diff --git a/cdk/foundation/CMakeLists.txt b/cdk/foundation/CMakeLists.txt index 0a34c7d7e..f9b7c00e3 100644 --- a/cdk/foundation/CMakeLists.txt +++ b/cdk/foundation/CMakeLists.txt @@ -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() diff --git a/cdk/foundation/connection_openssl.cc b/cdk/foundation/connection_openssl.cc index 2f00503f1..95aa4de52 100644 --- a/cdk/foundation/connection_openssl.cc +++ b/cdk/foundation/connection_openssl.cc @@ -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 diff --git a/cdk/foundation/socket_detail.cc b/cdk/foundation/socket_detail.cc index 1bb2b7b49..9ba45aa33 100644 --- a/cdk/foundation/socket_detail.cc +++ b/cdk/foundation/socket_detail.cc @@ -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() {} @@ -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) diff --git a/cdk/mysqlx/CMakeLists.txt b/cdk/mysqlx/CMakeLists.txt index c92d8004d..afacde65f 100644 --- a/cdk/mysqlx/CMakeLists.txt +++ b/cdk/mysqlx/CMakeLists.txt @@ -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" ) diff --git a/cdk/parser/parser.h b/cdk/parser/parser.h index 84dc3189d..e1e31cc92 100644 --- a/cdk/parser/parser.h +++ b/cdk/parser/parser.h @@ -35,7 +35,7 @@ #include "tokenizer.h" -#ifdef _WIN32 +#ifdef _MSC_VER /* 4061 = enum constant not explicitly handled by switch() case. diff --git a/cdk/protobuf/CMakeLists.txt b/cdk/protobuf/CMakeLists.txt index c5fb588a3..11727b401 100644 --- a/cdk/protobuf/CMakeLists.txt +++ b/cdk/protobuf/CMakeLists.txt @@ -163,7 +163,7 @@ if(APPLE) endif() -if(WIN32) +if(MSVC) add_compile_options( /wd4018 diff --git a/cmake/libutils.cmake b/cmake/libutils.cmake index 958f564dd..35bb88b64 100644 --- a/cmake/libutils.cmake +++ b/cmake/libutils.cmake @@ -35,89 +35,100 @@ # Includes all transitive dependencies of the libraries being merged. # -get_filename_component(LIBUTILS_SCRIPT_DIR ${CMAKE_CURRENT_LIST_FILE} PATH) -set(LIBUTILS_SCRIPT_DIR "${LIBUTILS_SCRIPT_DIR}/libutils") +# Include this script only once. -# -# Locate required tools. -# +if(COMMAND libutils_setup) + return() +endif() -if(CMAKE_BUILD_TOOL MATCHES "MSBuild") - set(MSBUILD ON) +macro(libutils_setup) - # Use lib.exe from the same location as other compiler tools + get_filename_component(LIBUTILS_SCRIPT_DIR ${CMAKE_CURRENT_LIST_FILE} PATH) + set(LIBUTILS_SCRIPT_DIR "${LIBUTILS_SCRIPT_DIR}/libutils") + set(LIBUTILS_BIN_DIR "${CMAKE_CURRENT_BINARY_DIR}/libutils" CACHE INTERNAL "") - get_filename_component(path "${CMAKE_LINKER}" DIRECTORY) - set(LIB_TOOL "${path}/lib.exe") + # + # Locate required tools. + # -endif() + if(CMAKE_BUILD_TOOL MATCHES "MSBuild") + set(MSBUILD ON) -if(APPLE) + # Use lib.exe from the same location as other compiler tools - find_program(LIB_TOOL libtool) + get_filename_component(path "${CMAKE_LINKER}" DIRECTORY) + set(LIB_TOOL "${path}/lib.exe") - # We need install_name_tool to do rpath mangling (see below) + endif() - find_program(INSTALL_NAME_TOOL install_name_tool) - # If available, otool is used to show runtime dependencies for libraries we - # build + if(APPLE) - find_program(OTOOL otool) + find_program(LIB_TOOL libtool) -endif() + # We need install_name_tool to do rpath mangling (see below) + find_program(INSTALL_NAME_TOOL install_name_tool) -# -# Infrastructure for merging static libraries -# =========================================== -# -# It is used to merge a static library with all other static libraries -# on which it depends, so that, when using the merged library, one does -# not have to worry about dependencies. -# -# The main logic for mering static libraries on different platforms is -# in the merge_archives.cmake script. Calling merge_static_library() on -# a library target arranges for this script to be called with all required -# parameters every time the library is (re-)built. -# -# Extra effort is needed to get the list of all dependencies of the library. -# These dependencies are computed by cmake, but there is no easy way to -# get them out of cmake. We use the trick with custom language linker. Hovewer, -# it does not work with MSBuild generator where we do other tricks. In either -# case the idea is to define a phony target that depends on the static library -# and capture link options that cmake uses to build this phony target. -# + # If available, otool is used to show runtime dependencies for libraries we + # build -# -# Create merge script from template, setting required internal variables in it. -# -# TODO: This will work only if this file is included in the same folder in which -# static libraries are linked. -# + find_program(OTOOL otool) -configure_file( - ${LIBUTILS_SCRIPT_DIR}/merge_archives.cmake.in - ${CMAKE_CURRENT_BINARY_DIR}/merge_archives.cmake - @ONLY -) + endif() -# -# This small program saves in a file all command line options that -# were passed to it. It is used to capture linker invocation options. -# -if(NOT MSBUILD AND NOT TARGET save_linker_opts) - add_executable(save_linker_opts ${LIBUTILS_SCRIPT_DIR}/save_linker_opts.cc) - set_property(TARGET save_linker_opts PROPERTY - OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR} + # + # Infrastructure for merging static libraries + # =========================================== + # + # It is used to merge a static library with all other static libraries + # on which it depends, so that, when using the merged library, one does + # not have to worry about dependencies. + # + # The main logic for mering static libraries on different platforms is + # in the merge_archives.cmake script. Calling merge_static_library() on + # a library target arranges for this script to be called with all required + # parameters every time the library is (re-)built. + # + # Extra effort is needed to get the list of all dependencies of the library. + # These dependencies are computed by cmake, but there is no easy way to + # get them out of cmake. We use the trick with custom language linker. Hovewer, + # it does not work with MSBuild generator where we do other tricks. In either + # case the idea is to define a phony target that depends on the static library + # and capture link options that cmake uses to build this phony target. + # + + # + # Create merge script from template, setting required internal variables in it. + # + + configure_file( + ${LIBUTILS_SCRIPT_DIR}/merge_archives.cmake.in + ${LIBUTILS_BIN_DIR}/merge_archives.cmake + @ONLY ) -endif() + + # + # This small program saves in a file all command line options that + # were passed to it. It is used to capture linker invocation options. + # + + if(NOT MSBUILD AND NOT TARGET save_linker_opts) + add_executable(save_linker_opts ${LIBUTILS_SCRIPT_DIR}/save_linker_opts.cc) + set_property(TARGET save_linker_opts PROPERTY + RUNTIME_OUTPUT_DIRECTORY ${LIBUTILS_BIN_DIR} + ) + endif() + +endmacro(libutils_setup) + +libutils_setup() # -# Merge static libraries into single static or shared library. +# Merge static libraries into a single static or shared library. # # Given a static library target, this function sets up an infrastructure # for merging this static libraray with its dependencies. It creates @@ -185,7 +196,7 @@ function(merge_libraries TARGET) -DMSBUILD=${MSBUILD} -DINFO=${INFO} -DINFO_PREFIX=${INFO_PREFIX} - -P merge_archives.cmake + -P ${LIBUTILS_BIN_DIR}/merge_archives.cmake ) endif() @@ -218,7 +229,7 @@ function(merge_libraries TARGET) add_dependencies(${TARGET}-deps save_linker_opts) set_target_properties(${TARGET}-deps PROPERTIES - RULE_LAUNCH_LINK "${CMAKE_BINARY_DIR}/save_linker_opts ${log_file}.STATIC " + RULE_LAUNCH_LINK "${LIBUTILS_BIN_DIR}/save_linker_opts ${log_file}.STATIC " ) # Arrange for ${TARGET}-deps to be built before ${TARGET} @@ -236,7 +247,7 @@ function(merge_libraries TARGET) # set_target_properties(${TARGET} PROPERTIES - RULE_LAUNCH_LINK "${CMAKE_BINARY_DIR}/save_linker_opts ${log_file}.SHARED " + RULE_LAUNCH_LINK "${LIBUTILS_BIN_DIR}/save_linker_opts ${log_file}.SHARED " ) else(NOT MSBUILD) diff --git a/common/session.cc b/common/session.cc index d76d307e7..d3985c37e 100644 --- a/common/session.cc +++ b/common/session.cc @@ -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 << ""; POP_SYS_WARNINGS diff --git a/jdbc b/jdbc index 9de205246..d5b0788b3 160000 --- a/jdbc +++ b/jdbc @@ -1 +1 @@ -Subproject commit 9de2052461e5a9658456d9bbd1bef1ae1bf66075 +Subproject commit d5b0788b3fed063f421d3d1b9e50fca2c22017f7 diff --git a/packaging/mysql-connector-c++.spec.in b/packaging/mysql-connector-c++.spec.in index 20ba00513..dd4bd4721 100644 --- a/packaging/mysql-connector-c++.spec.in +++ b/packaging/mysql-connector-c++.spec.in @@ -48,6 +48,8 @@ %global dist .sl15 %endif +%global source_date_epoch_from_changelog 0 + Summary: MySQL database connector for C++ Name: mysql-connector-c++%{?product_suffix} Version: @CONCPP_VERSION@ @@ -222,6 +224,9 @@ rm %{buildroot}/usr/{INFO_SRC,INFO_BIN} %endif %changelog +* Thu Jun 04 2020 Gipson Pulla - 8.0.21-1 +- Updated the macro to use the system date + * Fri Feb 15 2019 Bjorn Munch - 8.0.16-1 - CMake 3 should not be used on Fedora, only on Oracle Linux or Red Hat - Removed use of cmake_path as it is no longer needed diff --git a/testing/sub_project_test/CMakeLists.txt b/testing/sub_project_test/CMakeLists.txt new file mode 100644 index 000000000..09ed927f0 --- /dev/null +++ b/testing/sub_project_test/CMakeLists.txt @@ -0,0 +1,99 @@ +# Copyright (c) 2020, Oracle and/or its affiliates. All rights reserved. +# +# This program is free software; you can redistribute it and/or modify +# it under the terms of the GNU General Public License, version 2.0, as +# published by the Free Software Foundation. +# +# This program is also distributed 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 included license +# documentation. The authors of MySQL hereby grant you an +# additional permission to link the program and your derivative works +# with the separately licensed software that they have included with +# MySQL. +# +# Without limiting anything contained in the foregoing, this file, +# which is part of MySQL Connector/C++, is also subject to the +# Universal FOSS Exception, version 1.0, a copy of which can be found at +# http://oss.oracle.com/licenses/universal-foss-exception. +# +# This program is distributed in the hope that it will be useful, but +# WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. +# See the GNU General Public License, version 2.0, for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program; if not, write to the Free Software Foundation, Inc., +# 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA + +cmake_minimum_required(VERSION 3.0) + +# +# This is test cmake project that uses Connector/C++ as a subproject, +# to verify that this usage scenario works. +# + +project(Sub_project_test C CXX) + +# +# Find Connector/C++ sources. +# + +if (NOT DEFINED CONCPP_SRC) + get_filename_component(CONCPP_SRC ../.. REALPATH) +endif() + +message("- using Con/C++ sources at: ${CONCPP_SRC}") + +if (NOT EXISTS ${CONCPP_SRC}/CMakeLists.txt) + message(FATAL_ERROR + "Could not find CMakeLists.txt at Con/C++ source location." + ) +endif() + +# +# If CONCPP_CACHE is defined, it should point at Connector/C++ +# build location where a cmake cache is stored. Various settings +# required to build connector source are read from that cache. +# + +if (DEFINED CONCPP_CACHE) + + message("- loading settings from Con/C++ cmake cache at: ${CONCPP_CACHE}") + load_cache(${CONCPP_CACHE} READ_WITH_PREFIX "" + WITH_SSL + WITH_JDBC + WITH_BOOST + WITH_MYSQL MYSQL_INCLUDE_DIR MYSQL_LIB_DIR MYSQL_CONFIG_EXECUTABLE + ) + + message("- WITH_SSL: ${WITH_SSL}") + message("- WITH_BOOST: ${WITH_BOOST}") + message("- WITH_MYSQL: ${WITH_MYSQL} (${MYSQL_INCLUDE_DIR} ${MYSQL_LIB_DIR})") + +endif() + +# +# Include Connector/C++ as a sub-project +# + +add_subdirectory(${CONCPP_SRC} connector-cpp) + +# +# Define test applications to verify that they build correctly. +# + +set(CMAKE_CXX_STANDARD 11) + +add_executable(devapi_test ${CONCPP_SRC}/testapp/devapi_test.cc) +target_link_libraries(devapi_test connector) + +add_executable(xapi_test ${CONCPP_SRC}/testapp/xapi_test.c) +target_link_libraries(xapi_test connector) + +if (WITH_JDBC) + + add_executable(jdbc_test ${CONCPP_SRC}/testapp/jdbc_test.cc) + target_link_libraries(jdbc_test connector-jdbc) + +endif() diff --git a/testing/tests.cmake b/testing/tests.cmake new file mode 100644 index 000000000..ebfebe419 --- /dev/null +++ b/testing/tests.cmake @@ -0,0 +1,155 @@ +# Copyright (c) 2020, Oracle and/or its affiliates. All rights reserved. +# +# This program is free software; you can redistribute it and/or modify +# it under the terms of the GNU General Public License, version 2.0, as +# published by the Free Software Foundation. +# +# This program is also distributed 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 included license +# documentation. The authors of MySQL hereby grant you an +# additional permission to link the program and your derivative works +# with the separately licensed software that they have included with +# MySQL. +# +# Without limiting anything contained in the foregoing, this file, +# which is part of MySQL Connector/C++, is also subject to the +# Universal FOSS Exception, version 1.0, a copy of which can be found at +# http://oss.oracle.com/licenses/universal-foss-exception. +# +# This program is distributed in the hope that it will be useful, but +# WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. +# See the GNU General Public License, version 2.0, for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program; if not, write to the Free Software Foundation, Inc., +# 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA + + +# Note: This file is meant to be included from the main CMakeLists.txt. +# It defines tests for the build tree. +# ===================================================================== + +# +# Note: We must clear compile flags - the ones used to build the connector +# are not good for building client code that uses the connector. +# + +set_property( + DIRECTORY . + PROPERTY COMPILE_DEFINITIONS "" +) + +if(BUILD_STATIC) + add_definitions(-DSTATIC_CONCPP) +endif() + + +# Auto-generated test targets + +IF (WITH_TESTS) + # Unit tests declared with ADD_NG_TEST() (see cdk/cmake/testing.cmake) + ADD_TEST_TARGET() + + # Test for public headers declared with ADD_HEADERS() + # (see cdk/cmake/headers.cmake) + ADD_HEADERS_TEST() +ENDIF (WITH_TESTS) + +# +# Sub-project test +# ---------------- +# +# This test checks using Con/C++ build system as a sub-project in +# a master cmake project. +# + +file(REMOVE_RECURSE ${PROJECT_BINARY_DIR}/sub_project_test) +file(MAKE_DIRECTORY ${PROJECT_BINARY_DIR}/sub_project_test) + +if(CMAKE_GENERATOR_PLATFORM) + list(APPEND cmake_options -A ${CMAKE_GENERATOR_PLATFORM}) +endif() + +if(CMAKE_GENERATOR_TOOLSET) + list(APPEND cmake_options -T ${CMAKE_GENERATOR_TOOLSET}) +endif() + +add_custom_target(sub_project_test + COMMAND ${CMAKE_COMMAND} -E remove -f ${PROJECT_BINARY_DIR}/sub_project_test/CMakeCache.txt + COMMAND ${CMAKE_COMMAND} + -G "${CMAKE_GENERATOR}" + ${cmake_options} + -D CONCPP_CACHE=${PROJECT_BINARY_DIR} + ${PROJECT_SOURCE_DIR}/testing/sub_project_test + COMMAND ${CMAKE_COMMAND} --build . --config $ --clean-first + WORKING_DIRECTORY ${PROJECT_BINARY_DIR}/sub_project_test + VERBATIM +) + +set_target_properties(sub_project_test PROPERTIES FOLDER "Tests") + + +# +# Linking test +# ------------ +# +# This test compiles test application using internal installation of built +# connector. It is important to work with installed files because otherwise +# cmake does its magic to resolve missing dependencies when building test code. +# We don't want this to happen to make sure that test code can be built with +# connector library only, as we distribute it. +# +# Note: internal installation into /install is done by directly +# executing cmake_install.cmake script which is generated by cmake. +# +# TODO: Also test dynamic linking (requires adopting test app project) +# + +file(REMOVE_RECURSE ${PROJECT_BINARY_DIR}/link_test) +file(MAKE_DIRECTORY ${PROJECT_BINARY_DIR}/link_test) + +unset(jdbc_options) +if(WITH_JDBC) + #message("-- BOOST_ROOT: ${BOOST_ROOT}") + list(APPEND jdbc_options -DWITH_JDBC=ON -DWITH_BOOST=${BOOST_ROOT}) +endif() + +add_custom_target(link_test + COMMAND ${CMAKE_COMMAND} -E remove_directory ${PROJECT_BINARY_DIR}/install + COMMAND ${CMAKE_COMMAND} -E make_directory ${PROJECT_BINARY_DIR}/install + COMMAND ${CMAKE_COMMAND} + -D CMAKE_INSTALL_PREFIX=${PROJECT_BINARY_DIR}/install + -D CMAKE_INSTALL_CONFIG_NAME=$<$>:$>$<$>>:Release> + -P ${PROJECT_BINARY_DIR}/cmake_install.cmake + COMMAND ${CMAKE_COMMAND} -E remove -f ${PROJECT_BINARY_DIR}/link_test/CMakeCache.txt + COMMAND ${CMAKE_COMMAND} + -G "${CMAKE_GENERATOR}" + -D WITH_CONCPP=${PROJECT_BINARY_DIR}/install + -D WITH_SSL="${WITH_SSL}" + -D BUILD_STATIC=${BUILD_STATIC} + -D STATIC_MSVCRT=${STATIC_MSVCRT} + ${jdbc_options} + ${PROJECT_SOURCE_DIR}/testapp + COMMAND ${CMAKE_COMMAND} --build . --config $ --clean-first + WORKING_DIRECTORY ${PROJECT_BINARY_DIR}/link_test + VERBATIM +) + +set_target_properties(link_test PROPERTIES FOLDER "Tests") + +add_dependencies(link_test connector) +#if(TARGET connector-merge) +# add_dependencies(link_test connector-merge) +#endif() +#if(WITH_JDBC) +# add_dependencies(link_test build_jdbc) +#endif() + +# TDOD: Use ${CMAKE_COMMAND}, but evaluated at test time, not here. + +add_test(NAME Link_test + COMMAND cmake --build . --target link_test --config $ + WORKING_DIRECTORY ${PROJECT_BINARY_DIR} +)