diff options
| author | Ethan Morgan <ethan@gweithio.com> | 2026-02-14 16:44:06 +0000 |
|---|---|---|
| committer | Ethan Morgan <ethan@gweithio.com> | 2026-02-14 16:44:06 +0000 |
| commit | 54409423f767d8b1cf30cb7d0efca6b4ca138823 (patch) | |
| tree | d915ac7828703ce4b963efdd9728a1777ba18c1e /vcpkg/ports/mysql-connector-cpp | |
Diffstat (limited to 'vcpkg/ports/mysql-connector-cpp')
13 files changed, 591 insertions, 0 deletions
diff --git a/vcpkg/ports/mysql-connector-cpp/cmake-project-include.cmake b/vcpkg/ports/mysql-connector-cpp/cmake-project-include.cmake new file mode 100644 index 0000000..9d22462 --- /dev/null +++ b/vcpkg/ports/mysql-connector-cpp/cmake-project-include.cmake @@ -0,0 +1,61 @@ +#[[ + vcpkg overloads find_package(). + mysql-connector-cpp overloads find_dependency(). + + To force a strict order of desired effects and to prevent undesired effects, + without heavy patching: + 1. All pristine find_package() must be done here first. + This is with pristine vcpkg toolchain find_package()/find_dependency(). + 2. After that, find_package is overloaded to prevent loading of CMakeFindDependenyMacro. + 3. mysql-connector-cpp installs and uses its custom find_dependency(). +#]] + +set(THREADS_PREFER_PTHREAD_FLAG 1) +find_package(Threads) + +find_package(OpenSSL REQUIRED) + +find_package(Protobuf CONFIG REQUIRED) +#add_library(ext::protobuf ALIAS protobuf::libprotobuf) +add_library(ext::protobuf-lite ALIAS protobuf::libprotobuf-lite) +if(NOT TARGET ext::protoc) + add_executable(ext::protoc IMPORTED) + set_target_properties(ext::protoc PROPERTIES IMPORTED_LOCATION "${WITH_PROTOC}") +endif() + +find_package(RapidJSON CONFIG REQUIRED) +add_library(RapidJSON::rapidjson ALIAS RapidJSON) + +find_package(ZLIB REQUIRED) +add_library(ext::z ALIAS ZLIB::ZLIB) + +find_package(lz4 REQUIRED) +add_library(ext::lz4 ALIAS lz4::lz4) + +find_package(zstd REQUIRED) +add_library(ext::zstd ALIAS zstd::libzstd) + +if(WITH_JDBC) + find_package(unofficial-libmysql REQUIRED) + find_path(errmsg_include_dir NAMES errmsg.h PATH_SUFFIXES mysql) + set_property(TARGET unofficial::libmysql::libmysql APPEND PROPERTY INTERFACE_INCLUDE_DIRECTORIES "${errmsg_include_dir}") + add_library(MySQL::client ALIAS unofficial::libmysql::libmysql) + + file(READ "${errmsg_include_dir}/mysql_version.h" version_h) + if(NOT version_h MATCHES "#define +MYSQL_SERVER_VERSION +\"([^\"]+)\"") + message(FATAL_ERROR "Failed to detect libmysql version") + endif() + set(MYSQL_VERSION "${CMAKE_MATCH_1}") + if(NOT version_h MATCHES "#define +MYSQL_VERSION_ID +([0-9]+)") + message(FATAL_ERROR "Failed to detect libmysql version ID") + endif() + set(MYSQL_NUM_VERSION "${CMAKE_MATCH_1}") +endif() + +set(known_packages Threads OpenSSL Protobuf RapidJSON ZLIB lz4 zstd unofficial-libmysql) +cmake_policy(SET CMP0057 NEW) +macro(find_package NAME) + if(NOT "${NAME}" IN_LIST known_packages) + message(SEND_ERROR "find_package(${NAME}) not handled in ${CMAKE_CURRENT_LIST_FILE}") + endif() +endmacro() diff --git a/vcpkg/ports/mysql-connector-cpp/depfindprotobuf.diff b/vcpkg/ports/mysql-connector-cpp/depfindprotobuf.diff new file mode 100644 index 0000000..f3a82ae --- /dev/null +++ b/vcpkg/ports/mysql-connector-cpp/depfindprotobuf.diff @@ -0,0 +1,24 @@ +diff --git a/cdk/cmake/DepFindProtobuf.cmake b/cdk/cmake/DepFindProtobuf.cmake +index 1fc785e..2ba7e99 100644 +--- a/cdk/cmake/DepFindProtobuf.cmake ++++ b/cdk/cmake/DepFindProtobuf.cmake +@@ -44,9 +44,9 @@ + # + # + +-if(TARGET ext::protobuf) ++if(COMMAND mysqlx_protobuf_generate_cpp) + return() +-endif() ++elseif(0) + + message(STATUS "Setting up Protobuf.") + +@@ -66,6 +66,7 @@ add_ext_targets(protobuf + ) + + ++endif() + # Standard PROTOBUF_GENERATE_CPP modified to our usage + function(mysqlx_protobuf_generate_cpp SRCS HDRS) + IF(NOT ARGN) diff --git a/vcpkg/ports/mysql-connector-cpp/disable-telemetry.diff b/vcpkg/ports/mysql-connector-cpp/disable-telemetry.diff new file mode 100644 index 0000000..4ba74a1 --- /dev/null +++ b/vcpkg/ports/mysql-connector-cpp/disable-telemetry.diff @@ -0,0 +1,14 @@ +diff --git a/jdbc/extra/otel/CMakeLists.txt b/jdbc/extra/otel/CMakeLists.txt +index bbed9bd..d03e2ef 100644 +--- a/jdbc/extra/otel/CMakeLists.txt ++++ b/jdbc/extra/otel/CMakeLists.txt +@@ -9,7 +9,9 @@ if(NOT (WIN32 OR APPLE OR CMAKE_SYSTEM_NAME MATCHES "SunOS")) + message(STATUS "Adding OTel support") + + set(TELEMETRY ON CACHE INTERNAL "Whether connector is built with OTel support") ++endif() + ++if(TELEMETRY) + target_include_directories(otel_api INTERFACE + "${PROJECT_SOURCE_DIR}/extra/otel/${OPENTELEMETRY_CPP_TAG}/api/include" + ) diff --git a/vcpkg/ports/mysql-connector-cpp/dont-preload-cache.diff b/vcpkg/ports/mysql-connector-cpp/dont-preload-cache.diff new file mode 100644 index 0000000..d7a8a7f --- /dev/null +++ b/vcpkg/ports/mysql-connector-cpp/dont-preload-cache.diff @@ -0,0 +1,20 @@ +diff --git a/cdk/cmake/bootstrap.cmake b/cdk/cmake/bootstrap.cmake +index dd597dd..3d9a41f 100644 +--- a/cdk/cmake/bootstrap.cmake ++++ b/cdk/cmake/bootstrap.cmake +@@ -93,14 +93,7 @@ function(bootstrap) + + message("-- ----") + +- execute_process( +- COMMAND ${CMAKE_COMMAND} +- -G ${CMAKE_GENERATOR} +- ${cmake_opts} +- ${src_dir} +- WORKING_DIRECTORY ${bin_dir} +- RESULT_VARIABLE res +- ) ++ set(res "Cache breaks vcpkg toolchain") + + #message(FATAL_ERROR "!!! STOP") + diff --git a/vcpkg/ports/mysql-connector-cpp/export-targets.patch b/vcpkg/ports/mysql-connector-cpp/export-targets.patch new file mode 100644 index 0000000..23deca4 --- /dev/null +++ b/vcpkg/ports/mysql-connector-cpp/export-targets.patch @@ -0,0 +1,120 @@ +diff --git a/CMakeLists.txt b/CMakeLists.txt +index 341ed2d..686b859 100644 +--- a/CMakeLists.txt ++++ b/CMakeLists.txt +@@ -356,9 +356,11 @@ if(WITH_JDBC) + # we use a copy of them placed inside the build tree. + + target_include_directories(connector-jdbc +- PUBLIC "${PROJECT_BINARY_DIR}/include/jdbc" +- PUBLIC "${PROJECT_BINARY_DIR}/include/jdbc/cppconn" +- PUBLIC "${PROJECT_SOURCE_DIR}/include" ++ PUBLIC ++ "$<BUILD_INTERFACE:${PROJECT_BINARY_DIR}/include/jdbc>" ++ "$<BUILD_INTERFACE:${PROJECT_BINARY_DIR}/include/jdbc/cppconn>" ++ "$<BUILD_INTERFACE:${PROJECT_SOURCE_DIR}/include>" ++ "$<INSTALL_INTERFACE:include>" + ) + + endif() +@@ -417,7 +419,8 @@ add_version_info(connector + ) + + target_include_directories(connector PUBLIC +- "${PROJECT_SOURCE_DIR}/include" ++ $<BUILD_INTERFACE:${PROJECT_SOURCE_DIR}/include> ++ $<INSTALL_INTERFACE:include> + # Note: This is needed when using connector directly from the build tree to + # find headers generated by the build process. + $<BUILD_INTERFACE:${PROJECT_BINARY_DIR}/include/mysqlx> +@@ -537,23 +540,18 @@ set_target_properties(connector PROPERTIES + + + install(TARGETS connector +- CONFIGURATIONS Release RelWithDebInfo ++ EXPORT unofficial-mysql-connector-cpp-targets + ARCHIVE DESTINATION "${INSTALL_LIB_DIR_STATIC}" COMPONENT XDevAPIDev +- RUNTIME DESTINATION "${INSTALL_LIB_DIR}" COMPONENT XDevAPIDll ++ RUNTIME DESTINATION "bin" COMPONENT XDevAPIDll + LIBRARY DESTINATION "${INSTALL_LIB_DIR}" COMPONENT XDevAPIDll + ) + +-install(TARGETS connector +- CONFIGURATIONS Debug +- ARCHIVE DESTINATION "${INSTALL_LIB_DIR_STATIC_DEBUG}" COMPONENT XDevAPIDev +- RUNTIME DESTINATION "${INSTALL_LIB_DIR_DEBUG}" COMPONENT XDevAPIDll +- LIBRARY DESTINATION "${INSTALL_LIB_DIR_DEBUG}" COMPONENT XDevAPIDll +-) + + if(MSVC AND NOT BUILD_STATIC) + + install(FILES $<TARGET_PDB_FILE:connector> + CONFIGURATIONS RelWithDebInfo ++ Release + DESTINATION "${INSTALL_LIB_DIR}" + COMPONENT Debuginfo + ) +@@ -667,3 +665,15 @@ endif() + + + show_config_options() ++ ++include(CMakePackageConfigHelpers) ++configure_package_config_file( ++ "${CMAKE_SOURCE_DIR}/mysql-connector-cpp-config.cmake.in" ++ "${CMAKE_CURRENT_BINARY_DIR}/unofficial-mysql-connector-cpp-config.cmake" ++ INSTALL_DESTINATION "share/unofficial-mysql-connector-cpp" ++) ++install(FILES "${CMAKE_CURRENT_BINARY_DIR}/unofficial-mysql-connector-cpp-config.cmake" DESTINATION "share/unofficial-mysql-connector-cpp") ++install(EXPORT unofficial-mysql-connector-cpp-targets ++ NAMESPACE unofficial::mysql-connector-cpp:: ++ DESTINATION share/unofficial-mysql-connector-cpp ++) +diff --git a/cmake/libutils.cmake b/cmake/libutils.cmake +index 159145f..4d4f7fe 100644 +--- a/cmake/libutils.cmake ++++ b/cmake/libutils.cmake +@@ -164,7 +164,11 @@ function(merge_libraries TARGET) + set_property(SOURCE "${LIBUTILS_SCRIPT_DIR}/empty.cc" PROPERTY LANGUAGE CXX) + + add_library(${TARGET} ${TYPE} "${LIBUTILS_SCRIPT_DIR}/empty.cc") ++ if(TYPE STREQUAL "SHARED") + target_link_libraries(${TARGET} PRIVATE ${ARGN}) ++ else() # merged into whole archive ++ add_dependencies(${TARGET} ${ARGN}) ++ endif() + + # + # Arrange for marge_archives.cmake script to be executed in a POST_BUILD +diff --git a/jdbc/CMakeLists.txt b/jdbc/CMakeLists.txt +index 60e36e4..7117213 100644 +--- a/jdbc/CMakeLists.txt ++++ b/jdbc/CMakeLists.txt +@@ -341,24 +341,19 @@ endif() + + + install(TARGETS connector-jdbc +- CONFIGURATIONS Release RelWithDebInfo ++ EXPORT unofficial-mysql-connector-cpp-targets + ARCHIVE DESTINATION "${INSTALL_LIB_DIR_STATIC}" COMPONENT JDBCDev +- RUNTIME DESTINATION "${INSTALL_LIB_DIR}" COMPONENT JDBCDll ++ RUNTIME DESTINATION "bin" COMPONENT JDBCDll + LIBRARY DESTINATION "${INSTALL_LIB_DIR}" COMPONENT JDBCDll + ) + +-install(TARGETS connector-jdbc +- CONFIGURATIONS Debug +- ARCHIVE DESTINATION "${INSTALL_LIB_DIR_STATIC_DEBUG}" COMPONENT JDBCDev +- RUNTIME DESTINATION "${INSTALL_LIB_DIR_DEBUG}" COMPONENT JDBCDll +- LIBRARY DESTINATION "${INSTALL_LIB_DIR_DEBUG}" COMPONENT JDBCDll +-) + + + if(MSVC AND NOT BUILD_STATIC) + + install(FILES $<TARGET_PDB_FILE:connector-jdbc> + CONFIGURATIONS RelWithDebInfo ++ Release + DESTINATION "${INSTALL_LIB_DIR}" + COMPONENT Debuginfo + ) diff --git a/vcpkg/ports/mysql-connector-cpp/lib-name-static.diff b/vcpkg/ports/mysql-connector-cpp/lib-name-static.diff new file mode 100644 index 0000000..f3fec0a --- /dev/null +++ b/vcpkg/ports/mysql-connector-cpp/lib-name-static.diff @@ -0,0 +1,26 @@ +diff --git a/install_layout.cmake b/install_layout.cmake +index 4a8a511..ee091da 100644 +--- a/install_layout.cmake ++++ b/install_layout.cmake +@@ -219,7 +219,7 @@ set(LIB_NAME_BASE "mysqlcppconnx") + set(LIB_NAME_STATIC "${LIB_NAME_BASE}-static") + + if(WIN32 AND STATIC_MSVCRT) +- set(LIB_NAME_STATIC "${LIB_NAME}-mt") ++ set(LIB_NAME_STATIC "${LIB_NAME_STATIC}-mt") + endif() + + if(BUILD_STATIC) +diff --git a/jdbc/install_layout.cmake b/jdbc/install_layout.cmake +index e9e15a5..a4f7dc0 100644 +--- a/jdbc/install_layout.cmake ++++ b/jdbc/install_layout.cmake +@@ -91,7 +91,7 @@ set(LIB_NAME_BASE "mysqlcppconn") + set(LIB_NAME_STATIC "${LIB_NAME_BASE}-static") + + if(WIN32 AND STATIC_MSVCRT) +- set(LIB_NAME_STATIC "${LIB_NAME}-mt") ++ set(LIB_NAME_STATIC "${LIB_NAME_STATIC}-mt") + endif() + + if(BUILD_STATIC) diff --git a/vcpkg/ports/mysql-connector-cpp/merge-archives.diff b/vcpkg/ports/mysql-connector-cpp/merge-archives.diff new file mode 100644 index 0000000..fe9dc2c --- /dev/null +++ b/vcpkg/ports/mysql-connector-cpp/merge-archives.diff @@ -0,0 +1,25 @@ +diff --git a/cmake/libutils/merge_archives.cmake.in b/cmake/libutils/merge_archives.cmake.in +index 33094a6..5b256c6 100644 +--- a/cmake/libutils/merge_archives.cmake.in ++++ b/cmake/libutils/merge_archives.cmake.in +@@ -299,7 +299,7 @@ function(merge_libraries_gcc) + + get_filename_component(name "${lib}" NAME_WE) + # Make sure path is absolute +- get_filename_component(lib "${lib}" ABSOLUTE) ++ get_filename_component(lib "${lib}" ABSOLUTE BASE_DIR "@PROJECT_BINARY_DIR@") + + #message("-- processing lib: ${name} (${lib})") + +@@ -564,6 +564,11 @@ function(process_deps) + # ninja, for example. + + get_filename_component(libpath "${lib}" ABSOLUTE BASE_DIR "${BUILD_DIR}") ++ string(FIND "${libpath}/" "@PROJECT_BINARY_DIR@/" index) ++ if(NOT index STREQUAL "0") ++ message( "! Omitting ${lib}") ++ continue() ++ endif() + + if( + lib MATCHES "${libext}$" diff --git a/vcpkg/ports/mysql-connector-cpp/mysql-concpp-config.cmake b/vcpkg/ports/mysql-connector-cpp/mysql-concpp-config.cmake new file mode 100644 index 0000000..4ad08da --- /dev/null +++ b/vcpkg/ports/mysql-connector-cpp/mysql-concpp-config.cmake @@ -0,0 +1,17 @@ +# Partial reimplementation of official interface +include(CMakeFindDependencyMacro) +find_dependency(unofficial-mysql-connector-cpp) +set(suffix "") +if("@BUILD_STATIC@") + set(suffix "-static") +endif() +if(NOT TARGET mysql::concpp-xdevapi${suffix}) + add_library(mysql::concpp${suffix} ALIAS unofficial::mysql-connector-cpp::connector) + add_library(mysql::concpp-xdevapi${suffix} ALIAS unofficial::mysql-connector-cpp::connector) + if(TARGET unofficial::mysql-connector-cpp::connector-jdbc) + add_library(mysql::concpp-jdbc${suffix} ALIAS unofficial::mysql-connector-cpp::connector-jdbc) + endif() +endif() +set(MYSQL_CONCPP_FOUND 1) +set(MYSQL_CONCPP_VERSION "@VERSION@") +set(mysql-concpp_VERSION "@VERSION@") diff --git a/vcpkg/ports/mysql-connector-cpp/mysql-connector-cpp-config.cmake.in b/vcpkg/ports/mysql-connector-cpp/mysql-connector-cpp-config.cmake.in new file mode 100644 index 0000000..076ddda --- /dev/null +++ b/vcpkg/ports/mysql-connector-cpp/mysql-connector-cpp-config.cmake.in @@ -0,0 +1,48 @@ +@PACKAGE_INIT@
+
+include(CMakeFindDependencyMacro)
+find_dependency(Protobuf CONFIG)
+if(NOT "@BUILD_SHARED_LIBS@")
+ find_dependency(Threads)
+ find_dependency(OpenSSL)
+ find_dependency(RapidJSON CONFIG)
+ find_dependency(ZLIB)
+ find_dependency(lz4)
+ find_dependency(zstd)
+ if("@WITH_JDBC@")
+ find_dependency(unofficial-libmysql)
+ endif()
+endif()
+
+include("${CMAKE_CURRENT_LIST_DIR}/unofficial-mysql-connector-cpp-targets.cmake")
+
+if(NOT UNOFFICIAL_MYSQL_CONNECTOR_CPP_INITIALIZED)
+ if(NOT "@BUILD_SHARED_LIBS@")
+ set_target_properties(unofficial::mysql-connector-cpp::connector PROPERTIES
+ INTERFACE_LINK_LIBRARIES "$<LINK_ONLY:Threads::Threads>;$<LINK_ONLY:OpenSSL::SSL>;$<LINK_ONLY:rapidjson>;$<LINK_ONLY:ZLIB::ZLIB>;$<LINK_ONLY:>;$<LINK_ONLY:lz4::lz4>;$<LINK_ONLY:zstd::libzstd>"
+ )
+ # Cf. mysql-concpp-config.cmake.in
+ if(WIN32)
+ set_property(TARGET unofficial::mysql-connector-cpp::connector APPEND PROPERTY INTERFACE_LINK_LIBRARIES "dnsapi")
+ elseif(NOT CMAKE_SYSTEM_NAME MATCHES "FreeBSD")
+ set_property(TARGET unofficial::mysql-connector-cpp::connector APPEND PROPERTY INTERFACE_LINK_LIBRARIES "resolv;dl")
+ endif()
+ if("@WITH_JDBC@")
+ set_target_properties(unofficial::mysql-connector-cpp::connector-jdbc PROPERTIES
+ INTERFACE_LINK_LIBRARIES "$<LINK_ONLY:unofficial::libmysql::libmysql>"
+ )
+ # Cf. jdbc/driver/CMakeLists.txt
+ if(WIN32)
+ set_property(TARGET unofficial::mysql-connector-cpp::connector-jdbc APPEND PROPERTY INTERFACE_LINK_LIBRARIES "dnsapi")
+ elseif(NOT CMAKE_SYSTEM_NAME MATCHES "FreeBSD")
+ set_property(TARGET unofficial::mysql-connector-cpp::connector-jdbc APPEND PROPERTY INTERFACE_LINK_LIBRARIES "resolv;dl")
+ endif()
+ endif()
+ endif()
+ set_property(TARGET unofficial::mysql-connector-cpp::connector APPEND PROPERTY
+ INTERFACE_LINK_LIBRARIES "$<LINK_ONLY:protobuf::libprotobuf-lite>"
+ )
+ set(UNOFFICIAL_MYSQL_CONNECTOR_CPP_INITIALIZED 1 CACHE INTERNAL "")
+endif()
+
+check_required_components(mysql-connector-cpp)
diff --git a/vcpkg/ports/mysql-connector-cpp/portfile.cmake b/vcpkg/ports/mysql-connector-cpp/portfile.cmake new file mode 100644 index 0000000..bc9ed71 --- /dev/null +++ b/vcpkg/ports/mysql-connector-cpp/portfile.cmake @@ -0,0 +1,108 @@ +vcpkg_from_github(
+ OUT_SOURCE_PATH SOURCE_PATH
+ REPO mysql/mysql-connector-cpp
+ REF "${VERSION}"
+ SHA512 aa432822d4c9d7f1328bf59e261c362570f6b2237a5a9f730f96f079aba14bdc689f400ab2857c4cdd1dca025eb09eaaf2b26328f3b42d117f24b9182dc2cc0a
+ HEAD_REF master
+ PATCHES
+ depfindprotobuf.diff
+ disable-telemetry.diff
+ dont-preload-cache.diff
+ lib-name-static.diff
+ merge-archives.diff
+ save-linker-opts.diff
+ export-targets.patch
+ protobuf-source.patch # Disables upstream log event handling!
+)
+file(COPY "${CMAKE_CURRENT_LIST_DIR}/mysql-connector-cpp-config.cmake.in" DESTINATION "${SOURCE_PATH}")
+file(REMOVE_RECURSE
+ "${SOURCE_PATH}/cdk/extra/common"
+ "${SOURCE_PATH}/cdk/extra/exprtest"
+ "${SOURCE_PATH}/cdk/extra/lz4"
+ "${SOURCE_PATH}/cdk/extra/ngs_mockup"
+ "${SOURCE_PATH}/cdk/extra/process_launcher"
+ "${SOURCE_PATH}/cdk/extra/protobuf"
+ "${SOURCE_PATH}/cdk/extra/rapidjson"
+ "${SOURCE_PATH}/cdk/extra/zlib"
+ "${SOURCE_PATH}/cdk/extra/zstd"
+ "${SOURCE_PATH}/jdbc/extra/otel/opentelemetry-cpp-1.12.0"
+)
+
+vcpkg_check_features(
+ OUT_FEATURE_OPTIONS options
+ FEATURES
+ jdbc WITH_JDBC
+)
+
+if(VCPKG_CROSSCOMPILING AND EXISTS "${CURRENT_HOST_INSTALLED_DIR}/manual-tools/${PORT}/save_linker_opts${VCPKG_HOST_EXECUTABLE_SUFFIX}")
+ vcpkg_list(APPEND options "-DWITH_SAVE_LINKER_OPTS=${CURRENT_HOST_INSTALLED_DIR}/manual-tools/${PORT}/save_linker_opts${VCPKG_HOST_EXECUTABLE_SUFFIX}")
+endif()
+
+string(COMPARE EQUAL "${VCPKG_LIBRARY_LINKAGE}" "static" BUILD_STATIC)
+string(COMPARE EQUAL "${VCPKG_CRT_LINKAGE}" "static" STATIC_MSVCRT)
+
+# Preparing to merge STATIC library: connector (xapi;devapi)
+# CMake Error at cmake/libutils.cmake:297 (message):
+# Sorry but building static connector on Windows using MSVC toolset works
+# only with msbuild at the moment.
+# Call Stack (most recent call first):
+# CMakeLists.txt:413 (merge_libraries)
+set(USE_MSBUILD_ARG)
+if(BUILD_STATIC)
+ set(USE_MSBUILD_ARG WINDOWS_USE_MSBUILD)
+endif()
+
+vcpkg_cmake_configure(
+ SOURCE_PATH "${SOURCE_PATH}"
+ ${USE_MSBUILD_ARG}
+ OPTIONS
+ ${options}
+ "-DCMAKE_PROJECT_INCLUDE=${CURRENT_PORT_DIR}/cmake-project-include.cmake"
+ "-DWITH_PROTOC=${CURRENT_HOST_INSTALLED_DIR}/tools/protobuf/protoc${VCPKG_HOST_EXECUTABLE_SUFFIX}"
+ -DBUILD_STATIC=${BUILD_STATIC}
+ -DMYSQLCLIENT_STATIC_LINKING=${BUILD_STATIC}
+ -DSTATIC_MSVCRT=${STATIC_MSVCRT}
+ -DINSTALL_LIB_DIR=lib
+ -DINSTALL_LIB_DIR_DEBUG=lib
+ -DINSTALL_LIB_DIR_STATIC=lib
+ -DINSTALL_LIB_DIR_STATIC_DEBUG=lib
+ -DTELEMETRY=OFF
+ -DWITH_DOC=OFF
+ -DWITH_HEADER_CHECKS=OFF
+ -DWITH_SSL=system
+ -DWITH_TESTS=OFF
+ MAYBE_UNUSED_VARIABLES
+ TELEMETRY
+)
+
+vcpkg_cmake_install()
+vcpkg_cmake_config_fixup(PACKAGE_NAME unofficial-mysql-connector-cpp)
+configure_file("${CURRENT_PORT_DIR}/mysql-concpp-config.cmake" "${CURRENT_PACKAGES_DIR}/share/mysql-concpp/mysql-concpp-config.cmake" @ONLY)
+
+if(NOT VCPKG_CROSSCOMPILING AND EXISTS "${CURRENT_BUILDTREES_DIR}/${TARGET_TRIPLET}-rel/libutils/save_linker_opts${VCPKG_TARGET_EXECUTABLE_SUFFIX}")
+ vcpkg_copy_tools(TOOL_NAMES save_linker_opts
+ SEARCH_DIR "${CURRENT_BUILDTREES_DIR}/${TARGET_TRIPLET}-rel/libutils"
+ DESTINATION "${CURRENT_PACKAGES_DIR}/manual-tools/${PORT}"
+ )
+endif()
+
+if(BUILD_STATIC)
+ vcpkg_replace_string("${CURRENT_PACKAGES_DIR}/include/mysqlx/common/api.h" "defined STATIC_CONCPP" "(1)")
+ if(WITH_JDBC)
+ vcpkg_replace_string("${CURRENT_PACKAGES_DIR}/include/jdbc/cppconn/build_config.h" "ifdef STATIC_CONCPP" "if 1")
+ endif()
+endif()
+
+file(REMOVE_RECURSE
+ "${CURRENT_PACKAGES_DIR}/debug/include"
+ "${CURRENT_PACKAGES_DIR}/INFO_BIN"
+ "${CURRENT_PACKAGES_DIR}/INFO_SRC"
+ "${CURRENT_PACKAGES_DIR}/debug/INFO_BIN"
+ "${CURRENT_PACKAGES_DIR}/debug/INFO_SRC"
+ "${CURRENT_PACKAGES_DIR}/mysql-concpp-config.cmake"
+ "${CURRENT_PACKAGES_DIR}/mysql-concpp-config-version.cmake"
+ "${CURRENT_PACKAGES_DIR}/debug/mysql-concpp-config.cmake"
+ "${CURRENT_PACKAGES_DIR}/debug/mysql-concpp-config-version.cmake"
+)
+
+vcpkg_install_copyright(FILE_LIST "${SOURCE_PATH}/LICENSE.txt")
diff --git a/vcpkg/ports/mysql-connector-cpp/protobuf-source.patch b/vcpkg/ports/mysql-connector-cpp/protobuf-source.patch new file mode 100644 index 0000000..4412dec --- /dev/null +++ b/vcpkg/ports/mysql-connector-cpp/protobuf-source.patch @@ -0,0 +1,61 @@ +diff --git a/cdk/protocol/mysqlx/protocol.cc b/cdk/protocol/mysqlx/protocol.cc
+index d4589c27..c61deca4 100644
+--- a/cdk/protocol/mysqlx/protocol.cc
++++ b/cdk/protocol/mysqlx/protocol.cc
+@@ -117,18 +117,15 @@ namespace mysqlx {
+ Protobuf log handler initialization.
+ */
+
+-static void log_handler(LogLevel level, const char* filename, int line, const std::string& message);
+
+ #ifdef _WIN32
+ BOOL CALLBACK log_handler_init(PINIT_ONCE, PVOID, PVOID*)
+ {
+- SetLogHandler(&log_handler);
+ return TRUE;
+ }
+ #else
+ static void log_handler_init()
+ {
+- SetLogHandler(log_handler);
+ }
+ #endif
+
+@@ -289,37 +286,6 @@ Message* mk_message(Protocol_side side, msg_type_t msg_type)
+ situation occurs in Protobuf (such as parsing error etc).
+ */
+
+-static void log_handler(
+- LogLevel level, const char* /*filename*/, int /*line*/,
+- const std::string& message
+-)
+-{
+- switch(level)
+- {
+- case LOGLEVEL_FATAL:
+- case LOGLEVEL_ERROR:
+- /*
+- With this code the error description is:
+-
+- MMM: Protobuf error (cdk:NNN)
+-
+- where MMM is the message and NNN is the protbuf error code.
+-
+- TODO: Change description to:
+-
+- Protobuf error: MMM (cdk:NNN)
+- */
+- throw_error(cdkerrc::protobuf_error, message);
+-
+- case LOGLEVEL_WARNING:
+- case LOGLEVEL_INFO:
+- default:
+- {
+- // just ignore for now
+- // TODO: this could be used for logging in the future
+- }
+- }
+-}
+
+ /*
+ Implementation of protobuf's ZeroCopyOutputStream which stores
diff --git a/vcpkg/ports/mysql-connector-cpp/save-linker-opts.diff b/vcpkg/ports/mysql-connector-cpp/save-linker-opts.diff new file mode 100644 index 0000000..dbf8b10 --- /dev/null +++ b/vcpkg/ports/mysql-connector-cpp/save-linker-opts.diff @@ -0,0 +1,24 @@ +diff --git a/cmake/libutils.cmake b/cmake/libutils.cmake +index 848b7cf..159145f 100644 +--- a/cmake/libutils.cmake ++++ b/cmake/libutils.cmake +@@ -236,8 +236,9 @@ function(merge_libraries TARGET) + # + + add_dependencies(${TARGET}-deps save_linker_opts) ++ set(WITH_SAVE_LINKER_OPTS "${LIBUTILS_BIN_DIR}/save_linker_opts" CACHE FILEPATH "") + set_target_properties(${TARGET}-deps PROPERTIES +- RULE_LAUNCH_LINK "${LIBUTILS_BIN_DIR}/save_linker_opts ${log_file}.STATIC " ++ RULE_LAUNCH_LINK "${WITH_SAVE_LINKER_OPTS} ${log_file}.STATIC " + ) + + # Arrange for ${TARGET}-deps to be built before ${TARGET} +@@ -255,7 +256,7 @@ function(merge_libraries TARGET) + # + + set_target_properties(${TARGET} PROPERTIES +- RULE_LAUNCH_LINK "${LIBUTILS_BIN_DIR}/save_linker_opts ${log_file}.SHARED " ++ RULE_LAUNCH_LINK "${WITH_SAVE_LINKER_OPTS} ${log_file}.SHARED " + ) + + else(NOT MSVC) diff --git a/vcpkg/ports/mysql-connector-cpp/vcpkg.json b/vcpkg/ports/mysql-connector-cpp/vcpkg.json new file mode 100644 index 0000000..95edfbf --- /dev/null +++ b/vcpkg/ports/mysql-connector-cpp/vcpkg.json @@ -0,0 +1,43 @@ +{ + "name": "mysql-connector-cpp", + "version": "9.1.0", + "port-version": 4, + "description": "This is a release of MySQL Connector/C++, the C++ interface for communicating with MySQL servers.", + "homepage": "https://github.com/mysql/mysql-connector-cpp", + "license": null, + "supports": "!android & !uwp", + "dependencies": [ + "lz4", + { + "name": "mysql-connector-cpp", + "host": true, + "platform": "!windows | mingw" + }, + "openssl", + "protobuf", + { + "name": "protobuf", + "host": true + }, + "rapidjson", + { + "name": "vcpkg-cmake", + "host": true + }, + { + "name": "vcpkg-cmake-config", + "host": true + }, + "zlib", + "zstd" + ], + "features": { + "jdbc": { + "description": "Legacy C++ API based on the JDBC4 specification.", + "supports": "static", + "dependencies": [ + "libmysql" + ] + } + } +} |