From 8a11e42dea70d067543b1bbe11df0dd663e7a173 Mon Sep 17 00:00:00 2001 From: Gordon Smith Date: Thu, 14 Mar 2024 17:18:51 +0000 Subject: [PATCH] HPCC-31456 Prevent libmysql from building "host" targets Was adding 80 additional build steps to the vcpkg build process Signed-off-by: Gordon Smith --- vcpkg.json.in | 4 +- vcpkg_overlays/libmysql/cross-build.patch | 162 ++++++++++++++++++ vcpkg_overlays/libmysql/dependencies.patch | 140 +++++++++++++++ vcpkg_overlays/libmysql/fix_dup_symbols.patch | 20 +++ vcpkg_overlays/libmysql/install-exports.patch | 121 +++++++++++++ vcpkg_overlays/libmysql/libmysql-config.cmake | 6 + vcpkg_overlays/libmysql/portfile.cmake | 160 +++++++++++++++++ vcpkg_overlays/libmysql/usage | 4 + vcpkg_overlays/libmysql/vcpkg.json | 47 +++++ 9 files changed, 663 insertions(+), 1 deletion(-) create mode 100644 vcpkg_overlays/libmysql/cross-build.patch create mode 100644 vcpkg_overlays/libmysql/dependencies.patch create mode 100644 vcpkg_overlays/libmysql/fix_dup_symbols.patch create mode 100644 vcpkg_overlays/libmysql/install-exports.patch create mode 100644 vcpkg_overlays/libmysql/libmysql-config.cmake create mode 100644 vcpkg_overlays/libmysql/portfile.cmake create mode 100644 vcpkg_overlays/libmysql/usage create mode 100644 vcpkg_overlays/libmysql/vcpkg.json diff --git a/vcpkg.json.in b/vcpkg.json.in index 9afef0a36e2..310ac2cb38c 100644 --- a/vcpkg.json.in +++ b/vcpkg.json.in @@ -106,7 +106,9 @@ }, { "name": "libmysql", - "platform": "@VCPKG_MYSQLEMBED@ & !(windows & x86)" + "platform": "@VCPKG_MYSQLEMBED@ & !(windows & x86)", + "default-features": false, + "features": [] }, { "name": "librdkafka", diff --git a/vcpkg_overlays/libmysql/cross-build.patch b/vcpkg_overlays/libmysql/cross-build.patch new file mode 100644 index 00000000000..a91118b4f85 --- /dev/null +++ b/vcpkg_overlays/libmysql/cross-build.patch @@ -0,0 +1,162 @@ +diff --git a/cmake/os/Darwin.cmake b/cmake/os/Darwin.cmake +index 725b9bd..289bb3d 100644 +--- a/cmake/os/Darwin.cmake ++++ b/cmake/os/Darwin.cmake +@@ -31,13 +31,9 @@ ENDIF() + # We require at least XCode 10.0 + IF(NOT FORCE_UNSUPPORTED_COMPILER) + IF(MY_COMPILER_IS_CLANG) +- CHECK_C_SOURCE_RUNS(" +- int main() +- { +- return (__clang_major__ < 10); +- }" HAVE_SUPPORTED_CLANG_VERSION) +- IF(NOT HAVE_SUPPORTED_CLANG_VERSION) +- MESSAGE(FATAL_ERROR "XCode 10.0 or newer is required!") ++ IF (CMAKE_CXX_COMPILER_VERSION VERSION_LESS 10) ++ MESSAGE(FATAL_ERROR ++ "XCode 10.0 or newer is required! Compiler version was ${CMAKE_CXX_COMPILER_VERSION}") + ENDIF() + ELSE() + MESSAGE(FATAL_ERROR "Unsupported compiler!") +diff --git a/libmysql/CMakeLists.txt b/libmysql/CMakeLists.txt +index 8e22453..2b63413 100644 +--- a/libmysql/CMakeLists.txt ++++ b/libmysql/CMakeLists.txt +@@ -259,6 +259,7 @@ ELSEIF(FREEBSD) + MESSAGE(STATUS "BSD built in DNS SRV APIs") + ELSE() + FIND_LIBRARY(RESOLV_LIBRARY NAMES resolv) ++ FIND_LIBRARY(RESOLV_LIBRARY NAMES resolv PATHS ${CMAKE_C_IMPLICIT_LINK_DIRECTORIES} NO_DEFAULT_PATH) + IF (RESOLV_LIBRARY) + LIST(APPEND LIBS_TO_LINK ${RESOLV_LIBRARY}) + SET(HAVE_UNIX_DNS_SRV 1 PARENT_SCOPE) +@@ -413,6 +414,7 @@ MYSQL_ADD_EXECUTABLE(libmysql_api_test + ${CMAKE_CURRENT_BINARY_DIR}/api_test.c + LINK_LIBRARIES libmysql ${LIBRT} + SKIP_INSTALL ++ EXCLUDE_FROM_ALL + ) + # Clang/UBSAN needs this on some platforms. + SET_TARGET_PROPERTIES(libmysql_api_test PROPERTIES LINKER_LANGUAGE CXX) +@@ -439,6 +441,6 @@ ADD_CUSTOM_COMMAND( + COMMAND libmysql_api_test + > ${CMAKE_CURRENT_BINARY_DIR}/libmysql_api_test.out + ) +-MY_ADD_CUSTOM_TARGET(run_libmysql_api_test ALL ++MY_ADD_CUSTOM_TARGET(run_libmysql_api_test + DEPENDS ${CMAKE_CURRENT_BINARY_DIR}/libmysql_api_test.out + ) +diff --git a/scripts/CMakeLists.txt b/scripts/CMakeLists.txt +index 8e93387..d971acb 100644 +--- a/scripts/CMakeLists.txt ++++ b/scripts/CMakeLists.txt +@@ -69,7 +69,6 @@ ADD_CUSTOM_COMMAND( + + # Add target for the above to be built + MY_ADD_CUSTOM_TARGET(GenFixPrivs +- ALL + DEPENDS ${CMAKE_CURRENT_BINARY_DIR}/mysql_fix_privilege_tables_sql.h + ) + +diff --git a/scripts/sys_schema/CMakeLists.txt b/scripts/sys_schema/CMakeLists.txt +index aaba357..a0e5265 100644 +--- a/scripts/sys_schema/CMakeLists.txt ++++ b/scripts/sys_schema/CMakeLists.txt +@@ -221,7 +221,6 @@ MY_ADD_CUSTOM_TARGET(sql_commands + DEPENDS ${CMAKE_CURRENT_BINARY_DIR}/sql_commands.h) + + MY_ADD_CUSTOM_TARGET(GenSysSchemaC +- ALL + DEPENDS comp_sql sql_commands + COMMENT "Generating Sys Schema C code" + ) +diff --git a/share/CMakeLists.txt b/share/CMakeLists.txt +index 28cde40..be916cb 100644 +--- a/share/CMakeLists.txt ++++ b/share/CMakeLists.txt +@@ -47,8 +47,12 @@ SET(dirs + ukrainian + ) + +-FOREACH (dir ${dirs}) +- INSTALL(DIRECTORY ${CMAKE_BINARY_DIR}/${INSTALL_MYSQLSHAREDIR}/${dir} ++ set(src_dir ${CMAKE_BINARY_DIR}/share/libmysql) ++ if(CMAKE_CROSSCOMPILING) ++ set(src_dir ${VCPKG_INSTALLED_DIR}/${VCPKG_HOST_TRIPLET}/share/libmysql) ++ endif() ++ FOREACH (dir ${dirs}) ++ INSTALL(DIRECTORY ${src_dir}/${dir} + DESTINATION ${INSTALL_MYSQLSHAREDIR} + COMPONENT Server + ) +diff --git a/strings/CMakeLists.txt b/strings/CMakeLists.txt +index 665b35d..88f0743 100644 +--- a/strings/CMakeLists.txt ++++ b/strings/CMakeLists.txt +@@ -69,6 +69,13 @@ SET(ZH_HANS_SRC_FILE ${CMAKE_SOURCE_DIR}/strings/lang_data/zh_hans.txt) + SET(ZH_HANS_DST_FILE ${CMAKE_BINARY_DIR}/strings/uca900_zh_tbls.cc) + SET(JA_HANS_SRC_FILE ${CMAKE_SOURCE_DIR}/strings/lang_data/ja_hans.txt) + SET(JA_HANS_DST_FILE ${CMAKE_BINARY_DIR}/strings/uca900_ja_tbls.cc) ++if(CMAKE_CROSSCOMPILING) ++ file(COPY ++ "${VCPKG_INSTALLED_DIR}/${VCPKG_HOST_TRIPLET}/share/libmysql/${PROJECT_VERSION}/uca900_zh_tbls.cc" ++ "${VCPKG_INSTALLED_DIR}/${VCPKG_HOST_TRIPLET}/share/libmysql/${PROJECT_VERSION}/uca900_ja_tbls.cc" ++ DESTINATION "${CMAKE_BINARY_DIR}/strings" ++ ) ++else() + ADD_CUSTOM_COMMAND(OUTPUT ${ZH_HANS_DST_FILE} + ${JA_HANS_DST_FILE} + COMMAND uca9dump zh +@@ -79,6 +86,8 @@ ADD_CUSTOM_COMMAND(OUTPUT ${ZH_HANS_DST_FILE} + --out_file=${JA_HANS_DST_FILE} + DEPENDS uca9dump ${ZH_HANS_SRC_FILE} ${JA_HANS_SRC_FILE} + ) ++install(FILES "${ZH_HANS_DST_FILE}" "${JA_HANS_DST_FILE}" DESTINATION "share/libmysql/${PROJECT_VERSION}") ++endif() + + SET_SOURCE_FILES_PROPERTIES( + ${JA_HANS_DST_FILE} ${ZH_HANS_DST_FILE} +diff --git a/utilities/CMakeLists.txt b/utilities/CMakeLists.txt +index da34524..dc397da 100644 +--- a/utilities/CMakeLists.txt ++++ b/utilities/CMakeLists.txt +@@ -39,6 +39,21 @@ MYSQL_ADD_EXECUTABLE(comp_client_err + SKIP_INSTALL + ) + ++if(CMAKE_CROSSCOMPILING) ++ file(COPY ++ ${VCPKG_INSTALLED_DIR}/${VCPKG_HOST_TRIPLET}/include/mysql/mysqld_error.h ++ ${VCPKG_INSTALLED_DIR}/${VCPKG_HOST_TRIPLET}/share/libmysql/${PROJECT_VERSION}/mysqlclient_ername.h ++ ${VCPKG_INSTALLED_DIR}/${VCPKG_HOST_TRIPLET}/share/libmysql/${PROJECT_VERSION}/mysqld_ername.h ++ ${VCPKG_INSTALLED_DIR}/${VCPKG_HOST_TRIPLET}/share/libmysql/${PROJECT_VERSION}/mysqld_errmsg.h ++ DESTINATION ${PROJECT_BINARY_DIR}/include ++ ) ++ file(COPY ++ ${VCPKG_INSTALLED_DIR}/${VCPKG_HOST_TRIPLET}/share/libmysql/${PROJECT_VERSION}/errmsg.sys ++ DESTINATION ${PROJECT_BINARY_DIR}/share/libmysql/english ++ ) ++ add_custom_target(GenClientError) ++ add_custom_target(GenError) ++else() + ADD_CUSTOM_COMMAND(OUTPUT ${PROJECT_BINARY_DIR}/include/mysqlclient_ername.h + COMMAND comp_client_err + --in_file=${PROJECT_SOURCE_DIR}/include/errmsg.h +@@ -97,6 +112,16 @@ MYSQL_ADD_EXECUTABLE(range_check_err + SKIP_INSTALL + ) + ++ install( ++ FILES ++ ${PROJECT_BINARY_DIR}/include/mysqlclient_ername.h ++ ${PROJECT_BINARY_DIR}/include/mysqld_ername.h ++ ${PROJECT_BINARY_DIR}/include/mysqld_errmsg.h ++ ${PROJECT_BINARY_DIR}/share/libmysql/english/errmsg.sys ++ DESTINATION share/libmysql/${PROJECT_VERSION} ++ ) ++endif() ++ + # Set InnoDB mutex type + ADD_DEFINITIONS(-DMUTEX_EVENT) + diff --git a/vcpkg_overlays/libmysql/dependencies.patch b/vcpkg_overlays/libmysql/dependencies.patch new file mode 100644 index 00000000000..0129d71e974 --- /dev/null +++ b/vcpkg_overlays/libmysql/dependencies.patch @@ -0,0 +1,140 @@ +diff --git a/CMakeLists.txt b/CMakeLists.txt +index e17ec1d0..465e42f0 100644 +--- a/CMakeLists.txt ++++ b/CMakeLists.txt +@@ -818,8 +818,12 @@ INCLUDE(fileutils) + INCLUDE(zlib) + INCLUDE(zstd) + INCLUDE(lz4) +-INCLUDE(icu) +-INCLUDE(libevent) ++macro(MYSQL_CHECK_ICU) ++endmacro() ++macro(MYSQL_CHECK_LIBEVENT) ++endmacro() ++macro(WARN_MISSING_SYSTEM_LIBEVENT) ++endmacro() + INCLUDE(ssl) + INCLUDE(sasl) + INCLUDE(ldap) +@@ -837,7 +841,8 @@ INCLUDE(curl) + INCLUDE(rapidjson) + INCLUDE(fprofile) + INCLUDE(gloves) +-INCLUDE(fido2) ++macro(MYSQL_CHECK_FIDO) ++endmacro() + INCLUDE(win_jemalloc) + + IF(UNIX) +@@ -1942,7 +1947,7 @@ MYSQL_CHECK_RAPIDJSON() + MYSQL_CHECK_FIDO() + MYSQL_CHECK_FIDO_DLLS() + +-IF(APPLE) ++IF(0) + GET_FILENAME_COMPONENT(HOMEBREW_BASE ${HOMEBREW_HOME} DIRECTORY) + IF(EXISTS ${HOMEBREW_BASE}/include/boost) + FOREACH(SYSTEM_LIB ICU LIBEVENT LZ4 PROTOBUF ZSTD FIDO) +diff --git a/cmake/boost.cmake b/cmake/boost.cmake +index c979055c..53e55fcf 100644 +--- a/cmake/boost.cmake ++++ b/cmake/boost.cmake +@@ -301,7 +301,7 @@ IF(NOT BOOST_MAJOR_VERSION EQUAL 10) + COULD_NOT_FIND_BOOST() + ENDIF() + +-IF(NOT BOOST_MINOR_VERSION EQUAL 77) ++IF(NOT BOOST_MINOR_VERSION EQUAL 77 AND NOT IGNORE_BOOST_VERSION) + MESSAGE(WARNING "Boost minor version found is ${BOOST_MINOR_VERSION} " + "we need 77" + ) +diff --git a/cmake/libutils.cmake b/cmake/libutils.cmake +index 7107f4bd..bb7f3733 100644 +--- a/cmake/libutils.cmake ++++ b/cmake/libutils.cmake +@@ -534,7 +534,7 @@ MACRO(MERGE_CONVENIENCE_LIBRARIES TARGET_ARG) + + # On Windows, ssleay32.lib/libeay32.lib or libssl.lib/libcrypto.lib + # must be merged into mysqlclient.lib +- IF(WIN32 AND ${TARGET} STREQUAL "mysqlclient") ++ IF(0) + SET(LINKER_EXTRA_FLAGS "") + FOREACH(LIB ${SSL_LIBRARIES}) + STRING_APPEND(LINKER_EXTRA_FLAGS " ${LIB}") +diff --git a/cmake/lz4.cmake b/cmake/lz4.cmake +index 10e7e8c8..48772329 100644 +--- a/cmake/lz4.cmake ++++ b/cmake/lz4.cmake +@@ -46,7 +46,7 @@ FUNCTION(FIND_SYSTEM_LZ4) + FIND_PATH(LZ4_INCLUDE_DIR + NAMES lz4frame.h) + FIND_LIBRARY(LZ4_SYSTEM_LIBRARY +- NAMES lz4) ++ NAMES lz4d lz4 NAMES_PER_DIR) + IF (LZ4_INCLUDE_DIR AND LZ4_SYSTEM_LIBRARY) + SET(SYSTEM_LZ4_FOUND 1 CACHE INTERNAL "") + ADD_LIBRARY(lz4_interface INTERFACE) +diff --git a/cmake/ssl.cmake b/cmake/ssl.cmake +index 04e3af87..8ae52c82 100644 +--- a/cmake/ssl.cmake ++++ b/cmake/ssl.cmake +@@ -273,7 +273,18 @@ MACRO (MYSQL_CHECK_SSL) + FIND_ALTERNATIVE_SYSTEM_SSL() + ENDIF() + +- IF(WITH_SSL STREQUAL "system" OR WITH_SSL_PATH OR ALTERNATIVE_SYSTEM_SSL) ++ IF(WITH_SSL STREQUAL "system") ++ find_package(OpenSSL REQUIRED) ++ set(OPENSSL_LIBRARY OpenSSL::SSL CACHE STRING "") ++ set(CRYPTO_LIBRARY OpenSSL::Crypto CACHE STRING "") ++ find_program(OPENSSL_EXECUTABLE openssl ++ DOC "path to the openssl executable") ++ set(SSL_DEFINES "-DHAVE_OPENSSL") ++ add_library(ext::openssl ALIAS OpenSSL::SSL) ++ set(SSL_LIBRARIES ext::openssl) ++ set(OPENSSL_APPLINK_C "${OPENSSL_APPLINK_SOURCE}") ++ include_directories(SYSTEM ${OPENSSL_INCLUDE_DIR}) ++ ELSEIF(WITH_SSL STREQUAL "system" OR WITH_SSL_PATH OR ALTERNATIVE_SYSTEM_SSL) + IF((APPLE OR WIN32) AND WITH_SSL STREQUAL "system") + # FindOpenSSL.cmake knows about + # http://www.slproweb.com/products/Win32OpenSSL.html +diff --git a/cmake/zlib.cmake b/cmake/zlib.cmake +index 3781fe09..ac312ad0 100644 +--- a/cmake/zlib.cmake ++++ b/cmake/zlib.cmake +@@ -124,7 +124,7 @@ MACRO (MYSQL_CHECK_ZLIB) + MESSAGE(FATAL_ERROR "WITH_ZLIB must be bundled or system") + ENDIF() + +- ADD_LIBRARY(ext::zlib ALIAS zlib_interface) ++ ADD_LIBRARY(ext::zlib ALIAS ZLIB::ZLIB) + + IF(ZLIB_VERSION VERSION_LESS MIN_ZLIB_VERSION_REQUIRED) + MESSAGE(FATAL_ERROR +diff --git a/cmake/zstd.cmake b/cmake/zstd.cmake +index 425426d1..0ae1a907 100644 +--- a/cmake/zstd.cmake ++++ b/cmake/zstd.cmake +@@ -90,15 +90,16 @@ MACRO (MYSQL_CHECK_ZSTD) + IF(WITH_ZSTD STREQUAL "bundled") + MYSQL_USE_BUNDLED_ZSTD() + ELSEIF(WITH_ZSTD STREQUAL "system") +- FIND_SYSTEM_ZSTD() +- IF (NOT SYSTEM_ZSTD_FOUND) +- MESSAGE(FATAL_ERROR "Cannot find system zstd libraries.") +- ENDIF() ++ find_package(ZSTD NAMES zstd REQUIRED) + ELSE() + MESSAGE(FATAL_ERROR "WITH_ZSTD must be bundled or system") + ENDIF() + +- ADD_LIBRARY(ext::zstd ALIAS zstd_interface) ++ if(TARGET zstd::libzstd_shared) ++ add_library(ext::zstd ALIAS zstd::libzstd_shared) ++ else() ++ add_library(ext::zstd ALIAS zstd::libzstd_static) ++ endif() + + IF(ZSTD_VERSION VERSION_LESS MIN_ZSTD_VERSION_REQUIRED) + MESSAGE(FATAL_ERROR diff --git a/vcpkg_overlays/libmysql/fix_dup_symbols.patch b/vcpkg_overlays/libmysql/fix_dup_symbols.patch new file mode 100644 index 00000000000..352fd8af89f --- /dev/null +++ b/vcpkg_overlays/libmysql/fix_dup_symbols.patch @@ -0,0 +1,20 @@ +diff --git a/client/CMakeLists.txt b/client/CMakeLists.txt +index 058967b..bcd8841 100644 +--- a/client/CMakeLists.txt ++++ b/client/CMakeLists.txt +@@ -43,7 +43,6 @@ MYSQL_ADD_EXECUTABLE(mysql + pattern_matcher.cc + readline.cc + client_query_attributes.cc +- multi_factor_passwordopt-vars.cc + ${CMAKE_CURRENT_SOURCE_DIR}/common/user_registration.cc + LINK_LIBRARIES mysqlclient client_base ${EDITLINE_LIBRARY} + ) +@@ -226,7 +226,6 @@ SET(MYSQLBINLOG_SOURCES + ${CMAKE_SOURCE_DIR}/sql/binlog_reader.cc + ${CMAKE_SOURCE_DIR}/sql/stream_cipher.cc + ${CMAKE_SOURCE_DIR}/sql/rpl_log_encryption.cc +- ${CMAKE_SOURCE_DIR}/libbinlogevents/src/trx_boundary_parser.cpp + ) + + SET(MYSQLBINLOG_LIBRARIES diff --git a/vcpkg_overlays/libmysql/install-exports.patch b/vcpkg_overlays/libmysql/install-exports.patch new file mode 100644 index 00000000000..3cf34ed3be5 --- /dev/null +++ b/vcpkg_overlays/libmysql/install-exports.patch @@ -0,0 +1,121 @@ +diff --git a/cmake/install_macros.cmake b/cmake/install_macros.cmake +index baf49cd5..c45fda71 100644 +--- a/cmake/install_macros.cmake ++++ b/cmake/install_macros.cmake +@@ -113,8 +113,30 @@ FUNCTION(MYSQL_INSTALL_TARGET target_arg) + IF(ARG_NAMELINK_SKIP) + SET(LIBRARY_INSTALL_ARGS NAMELINK_SKIP) + ENDIF() ++ if(target STREQUAL "libmysql" OR target STREQUAL "mysqlclient") ++ target_include_directories(${target} INTERFACE $) ++ if(target STREQUAL "mysqlclient") ++ set_target_properties(${target} PROPERTIES EXPORT_NAME libmysql) # uniform ++ endif() ++ FILE(WRITE "${CMAKE_CURRENT_BINARY_DIR}/unofficial-libmysql-config.cmake" ++"include(CMakeFindDependencyMacro) ++find_dependency(OpenSSL) ++find_dependency(Threads) ++find_dependency(ZLIB) ++find_dependency(zstd CONFIG) ++include(\"\${CMAKE_CURRENT_LIST_DIR}/unofficial-libmysql-targets.cmake\") ++if(NOT TARGET ${target}) # legacy vcpkg ++ add_library(${target} INTERFACE IMPORTED) ++ set_target_properties(${target} PROPERTIES INTERFACE_LINK_LIBRARIES unofficial::libmysql::libmysql) ++endif() ++") ++ install(FILES "${CMAKE_CURRENT_BINARY_DIR}/unofficial-libmysql-config.cmake" DESTINATION "share/unofficial-libmysql") ++ install(EXPORT "unofficial-libmysql-targets" NAMESPACE unofficial::libmysql:: DESTINATION "share/unofficial-libmysql") ++ set(LIBRARY_EXPORT_ARGS EXPORT unofficial-libmysql-targets) ++ endif() + INSTALL(TARGETS ${target} +- RUNTIME DESTINATION ${ARG_DESTINATION} ${COMP} ++ ${LIBRARY_EXPORT_ARGS} ++ RUNTIME DESTINATION bin ${COMP} + ARCHIVE DESTINATION ${ARG_DESTINATION} ${COMP} + LIBRARY DESTINATION ${ARG_DESTINATION} ${COMP} ${LIBRARY_INSTALL_ARGS}) + SET(INSTALL_LOCATION ${ARG_DESTINATION} ) +diff --git a/cmake/libutils.cmake b/cmake/libutils.cmake +index a5333987..c954bfb1 100644 +--- a/cmake/libutils.cmake ++++ b/cmake/libutils.cmake +@@ -385,8 +385,12 @@ MACRO(MERGE_LIBRARIES_SHARED TARGET_ARG) + IF(ARG_NAMELINK_SKIP) + SET(INSTALL_ARGS NAMELINK_SKIP) + ENDIF() ++ if(INSTALL_STATIC_LIBRARIES) ++ set_target_properties(${TARGET} PROPERTIES EXCLUDE_FROM_ALL 1) ++ else() + MYSQL_INSTALL_TARGET(${TARGET} DESTINATION "${DESTINATION}" ${COMP} + ${INSTALL_ARGS}) ++ endif() + ENDIF() + + IF(WIN32) +@@ -563,6 +567,8 @@ MACRO(MERGE_CONVENIENCE_LIBRARIES TARGET_ARG) + ENDIF() + IF(INSTALL_STATIC_LIBRARIES) + MYSQL_INSTALL_TARGET(${TARGET} DESTINATION "${INSTALL_LIBDIR}" ${COMP}) ++ else() ++ set_target_properties(${TARGET} PROPERTIES EXCLUDE_FROM_ALL 1) + ENDIF() + ENDIF() + ENDMACRO(MERGE_CONVENIENCE_LIBRARIES) +diff --git a/scripts/CMakeLists.txt b/scripts/CMakeLists.txt +index c4ef5694..8e933877 100644 +--- a/scripts/CMakeLists.txt ++++ b/scripts/CMakeLists.txt +@@ -315,10 +315,14 @@ MACRO(EXTRACT_LINK_LIBRARIES target var) + FOREACH(lib ${TARGET_LIB_DEPENDS}) + IF (lib MATCHES "^\\-l") + SET(${var} "${${var}} ${lib} ") ++ elseif(lib MATCHES "^ext::(openssl|zlib|zstd)" AND NOT WIN32) ++ list(APPEND ext_targets "${CMAKE_MATCH_1}") + ELSEIF (lib MATCHES "^ext::") + STRING(REGEX MATCH "ext::([a-z]+)" MATCH_LIB "${lib}") + SET(SYSTEM_LIB ${CMAKE_MATCH_1}) + SET(${var} "${${var}} -l${SYSTEM_LIB} ") ++ elseif(TARGET "${lib}" AND NOT WIN32) ++ # merged or shared, not external + ELSEIF (lib MATCHES "^\\-L") + # Search directory. Test on FreeBSD: -L/usr/local/lib -lunwind + SET(${var} "${${var}} ${lib} ") +@@ -354,6 +358,7 @@ IF(MSVC) + GET_TARGET_PROPERTY(LIBMYSQL_OS_SHLIB_VERSION mysqlclient VERSION) + GET_TARGET_PROPERTY(LIBMYSQL_OS_OUTPUT_NAME mysqlclient OUTPUT_NAME) + ELSE() ++ EXTRACT_LINK_LIBRARIES(libmysql CLIENT_LIBS) + GET_TARGET_PROPERTY(LIBMYSQL_OS_SHLIB_VERSION libmysql VERSION) + GET_TARGET_PROPERTY(LIBMYSQL_OS_OUTPUT_NAME libmysql OUTPUT_NAME) + ENDIF() +@@ -373,6 +378,10 @@ IF (WITH_SSL STREQUAL "system") + "${CONFIG_LIBS_PRIVATE}") + ENDIF() + ENDIF() ++list(APPEND CONFIG_REQUIRES_PRIVATE ${ext_targets}) ++list(REMOVE_DUPLICATES CONFIG_REQUIRES_PRIVATE) ++list(JOIN CONFIG_REQUIRES_PRIVATE " " CONFIG_REQUIRES_PRIVATE) ++string(REPLACE "zstd" "libzstd" CONFIG_REQUIRES_PRIVATE "${CONFIG_REQUIRES_PRIVATE}" ) + + MESSAGE(STATUS "CONFIG_CLIENT_LIBS ${CONFIG_CLIENT_LIBS}") + MESSAGE(STATUS "CONFIG_LIBS_PRIVATE ${CONFIG_LIBS_PRIVATE}") +diff --git a/scripts/mysql_config.sh b/scripts/mysql_config.sh +index 6e8520be..bf1a45af 100644 +--- a/scripts/mysql_config.sh ++++ b/scripts/mysql_config.sh +@@ -119,6 +119,16 @@ fi + # Create options + libs="-L$pkglibdir@RPATH_OPTION@" + libs="$libs -l@LIBMYSQL_OS_OUTPUT_NAME@ @CONFIG_CLIENT_LIBS@" ++if test -z "${PKG_CONFIG}" ; then ++ if pkg-config --version >/dev/null 2>&1 ; then ++ PKG_CONFIG=pkg-config ++ elif pkgconf --version >/dev/null 2>&1 ; then ++ PKG_CONFIG=pkgconf ++ else ++ PKG_CONFIG=false ++ fi ++fi ++libs="$libs $(${PKG_CONFIG} --libs @CONFIG_REQUIRES_PRIVATE@)" + + cflags="-I$pkgincludedir @CFLAGS@" + cxxflags="-I$pkgincludedir @CXXFLAGS@" diff --git a/vcpkg_overlays/libmysql/libmysql-config.cmake b/vcpkg_overlays/libmysql/libmysql-config.cmake new file mode 100644 index 00000000000..ea2bbbe0ab0 --- /dev/null +++ b/vcpkg_overlays/libmysql/libmysql-config.cmake @@ -0,0 +1,6 @@ +file(READ "${CMAKE_CURRENT_LIST_DIR}/usage" usage) +message(WARNING "find_package(libmysql) is deprecated.\n${usage}") +include(CMakeFindDependencyMacro) +find_dependency(unofficial-libmysql CONFIG REQUIRED) +set(libmysql_FOUND 1) +set(MYSQL_LIBRARIES unofficial::libmysql::libmysql) diff --git a/vcpkg_overlays/libmysql/portfile.cmake b/vcpkg_overlays/libmysql/portfile.cmake new file mode 100644 index 00000000000..34565231170 --- /dev/null +++ b/vcpkg_overlays/libmysql/portfile.cmake @@ -0,0 +1,160 @@ +if (EXISTS "${CURRENT_INSTALLED_DIR}/include/mysql/mysql.h") + message(FATAL_ERROR "FATAL ERROR: ${PORT} and libmariadb are incompatible.") +endif() + +vcpkg_from_github( + OUT_SOURCE_PATH SOURCE_PATH + REPO mysql/mysql-server + REF mysql-${VERSION} + SHA512 5df45c1ce1e2c620856b9274666cf56738d6a0308c33c9c96583b494c987fb0e862e676301109b9e4732070d54e6086596a62ad342f35adc59ca9f749e37b561 + HEAD_REF master + PATCHES + dependencies.patch + install-exports.patch + fix_dup_symbols.patch + cross-build.patch +) + +vcpkg_check_features(OUT_FEATURE_OPTIONS FEATURE_OPTIONS + INVERTED_FEATURES + host-tools FORCE_CMAKE_CROSSCOMPILING +) + +file(GLOB third_party "${SOURCE_PATH}/extra/*" "${SOURCE_PATH}/include/boost_1_70_0") +list(REMOVE_ITEM third_party "${SOURCE_PATH}/extra/libedit") +if (third_party) + file(REMOVE_RECURSE ${third_party}) +endif() + +#Skip the version check for Visual Studio +set(FORCE_UNSUPPORTED_COMPILER "") +if(VCPKG_TARGET_IS_WINDOWS) + set(FORCE_UNSUPPORTED_COMPILER 1) +endif() + +string(COMPARE EQUAL "${VCPKG_LIBRARY_LINKAGE}" "static" BUILD_STATIC_LIBS) +string(COMPARE EQUAL "${VCPKG_CRT_LINKAGE}" "static" STATIC_CRT_LINKAGE) + +set(cross_options "") +if(VCPKG_CROSSCOMPILING) + list(APPEND cross_options + -DCMAKE_CROSSCOMPILING=1 + -DVCPKG_HOST_TRIPLET=${HOST_TRIPLET} + # required, skip try_run + -DHAVE_RAPIDJSON_WITH_STD_REGEX=1 + ) + if(NOT VCPKG_TARGET_IS_WINDOWS) + list(APPEND cross_options + # optimistic, skip try_run + -DHAVE_CLOCK_GETTIME=1 + -DHAVE_CLOCK_REALTIME=1 + # pessimistic, skip try_run + -DHAVE_C_FLOATING_POINT_FUSED_MADD=1 + -DHAVE_CXX_FLOATING_POINT_FUSED_MADD=1 + -DHAVE_SETNS=0 + ) + endif() +endif() +if ("-DFORCE_CMAKE_CROSSCOMPILING=ON" IN_LIST FEATURE_OPTIONS) + list(APPEND cross_options + -DCMAKE_CROSSCOMPILING=OFF + ) +endif() + +vcpkg_cmake_configure( + SOURCE_PATH "${SOURCE_PATH}" + OPTIONS + ${cross_options} + -DINSTALL_INCLUDEDIR=include/mysql + -DINSTALL_DOCDIR=share/${PORT}/doc + -DINSTALL_MANDIR=share/${PORT}/doc + -DINSTALL_INFODIR=share/${PORT}/doc + -DINSTALL_DOCREADMEDIR=share/${PORT} + -DINSTALL_SHAREDIR=share + -DINSTALL_MYSQLSHAREDIR=share/${PORT} + -DWITHOUT_SERVER=ON + -DWITH_BUILD_ID=OFF + -DWITH_UNIT_TESTS=OFF + -DENABLED_PROFILING=OFF + -DWIX_DIR=OFF + -DIGNORE_BOOST_VERSION=ON + -DWITH_TEST_TRACE_PLUGIN=OFF + -DMYSQL_MAINTAINER_MODE=OFF + -DBUNDLE_RUNTIME_LIBRARIES=OFF + -DDOWNLOAD_BOOST=OFF + -DWITH_CURL=none + -DWITH_EDITLINE=bundled # not in vcpkg + -DWITH_LZ4=system + -DWITH_RAPIDJSON=system + -DWITH_SSL=system + -DWITH_SYSTEMD=OFF + -DWITH_ZLIB=system + -DWITH_ZSTD=system + -DFORCE_UNSUPPORTED_COMPILER=${FORCE_UNSUPPORTED_COMPILER} + -DINSTALL_STATIC_LIBRARIES=${BUILD_STATIC_LIBS} + -DLINK_STATIC_RUNTIME_LIBRARIES=${STATIC_CRT_LINKAGE} + MAYBE_UNUSED_VARIABLES + BUNDLE_RUNTIME_LIBRARIES # only on windows + LINK_STATIC_RUNTIME_LIBRARIES # only on windows + WIX_DIR # only on windows + WITH_BUILD_ID # only on windows +) + +vcpkg_cmake_install(ADD_BIN_TO_PATH) +vcpkg_cmake_config_fixup(PACKAGE_NAME unofficial-libmysql) +vcpkg_fixup_pkgconfig() + +set(MYSQL_TOOLS + my_print_defaults + mysql + mysql_config_editor + mysql_migrate_keyring + mysql_secure_installation + mysql_ssl_rsa_setup + mysqladmin + mysqlbinlog + mysqlcheck + mysqldump + mysqlimport + mysqlpump + mysqlshow + mysqlslap + mysqltest + perror + zlib_decompress +) +if (NOT VCPKG_CROSSCOMPILING) + list(APPEND MYSQL_TOOLS + comp_err + ) +endif() +if (VCPKG_TARGET_IS_WINDOWS) + list(APPEND MYSQL_TOOLS + echo + ) +else() + list(APPEND MYSQL_TOOLS + mysql_config + ) +endif() + +vcpkg_copy_tools(TOOL_NAMES ${MYSQL_TOOLS} AUTO_CLEAN) + +file(REMOVE_RECURSE + "${CURRENT_PACKAGES_DIR}/debug/include" + "${CURRENT_PACKAGES_DIR}/debug/share" + "${CURRENT_PACKAGES_DIR}/lib/debug" +) + +if (NOT VCPKG_TARGET_IS_WINDOWS) + set(MYSQL_CONFIG_FILE "${CURRENT_PACKAGES_DIR}/tools/libmysql/mysql_config") + vcpkg_replace_string("${MYSQL_CONFIG_FILE}" "/bin/mysql_.*config" "/tools/libmysql/mysql_.*config") + vcpkg_replace_string("${MYSQL_CONFIG_FILE}" "'${CURRENT_PACKAGES_DIR}" "\"\$basedir\"\'") +endif() + +file(INSTALL "${CURRENT_PORT_DIR}/libmysql-config.cmake" DESTINATION "${CURRENT_PACKAGES_DIR}/share/${PORT}") +file(INSTALL "${CURRENT_PORT_DIR}/usage" DESTINATION "${CURRENT_PACKAGES_DIR}/share/${PORT}") + +set(libedit_copying "${SOURCE_PATH}/COPYING for libedit") +file(COPY_FILE "${SOURCE_PATH}/extra/libedit/libedit-20210910-3.1/COPYING" "${libedit_copying}") +vcpkg_install_copyright(FILE_LIST "${SOURCE_PATH}/LICENSE" "${libedit_copying}") diff --git a/vcpkg_overlays/libmysql/usage b/vcpkg_overlays/libmysql/usage new file mode 100644 index 00000000000..7ea8c37e177 --- /dev/null +++ b/vcpkg_overlays/libmysql/usage @@ -0,0 +1,4 @@ +libmysql provides CMake targets: + + find_package(unofficial-libmysql REQUIRED) + target_link_libraries(main PRIVATE unofficial::libmysql::libmysql) diff --git a/vcpkg_overlays/libmysql/vcpkg.json b/vcpkg_overlays/libmysql/vcpkg.json new file mode 100644 index 00000000000..b143f59ef7f --- /dev/null +++ b/vcpkg_overlays/libmysql/vcpkg.json @@ -0,0 +1,47 @@ +{ + "name": "libmysql", + "version": "8.0.34", + "port-version": 1, + "description": "A MySQL client library for C development", + "homepage": "https://github.com/mysql/mysql-server", + "license": "GPL-2.0-or-later", + "supports": "!android & !mingw & !uwp & !xbox", + "dependencies": [ + "boost-algorithm", + "boost-functional", + "boost-geometry", + "boost-graph", + "boost-optional", + "lz4", + { + "name": "ncurses", + "platform": "!windows | mingw" + }, + "openssl", + "rapidjson", + { + "name": "vcpkg-cmake", + "host": true + }, + { + "name": "vcpkg-cmake-config", + "host": true + }, + "zlib", + "zstd" + ], + "default-features": [ + "host-tools" + ], + "features": { + "host-tools": { + "description": "Build CLI tools", + "dependencies": [ + { + "name": "libmysql", + "host": true + } + ] + } + } +} \ No newline at end of file