From e1b358fb9029793c4126357a0241ae6063f55941 Mon Sep 17 00:00:00 2001 From: Martin Valgur Date: Tue, 26 Dec 2023 16:20:20 +0200 Subject: [PATCH 01/16] mysql-connector-cpp: new recipe --- .../mysql-connector-cpp/all/conan_deps.cmake | 9 + recipes/mysql-connector-cpp/all/conandata.yml | 9 + recipes/mysql-connector-cpp/all/conanfile.py | 165 ++++++++++++++++++ .../all/test_package/CMakeLists.txt | 8 + .../all/test_package/conanfile.py | 26 +++ .../all/test_package/test_package.cpp | 22 +++ recipes/mysql-connector-cpp/config.yml | 3 + 7 files changed, 242 insertions(+) create mode 100644 recipes/mysql-connector-cpp/all/conan_deps.cmake create mode 100644 recipes/mysql-connector-cpp/all/conandata.yml create mode 100644 recipes/mysql-connector-cpp/all/conanfile.py create mode 100644 recipes/mysql-connector-cpp/all/test_package/CMakeLists.txt create mode 100644 recipes/mysql-connector-cpp/all/test_package/conanfile.py create mode 100644 recipes/mysql-connector-cpp/all/test_package/test_package.cpp create mode 100644 recipes/mysql-connector-cpp/config.yml diff --git a/recipes/mysql-connector-cpp/all/conan_deps.cmake b/recipes/mysql-connector-cpp/all/conan_deps.cmake new file mode 100644 index 0000000000000..26965444dee25 --- /dev/null +++ b/recipes/mysql-connector-cpp/all/conan_deps.cmake @@ -0,0 +1,9 @@ +list(PREPEND CMAKE_PREFIX_PATH ${CMAKE_BINARY_DIR}/generators) + +find_package(LZ4 REQUIRED CONFIG) +find_package(MySQL REQUIRED CONFIG) +#find_package(OpenSSL REQUIRED CONFIG) +find_package(Protobuf REQUIRED CONFIG) +find_package(RapidJSON REQUIRED CONFIG) +find_package(ZLIB REQUIRED CONFIG) +find_package(Zstd REQUIRED CONFIG) diff --git a/recipes/mysql-connector-cpp/all/conandata.yml b/recipes/mysql-connector-cpp/all/conandata.yml new file mode 100644 index 0000000000000..f92dbe9d711e0 --- /dev/null +++ b/recipes/mysql-connector-cpp/all/conandata.yml @@ -0,0 +1,9 @@ +sources: + "8.2.0": + url: "https://dev.mysql.com/get/Downloads/Connector-C++/mysql-connector-c++-8.2.0-src.tar.gz" + sha256: "9424668225c5a73f7b7805cd36d75d8502c9a8e20ca11c952653155ef6e909da" +#patches: +# "8.2.0": +# - patch_file: "patches/0006-fix-cpp20-build-8.1.0.patch" +# patch_description: "Fix C++20 compilation" +# patch_type: "portability" diff --git a/recipes/mysql-connector-cpp/all/conanfile.py b/recipes/mysql-connector-cpp/all/conanfile.py new file mode 100644 index 0000000000000..03b89be6238b1 --- /dev/null +++ b/recipes/mysql-connector-cpp/all/conanfile.py @@ -0,0 +1,165 @@ +import os + +from conan import ConanFile +from conan.errors import ConanInvalidConfiguration +from conan.tools.build import check_min_cppstd +from conan.tools.cmake import CMake, CMakeToolchain, CMakeDeps, cmake_layout +from conan.tools.env import VirtualRunEnv, VirtualBuildEnv +from conan.tools.files import rename, get, rmdir, save, copy, replace_in_file, rm +from conan.tools.microsoft import is_msvc_static_runtime +from conan.tools.scm import Version + +required_conan_version = ">=1.55.0" + + +class MysqlConnectorCppConan(ConanFile): + name = "mysql-connector-cpp" + description = "MySQL database connector for C++ applications" + license = "GPL-2.0-only WITH Universal-FOSS-exception-1.0" + url = "https://github.com/conan-io/conan-center-index" + homepage = "https://dev.mysql.com/doc/connector-cpp/en/" + topics = ("mysql", "sql", "connector", "database") + + package_type = "library" + settings = "os", "arch", "compiler", "build_type" + options = { + "shared": [True, False], + "fPIC": [True], # fPIC is required by internal libraries + } + default_options = { + "shared": False, + "fPIC": True, + } + + @property + def _min_cppstd(self): + return 17 + + @property + def _compilers_minimum_version(self): + return { + "Visual Studio": "16", + "msvc": "192", + "gcc": "5", + "clang": "6", + } + + def export_sources(self): + copy(self, "conan_deps.cmake", self.recipe_folder, os.path.join(self.export_sources_folder, "src")) + + def config_options(self): + if self.settings.os == "Windows": + del self.options.fPIC + + def configure(self): + if self.options.shared: + self.options.rm_safe("fPIC") + + def layout(self): + cmake_layout(self, src_folder="src") + + def requirements(self): + # None of the dependencies are used transitively + self.requires("libmysqlclient/8.2.0") + self.requires("lz4/1.9.4") + self.requires("openssl/[>=1.1 <4]") + self.requires("rapidjson/cci.20230929") + self.requires("zlib/[>=1.2.11 <2]") + self.requires("zstd/1.5.5") + self.requires("protobuf/3.21.12") + + def validate_build(self): + if self.settings.compiler.get_safe("cppstd"): + check_min_cppstd(self, self._min_cppstd) + + def validate(self): + minimum_version = self._compilers_minimum_version.get(str(self.settings.compiler), False) + if minimum_version and Version(self.settings.compiler.version) < minimum_version: + raise ConanInvalidConfiguration(f"{self.ref} requires {self.settings.compiler} {minimum_version} or newer") + + def build_requirements(self): + self.tool_requires("protobuf/") + + def source(self): + get(self, **self.conan_data["sources"][self.version], strip_root=True) + + def _patch_sources(self): + # Unvendor dependencies + for subdir in ["lz4", "protobuf", "rapidjson", "zlib", "zstd"]: + rmdir(self, os.path.join(self.source_folder, "cdk", "extra", subdir)) + save(self, os.path.join(self.source_folder, "cdk", "extra", subdir, "CMakeLists.txt"), "") + + # Dependencies are found by conan_deps.cmake, adjust modules accordingly + for find_module in self.source_path.joinpath("cdk", "cmake").rglob("DepFind*.cmake"): + if "SSL" not in find_module.name: + replace_in_file(self, find_module, "if(TARGET ", "if(0) # if(TARGET ", strict=False) + replace_in_file(self, find_module, "add_ext_targets", "message(TRACE #", strict=False) + save(self, os.path.join(self.source_folder, "cdk", "cmake", "DepFindCompression.cmake"), "") + replace_in_file(self, os.path.join(self.source_folder, "cdk", "cmake", "DepFindProtobuf.cmake"), + "ext::protoc", "protoc") + + # Buggy and not required for the build + replace_in_file(self, os.path.join(self.source_folder, "CMakeLists.txt"), + 'set_target_properties(${T} PROPERTIES FOLDER "CDK")', "") + + # Link against protobuf instead of protobuf-lite, if necessary + if not self.dependencies["protobuf"].options.lite: + replace_in_file(self, os.path.join(self.source_folder, "cdk", "core", "CMakeLists.txt"), + "ext::protobuf-lite", "ext::protobuf") + replace_in_file(self, os.path.join(self.source_folder, "cdk", "protocol", "mysqlx", "CMakeLists.txt"), + "set(use_full_protobuf ${WITH_TESTS})", "set(use_full_protobuf 1)") + + def generate(self): + VirtualBuildEnv(self).generate() + VirtualRunEnv(self).generate(scope="build") + + tc = CMakeToolchain(self) + tc.cache_variables["CMAKE_PROJECT_MySQL_CONCPP_INCLUDE"] = os.path.join(self.source_folder, "conan_deps.cmake") + tc.cache_variables["BUNDLE_DEPENDENCIES"] = False + tc.cache_variables["BUILD_STATIC"] = not self.options.shared + tc.cache_variables["STATIC_MSVCRT"] = is_msvc_static_runtime(self) + tc.cache_variables["WITH_TESTS"] = False + tc.cache_variables["WITH_SSL"] = "system" + tc.cache_variables["OPENSSL_ROOT_DIR"] = self.dependencies["openssl"].package_folder.replace("\\", "/") + tc.generate() + + deps = CMakeDeps(self) + deps.set_property("libmysqlclient", "cmake_file_name", "MySQL") + deps.set_property("libmysqlclient", "cmake_target_name", "MySQL::client") + deps.set_property("lz4", "cmake_target_name", "ext::lz4") + deps.set_property("protobuf::libprotobuf", "cmake_target_name", "ext::protobuf") + deps.set_property("protobuf::libprotobuf-lite", "cmake_target_name", "ext::protobuf-lite") + deps.set_property("rapidjson", "cmake_target_name", "RapidJSON::rapidjson") + deps.set_property("zlib", "cmake_target_name", "ext::z") + deps.set_property("zstd", "cmake_target_name", "ext::zstd") + deps.generate() + + def build(self): + self._patch_sources() + cmake = CMake(self) + cmake.configure() + cmake.build() + + def package(self): + copy(self, "LICENSE.txt", self.source_folder, os.path.join(self.package_folder, "licenses")) + cmake = CMake(self) + cmake.install() + if self.package_path.joinpath("lib64").exists(): + rename(self, self.package_path.joinpath("lib64"), self.package_path.joinpath("lib")) + rm(self, "*.pdb", self.package_folder, recursive=True) + + def package_info(self): + major_ver = Version(self.version).major + lib = f"mysqlcppconn{major_ver}" + if not self.options.shared: + lib += "-static" + self.cpp_info.libs = [lib] + + if self.settings.os == "Windows": + self.cpp_info.system_libs.append("dnsapi") + self.cpp_info.system_libs.append("ws2_32") + elif self.settings.os != "FreeBSD": + self.cpp_info.system_libs.append("resolv") + if self.settings.os == "SunOS": + self.cpp_info.system_libs.append("socket") + self.cpp_info.system_libs.append("nsl") diff --git a/recipes/mysql-connector-cpp/all/test_package/CMakeLists.txt b/recipes/mysql-connector-cpp/all/test_package/CMakeLists.txt new file mode 100644 index 0000000000000..fefd7a2e00086 --- /dev/null +++ b/recipes/mysql-connector-cpp/all/test_package/CMakeLists.txt @@ -0,0 +1,8 @@ +cmake_minimum_required(VERSION 3.15) +project(test_package LANGUAGES CXX) + +find_package(mysql-connector-cpp REQUIRED CONFIG) + +add_executable(${PROJECT_NAME} test_package.cpp) +target_link_libraries(${PROJECT_NAME} PRIVATE mysql-connector-cpp::mysql-connector-cpp) +target_compile_features(${PROJECT_NAME} PRIVATE cxx_std_17) diff --git a/recipes/mysql-connector-cpp/all/test_package/conanfile.py b/recipes/mysql-connector-cpp/all/test_package/conanfile.py new file mode 100644 index 0000000000000..dd09e74d7fe14 --- /dev/null +++ b/recipes/mysql-connector-cpp/all/test_package/conanfile.py @@ -0,0 +1,26 @@ +from conan import ConanFile +from conan.tools.build import can_run +from conan.tools.cmake import CMake, cmake_layout +import os + + +class TestPackageConan(ConanFile): + settings = "os", "arch", "compiler", "build_type" + generators = "CMakeDeps", "CMakeToolchain", "VirtualRunEnv" + test_type = "explicit" + + def layout(self): + cmake_layout(self) + + def requirements(self): + self.requires(self.tested_reference_str) + + def build(self): + cmake = CMake(self) + cmake.configure() + cmake.build() + + def test(self): + if can_run(self): + bin_path = os.path.join(self.cpp.build.bindir, "test_package") + self.run(bin_path, env="conanrun") diff --git a/recipes/mysql-connector-cpp/all/test_package/test_package.cpp b/recipes/mysql-connector-cpp/all/test_package/test_package.cpp new file mode 100644 index 0000000000000..d431fb68b665d --- /dev/null +++ b/recipes/mysql-connector-cpp/all/test_package/test_package.cpp @@ -0,0 +1,22 @@ +#include + +#include + + +void test() { + using namespace mysqlx::abi2::r0; + Session sess("localhost", 33060, "user", "password"); + Schema db = sess.getSchema("test"); + + Collection myColl = db.getCollection("my_collection"); + + DocResult myDocs = myColl.find("name like :param") + .limit(1) + .bind("param", "L%").execute(); + + std::cout << myDocs.fetchOne(); +} + +int main() { + return 0; +} diff --git a/recipes/mysql-connector-cpp/config.yml b/recipes/mysql-connector-cpp/config.yml new file mode 100644 index 0000000000000..ded307567d87e --- /dev/null +++ b/recipes/mysql-connector-cpp/config.yml @@ -0,0 +1,3 @@ +versions: + "8.2.0": + folder: all From daf4bcc2abf599db83b406731dc20cc2de4a99bf Mon Sep 17 00:00:00 2001 From: Hussein Itawi <26905155+husitawi@users.noreply.github.com> Date: Sun, 21 Jul 2024 16:47:33 +0300 Subject: [PATCH 02/16] Added mysqlcppconn recipe --- recipes/mysql-connector-cpp/all/conandata.yml | 5 + recipes/mysql-connector-cpp/all/conanfile.py | 237 ++++++++++++++++++ .../all/test_package/CMakeLists.txt | 8 + .../all/test_package/conanfile.py | 26 ++ .../all/test_package/src/example.cpp | 7 + recipes/mysql-connector-cpp/config.yml | 3 + 6 files changed, 286 insertions(+) create mode 100644 recipes/mysql-connector-cpp/all/conandata.yml create mode 100644 recipes/mysql-connector-cpp/all/conanfile.py create mode 100644 recipes/mysql-connector-cpp/all/test_package/CMakeLists.txt create mode 100644 recipes/mysql-connector-cpp/all/test_package/conanfile.py create mode 100644 recipes/mysql-connector-cpp/all/test_package/src/example.cpp create mode 100644 recipes/mysql-connector-cpp/config.yml diff --git a/recipes/mysql-connector-cpp/all/conandata.yml b/recipes/mysql-connector-cpp/all/conandata.yml new file mode 100644 index 0000000000000..b2dd3c5e5094a --- /dev/null +++ b/recipes/mysql-connector-cpp/all/conandata.yml @@ -0,0 +1,5 @@ +sources: + "9.0.0": + url: "https://github.com/mysql/mysql-connector-cpp/archive/refs/tags/9.0.0.zip" + sha256: "9d4b90a4efe8861e821136fb3024074d14875749d8b69d1821361b2f2b8bfe55" + diff --git a/recipes/mysql-connector-cpp/all/conanfile.py b/recipes/mysql-connector-cpp/all/conanfile.py new file mode 100644 index 0000000000000..beb79c2632f29 --- /dev/null +++ b/recipes/mysql-connector-cpp/all/conanfile.py @@ -0,0 +1,237 @@ +import os +from conan import ConanFile +from conan.errors import ConanInvalidConfiguration +from conan.tools.apple import is_apple_os +from conan.tools.cmake import CMakeToolchain, CMake, cmake_layout, CMakeDeps +from conan.tools.build import check_min_cppstd, cross_building +from conan.tools.files import get, replace_in_file, copy, rm +from conan.tools.scm import Version +from conan.tools.microsoft import is_msvc, is_msvc_static_runtime + +required_conan_version = ">=1.64.1" + +class MysqlCppConnRecipe(ConanFile): + name = "mysql-connector-cpp" + package_type = "library" + short_paths = True + version= "9.0.0" + + # Optional metadata + license = "GPL-2.0-only" + url = "https://github.com/conan-io/conan-center-index" + homepage = "https://github.com/mysql/mysql-connector-cpp" + description = "A MySQL client library for C++ development" + topics = ("mysql", "sql", "connector", "database", "c++", "cpp") + + # Binary configuration + settings = "os", "compiler", "build_type", "arch" + options = { + "shared": [True, False], + "fPIC": [True, False], + } + + default_options = { "shared": False, "fPIC": True } + + @property + def _minimum_compilers_version(self): + return { + "Visual Studio": "14", + "msvc": "192", + "gcc": "8", + "clang": "7", + "apple-clang": "10", + } + + def validate(self): + if self.settings.compiler.get_safe("cppstd"): + check_min_cppstd(self, "17") + + # Compiler minimum version + compiler = self.settings.compiler + compiler_name = str(compiler) + minimum_version = self._minimum_compilers_version.get(compiler_name, False) + if minimum_version and Version(compiler.version) < minimum_version: + raise ConanInvalidConfiguration( + f"Requires compiler {compiler_name} minimum version: {minimum_version} with C++17 support." + ) + + def requirements(self): + self.requires("openssl/1.0.2u") + self.requires("zlib/[>=1.2.11 <2]") + self.requires("protobuf/3.21.12") + + def build_requirements(self): + if not is_msvc(self): + self.tool_requires("ninja/[>=1.10 <2]") + + def source(self): + get(self, **self.conan_data["sources"][self.version], strip_root=True) + + def config_options(self): + if self.settings.os == "Windows": + self.options.rm_safe("fPIC") + + def configure(self): + if self.options.shared: + self.options.rm_safe("fPIC") + + def layout(self): + cmake_layout(self, src_folder="src") + + def _package_folder_dep(self, dep): + return self.dependencies[dep].package_folder.replace("\\", "/") + + def _include_folder_dep(self, dep): + return self.dependencies[dep].cpp_info.includedirs[0].replace("\\", "/") + + def _lib_folder_dep(self, dep): + return self.dependencies[dep].cpp_info.libdirs[0].replace("\\", "/") + + def generate(self): + + tc = CMakeToolchain(self, generator="Ninja") if not is_msvc(self) else CMakeToolchain(self) + + # OpenSSL + tc.cache_variables["WITH_SSL"] = "SYSTEM" + # LZ4 patches + tc.cache_variables["WITH_LZ4"] = "TRUE" + # ZLIB patches + tc.cache_variables["WITH_ZLIB"] = "TRUE" if self.settings.os == "Windows" else self._package_folder_dep("zlib") + # ZSTD patches + tc.cache_variables["WITH_ZSTD"] = "TRUE" + # Build patches + tc.cache_variables["BUILD_STATIC"] = not self.options.shared + tc.cache_variables["BUILD_SHARED_LIBS"] = self.options.shared + # Disable Boost, only legacy JDBC connector needs it + tc.cache_variables["BOOST_DIR"] = "FALSE" + # Protobuf + tc.cache_variables["WITH_PROTOBUF"] = self._package_folder_dep("protobuf") + + # Windows patches + if self.settings.os == "Windows": + # OpenSSL patches + tc.cache_variables["WITH_SSL"] = self._package_folder_dep("openssl") + + tc.generate() + + deps = CMakeDeps(self) + deps.generate() + + def _patch_sources(self): + + # Fix static lib naming + if not self.options.shared and is_msvc(self): + replace_in_file(self, os.path.join(self.source_folder, "install_layout.cmake"), + "set(LIB_NAME_STATIC \"${LIB_NAME}-mt\")", + "set(LIB_NAME_STATIC \"${LIB_NAME_STATIC}-mt\")", + strict=False) + + # ZSTD patch + replace_in_file(self, os.path.join(self.source_folder, "cdk", "extra", "zstd", "CMakeLists.txt"), + "enable_pic()", + "enable_pic()\n"\ + "add_compile_definitions(ZSTD_DISABLE_ASM)", + strict=False) + + # Fix shared zlib build = duplicate references + if self.options.shared and self.settings.os in ["Linux", "FreeBSD"] : + # ZLIB patch + replace_in_file(self, os.path.join(self.source_folder, "cdk", "extra", "protobuf", "protobuf-3.19.6", "cmake", "CMakeLists.txt"), + "set(protobuf_WITH_ZLIB_DEFAULT ON)", + "set(protobuf_WITH_ZLIB_DEFAULT OFF)", + strict=False) + + # mysqlx && ZLIB patch + replace_in_file(self, os.path.join(self.source_folder, "cdk", "protocol", "mysqlx", "CMakeLists.txt"), + "PRIVATE cdk_foundation ext::z ext::lz4 ext::zstd", + "PRIVATE cdk_foundation ZLIB::ZLIB ext::lz4 ext::zstd", + strict=False) + + # Apple patches + if is_apple_os(self) and cross_building(self): + patch = f"set(CMAKE_OSX_ARCHITECTURES \"{self.settings.arch}\" CACHE INTERNAL \"\" FORCE)\n" + + replace_in_file(self, os.path.join(self.source_folder, "CMakeLists.txt"), + "PROJECT(MySQL_CONCPP)", + f"PROJECT(MySQL_CONCPP)\n{patch}", + strict=False) + # Packages-Apple patches + for lb in ["lz4", 'zlib', 'protobuf', 'zstd']: + replace_in_file(self, os.path.join(self.source_folder, "cdk", "extra", lb, "CMakeLists.txt"), + "enable_pic()", + f"enable_pic()\n{patch}", + strict=False) + + # Protobuf patches + protobuf = "protobufd" if self.dependencies["protobuf"].settings.build_type == "Debug" else "protobuf" + # INFO: Disable protobuf-lite to use Conan protobuf targets instead + replace_in_file(self, os.path.join(self.source_folder, "cdk", "cmake", "DepFindProtobuf.cmake"), "LIBRARY protobuf-lite pb_libprotobuf-lite", "") + # INFO: Fix protobuf library name according to the build type + replace_in_file(self, os.path.join(self.source_folder, "cdk", "cmake", "DepFindProtobuf.cmake"), "LIBRARY protobuf", f"LIBRARY {protobuf}") + # INFO: Disable protobuf-lite to use Conan protobuf targets instead + replace_in_file(self, os.path.join(self.source_folder, "cdk", "protocol", "mysqlx", "CMakeLists.txt"), "ext::protobuf-lite", f"ext::{protobuf}") + # INFO: Disable protobuf-lite to use Conan protobuf targets instead + replace_in_file(self, os.path.join(self.source_folder, "cdk", "core", "CMakeLists.txt"), "ext::protobuf-lite", f"ext::{protobuf}") + + def build(self): + self._patch_sources() + cmake = CMake(self) + cmake.configure() + cmake.build() + + def package(self): + cmake = CMake(self) + cmake.install() + + # Clean + rm(self, "INFO_SRC", self.package_folder) + rm(self, "INFO_BIN", self.package_folder) + rm(self, "*.cmake", self.package_folder) + + # Add License + copy(self, "LICENSE.txt", dst=os.path.join(self.package_folder, "licenses"), src=self.source_folder) + + @property + def _package_dirs(self): + template_dirs = ["lib64", "lib"] if self.settings.build_type == "Release" else [os.path.join("lib64", "debug"), os.path.join("lib", "debug")] + if is_msvc(self): + template_dirs = [os.path.join(lib, "vs14") for lib in template_dirs] + else: + template_dirs = template_dirs + + # Clean out bad dirs + template_dirs = [path for path in template_dirs if os.path.isdir(path)] + return template_dirs + + def package_info(self): + dirs = self._package_dirs + self.cpp_info.bindirs = dirs + self.cpp_info.libdirs= dirs + + if is_apple_os(self) or self.settings.os in ["Linux", "FreeBSD"]: + self.cpp_info.system_libs.extend(["resolv"]) + if self.settings.os in ["Linux", "FreeBSD"]: + self.cpp_info.system_libs.extend(["m", "pthread"]) + + target = "concpp-xdevapi" + target_alias = "concpp" + + if self.options.shared: + target += "-static" + target_alias += "-static" + + if self.settings.build_type == "Debug": + target += "-debug" + target_alias += "-debug" + + self.cpp_info.set_property("cmake_target_name", "mysql::concpp") + self.cpp_info.set_property("cmake_target_aliases", [f"mysql::{target_alias}"] ) + + lib = "mysqlcppconnx" if self.options.shared else "mysqlcppconnx-static" + if is_msvc(self) and not self.options.shared and is_msvc_static_runtime(self): + lib += "-mt" + self.cpp_info.libs = [lib] + + if not self.options.shared: + self.cpp_info.defines = ["MYSQL_STATIC"] + self.cpp_info.defines = ["STATIC_CONCPP"] diff --git a/recipes/mysql-connector-cpp/all/test_package/CMakeLists.txt b/recipes/mysql-connector-cpp/all/test_package/CMakeLists.txt new file mode 100644 index 0000000000000..2ee79a2234e33 --- /dev/null +++ b/recipes/mysql-connector-cpp/all/test_package/CMakeLists.txt @@ -0,0 +1,8 @@ +cmake_minimum_required(VERSION 3.15) +project(PackageTest CXX) + +find_package(mysql-connector-cpp REQUIRED CONFIG) + +add_executable(${PROJECT_NAME} src/example.cpp) +target_link_libraries(${PROJECT_NAME} PRIVATE mysql::concpp) +target_compile_features(${PROJECT_NAME} PRIVATE cxx_std_17) diff --git a/recipes/mysql-connector-cpp/all/test_package/conanfile.py b/recipes/mysql-connector-cpp/all/test_package/conanfile.py new file mode 100644 index 0000000000000..646066c5d86d1 --- /dev/null +++ b/recipes/mysql-connector-cpp/all/test_package/conanfile.py @@ -0,0 +1,26 @@ +import os + +from conan import ConanFile +from conan.tools.cmake import CMake, cmake_layout +from conan.tools.build import can_run + + +class TestPackageConan(ConanFile): + settings = "os", "compiler", "build_type", "arch" + generators = "CMakeDeps", "CMakeToolchain" + + def requirements(self): + self.requires(self.tested_reference_str) + + def build(self): + cmake = CMake(self) + cmake.configure() + cmake.build() + + def layout(self): + cmake_layout(self) + + def test(self): + if can_run(self): + cmd = os.path.join(self.cpp.build.bindir, "PackageTest") + self.run(cmd, env="conanrun") diff --git a/recipes/mysql-connector-cpp/all/test_package/src/example.cpp b/recipes/mysql-connector-cpp/all/test_package/src/example.cpp new file mode 100644 index 0000000000000..28ac0d69f3e4c --- /dev/null +++ b/recipes/mysql-connector-cpp/all/test_package/src/example.cpp @@ -0,0 +1,7 @@ +#include + +int main() +{ + mysqlx::SessionSettings from_url("mysqlx://user:pwd@127.0.0.1:1234/db?ssl-mode=required"); + return 0; +} \ No newline at end of file diff --git a/recipes/mysql-connector-cpp/config.yml b/recipes/mysql-connector-cpp/config.yml new file mode 100644 index 0000000000000..876addd4673bf --- /dev/null +++ b/recipes/mysql-connector-cpp/config.yml @@ -0,0 +1,3 @@ +versions: + "9.0.0": + folder: all From 8d61029e8072bce324e9536814e959229cf987c8 Mon Sep 17 00:00:00 2001 From: Martin Valgur Date: Sat, 7 Sep 2024 00:17:53 +0300 Subject: [PATCH 03/16] mysql-connector-cpp: fix build --- recipes/mysql-connector-cpp/all/conandata.yml | 18 +++- recipes/mysql-connector-cpp/all/conanfile.py | 74 +++++++++----- .../0001-override-cmake-policy-version.patch | 45 +++++++++ .../9.0.0/0002-rename-find_dependency.patch | 96 +++++++++++++++++++ .../0003-inject-conan-dependencies.patch | 94 ++++++++++++++++++ .../0004-add-target_include_directories.patch | 43 +++++++++ .../0005-simplify-install-directories.patch | 55 +++++++++++ .../all/test_package/CMakeLists.txt | 4 +- 8 files changed, 400 insertions(+), 29 deletions(-) create mode 100644 recipes/mysql-connector-cpp/all/patches/9.0.0/0001-override-cmake-policy-version.patch create mode 100644 recipes/mysql-connector-cpp/all/patches/9.0.0/0002-rename-find_dependency.patch create mode 100644 recipes/mysql-connector-cpp/all/patches/9.0.0/0003-inject-conan-dependencies.patch create mode 100644 recipes/mysql-connector-cpp/all/patches/9.0.0/0004-add-target_include_directories.patch create mode 100644 recipes/mysql-connector-cpp/all/patches/9.0.0/0005-simplify-install-directories.patch diff --git a/recipes/mysql-connector-cpp/all/conandata.yml b/recipes/mysql-connector-cpp/all/conandata.yml index b2dd3c5e5094a..76bb1f03918af 100644 --- a/recipes/mysql-connector-cpp/all/conandata.yml +++ b/recipes/mysql-connector-cpp/all/conandata.yml @@ -2,4 +2,20 @@ sources: "9.0.0": url: "https://github.com/mysql/mysql-connector-cpp/archive/refs/tags/9.0.0.zip" sha256: "9d4b90a4efe8861e821136fb3024074d14875749d8b69d1821361b2f2b8bfe55" - +patches: + "9.0.0": + - patch_file: "patches/9.0.0/0001-override-cmake-policy-version.patch" + patch_description: "Set CMake policy version to 3.15, move project() statement" + patch_type: "conan" + - patch_file: "patches/9.0.0/0002-rename-find_dependency.patch" + patch_description: "Rename find_dependency() to avoid conflicts with the official CMake function" + patch_type: "conan" + - patch_file: "patches/9.0.0/0003-inject-conan-dependencies.patch" + patch_description: "Inject Conan dependencies" + patch_type: "conan" + - patch_file: "patches/9.0.0/0004-add-target_include_directories.patch" + patch_description: "Add target_include_directories() for compatibility with Conan v1" + patch_type: "conan" + - patch_file: "patches/9.0.0/0005-simplify-install-directories.patch" + patch_description: "Do not install libraries into subdirectories" + patch_type: "conan" diff --git a/recipes/mysql-connector-cpp/all/conanfile.py b/recipes/mysql-connector-cpp/all/conanfile.py index 835c47ff78f72..a94c793894053 100644 --- a/recipes/mysql-connector-cpp/all/conanfile.py +++ b/recipes/mysql-connector-cpp/all/conanfile.py @@ -4,9 +4,9 @@ from conan.errors import ConanInvalidConfiguration from conan.tools.build import check_min_cppstd from conan.tools.cmake import CMake, CMakeToolchain, CMakeDeps, cmake_layout -from conan.tools.env import VirtualRunEnv, VirtualBuildEnv -from conan.tools.files import rename, get, rmdir, save, copy, replace_in_file, rm -from conan.tools.microsoft import is_msvc_static_runtime +from conan.tools.env import VirtualBuildEnv +from conan.tools.files import get, copy, rm, export_conandata_patches, apply_conandata_patches +from conan.tools.microsoft import is_msvc_static_runtime, is_msvc, msvs_toolset from conan.tools.scm import Version required_conan_version = ">=1.55.0" @@ -40,12 +40,13 @@ def _compilers_minimum_version(self): return { "Visual Studio": "16", "msvc": "192", - "gcc": "5", - "clang": "6", + "gcc": "8", + "clang": "7", + "apple-clang": "10", } def export_sources(self): - copy(self, "conan_deps.cmake", self.recipe_folder, os.path.join(self.export_sources_folder, "src")) + export_conandata_patches(self) def config_options(self): if self.settings.os == "Windows": @@ -60,19 +61,16 @@ def layout(self): def requirements(self): # None of the dependencies are used transitively - self.requires("libmysqlclient/8.2.0") - self.requires("lz4/1.9.4") + self.requires("protobuf/3.21.12") # v4 and newer are not supported as of v9.0.0 self.requires("openssl/[>=1.1 <4]") - self.requires("rapidjson/cci.20230929") + self.requires("rapidjson/1.1.0") self.requires("zlib/[>=1.2.11 <2]") - self.requires("zstd/1.5.5") - self.requires("protobuf/3.21.12") + self.requires("lz4/1.9.4") + self.requires("zstd/[~1.5]") - def validate_build(self): + def validate(self): if self.settings.compiler.get_safe("cppstd"): check_min_cppstd(self, self._min_cppstd) - - def validate(self): minimum_version = self._compilers_minimum_version.get(str(self.settings.compiler), False) if minimum_version and Version(self.settings.compiler.version) < minimum_version: raise ConanInvalidConfiguration(f"{self.ref} requires {self.settings.compiler} {minimum_version} or newer") @@ -85,30 +83,28 @@ def source(self): def generate(self): VirtualBuildEnv(self).generate() - VirtualRunEnv(self).generate(scope="build") tc = CMakeToolchain(self) - tc.cache_variables["CMAKE_PROJECT_MySQL_CONCPP_INCLUDE"] = os.path.join(self.source_folder, "conan_deps.cmake") tc.cache_variables["BUNDLE_DEPENDENCIES"] = False tc.cache_variables["BUILD_STATIC"] = not self.options.shared tc.cache_variables["STATIC_MSVCRT"] = is_msvc_static_runtime(self) tc.cache_variables["WITH_TESTS"] = False - tc.cache_variables["WITH_SSL"] = "system" - tc.cache_variables["OPENSSL_ROOT_DIR"] = self.dependencies["openssl"].package_folder.replace("\\", "/") + tc.cache_variables["CMAKE_TRY_COMPILE_CONFIGURATION"] = str(self.settings.build_type) + tc.cache_variables["WITH_SSL"] = self.dependencies["openssl"].package_folder.replace("\\", "/") + tc.cache_variables["CMAKE_PREFIX_PATH"] = self.generators_folder.replace("\\", "/") tc.generate() deps = CMakeDeps(self) - deps.set_property("libmysqlclient", "cmake_file_name", "MySQL") - deps.set_property("libmysqlclient", "cmake_target_name", "MySQL::client") - deps.set_property("lz4", "cmake_target_name", "ext::lz4") deps.set_property("protobuf::libprotobuf", "cmake_target_name", "ext::protobuf") deps.set_property("protobuf::libprotobuf-lite", "cmake_target_name", "ext::protobuf-lite") deps.set_property("rapidjson", "cmake_target_name", "RapidJSON::rapidjson") deps.set_property("zlib", "cmake_target_name", "ext::z") + deps.set_property("lz4", "cmake_target_name", "ext::lz4") deps.set_property("zstd", "cmake_target_name", "ext::zstd") deps.generate() def build(self): + apply_conandata_patches(self) cmake = CMake(self) cmake.configure() cmake.build() @@ -117,15 +113,38 @@ def package(self): copy(self, "LICENSE.txt", self.source_folder, os.path.join(self.package_folder, "licenses")) cmake = CMake(self) cmake.install() - if self.package_path.joinpath("lib64").exists(): - rename(self, self.package_path.joinpath("lib64"), self.package_path.joinpath("lib")) - rm(self, "*.pdb", self.package_folder, recursive=True) + rm(self, "INFO_SRC", self.package_folder) + rm(self, "INFO_BIN", self.package_folder) + rm(self, "*.cmake", self.package_folder) + + @property + def _abi_version_major(self): + return 2 def package_info(self): - major_ver = Version(self.version).major - lib = f"mysqlcppconn{major_ver}" + self.cpp_info.set_property("cmake_file_name", "mysql-concpp") + self.cpp_info.set_property("cmake_target_name", "mysql::concpp") + + aliases = ["mysql::concpp-xdevapi"] + if not self.options.shared: + aliases.append("mysql::concpp-static") + aliases.append("mysql::concpp-xdevapi-static") + if self.settings.build_type == "Debug": + aliases.append("mysql::concpp-static-debug") + aliases.append("mysql::concpp-xdevapi-static-debug") + aliases.append("mysql::openssl") + self.cpp_info.set_property("cmake_target_aliases", aliases) + + lib = "mysqlcppconnx" if not self.options.shared: lib += "-static" + if is_msvc_static_runtime(self): + lib += "-mt" + elif self.settings.os == "Windows": + lib += f"-{self._abi_version_major}" + if is_msvc(self): + # e.g. v143 -> -vs14 + lib += f"-vs{msvs_toolset(self)[1:-1]}" self.cpp_info.libs = [lib] if self.settings.os == "Windows": @@ -136,3 +155,6 @@ def package_info(self): if self.settings.os == "SunOS": self.cpp_info.system_libs.append("socket") self.cpp_info.system_libs.append("nsl") + + if not self.options.shared: + self.cpp_info.defines = ["MYSQL_STATIC", "STATIC_CONCPP"] diff --git a/recipes/mysql-connector-cpp/all/patches/9.0.0/0001-override-cmake-policy-version.patch b/recipes/mysql-connector-cpp/all/patches/9.0.0/0001-override-cmake-policy-version.patch new file mode 100644 index 0000000000000..8007cf0e4bedb --- /dev/null +++ b/recipes/mysql-connector-cpp/all/patches/9.0.0/0001-override-cmake-policy-version.patch @@ -0,0 +1,45 @@ +From fdc950d95b215527fb1bd1790fb24b4c427bf807 Mon Sep 17 00:00:00 2001 +From: Martin Valgur +Date: Fri, 6 Sep 2024 17:56:39 +0300 +Subject: [PATCH 1/2] Set CMake policy version to 3.15, move project() + +--- + CMakeLists.txt | 8 ++++---- + 1 file changed, 4 insertions(+), 4 deletions(-) + +diff --git a/CMakeLists.txt b/CMakeLists.txt +index 341ed2de..4d747849 100644 +--- a/CMakeLists.txt ++++ b/CMakeLists.txt +@@ -27,10 +27,10 @@ + # 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA + + +-CMAKE_MINIMUM_REQUIRED(VERSION 3.8) ++CMAKE_MINIMUM_REQUIRED(VERSION 3.15) ++PROJECT(MySQL_CONCPP) ++ + +-CMAKE_POLICY(VERSION 3.1) +-cmake_policy(SET CMP0022 NEW) + + + SET(BUILDTYPE_DOCSTRING +@@ -73,7 +73,7 @@ endif() + + ########################################################################## + +-PROJECT(MySQL_CONCPP) ++ + + # Load cmake modules + +@@ -87,7 +87,7 @@ + # Detect if we are configured as stand-alone project, or sub-project. + # + +-if(PROJECT_NAME STREQUAL CMAKE_PROJECT_NAME) ++if(1) + + SET(concpp_stand_alone 1) + diff --git a/recipes/mysql-connector-cpp/all/patches/9.0.0/0002-rename-find_dependency.patch b/recipes/mysql-connector-cpp/all/patches/9.0.0/0002-rename-find_dependency.patch new file mode 100644 index 0000000000000..e9edb40215e2e --- /dev/null +++ b/recipes/mysql-connector-cpp/all/patches/9.0.0/0002-rename-find_dependency.patch @@ -0,0 +1,96 @@ +From 4d5a57343a8cb54a787b68c42a6b2379bbce2a84 Mon Sep 17 00:00:00 2001 +From: Martin Valgur +Date: Fri, 6 Sep 2024 19:04:24 +0300 +Subject: [PATCH 1/2] Rename find_dependency() to avoid with official version + +--- + CMakeLists.txt | 4 ++-- + cdk/CMakeLists.txt | 8 ++++---- + cdk/cmake/dependency.cmake | 6 +++--- + cdk/protocol/mysqlx/CMakeLists.txt | 4 ++-- + 4 files changed, 11 insertions(+), 11 deletions(-) + +diff --git a/CMakeLists.txt b/CMakeLists.txt +index 4d747849..65b043a5 100644 +--- a/CMakeLists.txt ++++ b/CMakeLists.txt +@@ -177,7 +177,7 @@ endif() + # Gcov support (Linux only) + # + +-find_dependency(Coverage) # defines add_coverage() command ++find_dep(Coverage) # defines add_coverage() command + #message("WITH_COVERAGE: ${WITH_COVERAGE}") + + +@@ -306,7 +306,7 @@ endif() + # Note: Find OpenSSL early because it is needed by both CDK and JDBC (in case + # of static linking with the client library) + +-find_dependency(SSL) ++find_dep(SSL) + + + # +diff --git a/cdk/CMakeLists.txt b/cdk/CMakeLists.txt +index dc8e3adc..4a9a164d 100644 +--- a/cdk/CMakeLists.txt ++++ b/cdk/CMakeLists.txt +@@ -93,10 +93,10 @@ add_config(CDK_BIG_ENDIAN ${BIG_ENDIAN}) + # Dependencies + # + +-find_dependency(SSL) +-#find_dependency(Protobuf) +-find_dependency(RapidJSON) +-find_dependency(Coverage) ++find_dep(SSL) ++#find_dep(Protobuf) ++find_dep(RapidJSON) ++find_dep(Coverage) + + + # TODO: These macros should not be used in public headers because they are +diff --git a/cdk/cmake/dependency.cmake b/cdk/cmake/dependency.cmake +index e3fec4ee..3c38ca5c 100644 +--- a/cdk/cmake/dependency.cmake ++++ b/cdk/cmake/dependency.cmake +@@ -33,20 +33,20 @@ include(config_options) + + ########################################################################## + # +-# find_dependency(XXX) command. ++# find_dep(XXX) command. + # + # Currently it is looking for DepFindXXX.cmake script that should perform + # all steps required to locate given dependency and make it available in + # the project. It is a layer on top of find_module(). + # + +-function(find_dependency NAME) ++macro(find_dep NAME) + + # TODO: Fallback to find_module() + + include(DepFind${NAME}) + +-endfunction(find_dependency) ++endmacro(find_dep) + + + # Variables to forward from this build configuration to external +diff --git a/cdk/protocol/mysqlx/CMakeLists.txt b/cdk/protocol/mysqlx/CMakeLists.txt +index a9873127..2ee4f937 100644 +--- a/cdk/protocol/mysqlx/CMakeLists.txt ++++ b/cdk/protocol/mysqlx/CMakeLists.txt +@@ -26,8 +26,8 @@ + # along with this program; if not, write to the Free Software Foundation, Inc., + # 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA + +-find_dependency(Protobuf) +-find_dependency(Compression) ++find_dep(Protobuf) ++find_dep(Compression) + + include(CheckIncludeFile) + diff --git a/recipes/mysql-connector-cpp/all/patches/9.0.0/0003-inject-conan-dependencies.patch b/recipes/mysql-connector-cpp/all/patches/9.0.0/0003-inject-conan-dependencies.patch new file mode 100644 index 0000000000000..e9c7da17bf6e7 --- /dev/null +++ b/recipes/mysql-connector-cpp/all/patches/9.0.0/0003-inject-conan-dependencies.patch @@ -0,0 +1,94 @@ +From cbcd5a641f10ed9a85bbccd93a0adf85939ea6c9 Mon Sep 17 00:00:00 2001 +From: Martin Valgur +Date: Fri, 6 Sep 2024 17:33:25 +0300 +Subject: [PATCH] Inject Conan dependencies + +--- + cdk/cmake/DepFindCompression.cmake | 5 +++++ + cdk/cmake/DepFindProtobuf.cmake | 18 ++++-------------- + cdk/cmake/DepFindRapidJSON.cmake | 3 +++ + cdk/core/CMakeLists.txt | 2 +- + 4 files changed, 13 insertions(+), 15 deletions(-) + +diff --git a/cdk/cmake/DepFindCompression.cmake b/cdk/cmake/DepFindCompression.cmake +index 68f8e106..775e0b53 100644 +--- a/cdk/cmake/DepFindCompression.cmake ++++ b/cdk/cmake/DepFindCompression.cmake +@@ -39,6 +39,11 @@ + # ext::zstd + # + ++find_package(ZLIB REQUIRED CONFIG) ++find_package(LZ4 REQUIRED CONFIG) ++find_package(Zstd REQUIRED CONFIG) ++return() ++ + if(TARGET ext::z) + return() + endif() +diff --git a/cdk/cmake/DepFindProtobuf.cmake b/cdk/cmake/DepFindProtobuf.cmake +index 1fc785e3..f371e29a 100644 +--- a/cdk/cmake/DepFindProtobuf.cmake ++++ b/cdk/cmake/DepFindProtobuf.cmake +@@ -50,22 +50,12 @@ endif() + + message(STATUS "Setting up Protobuf.") + +-# Setup extrnal project that builds protobuf from bundled sources +-add_ext(protobuf google/protobuf/api.pb.h) ++find_package(Protobuf REQUIRED CONFIG) + +-if(NOT PROTOBUF_FOUND) +- message(FATAL_ERROR "Can't build without protobuf support") ++if(NOT TARGET ext::protobuf-lite) ++ add_library(ext::protobuf-lite ALIAS ext::protobuf) + endif() + +-# import targets from the external project +-# Note: The pb_ targets are created by protobuf/exports.cmake +-add_ext_targets(protobuf +- LIBRARY protobuf-lite pb_libprotobuf-lite +- LIBRARY protobuf pb_libprotobuf +- EXECUTABLE protoc pb_protoc +-) +- +- + # Standard PROTOBUF_GENERATE_CPP modified to our usage + function(mysqlx_protobuf_generate_cpp SRCS HDRS) + IF(NOT ARGN) +@@ -90,7 +80,7 @@ function(mysqlx_protobuf_generate_cpp SRCS HDRS) + "${CMAKE_CURRENT_BINARY_DIR}/protobuf/${FIL_WE}.pb.h" + COMMAND ${CMAKE_COMMAND} + -E make_directory "${CMAKE_CURRENT_BINARY_DIR}/protobuf" +- COMMAND ext::protoc ++ COMMAND protobuf::protoc + ARGS --cpp_out "${CMAKE_CURRENT_BINARY_DIR}/protobuf" + -I ${ABS_PATH} ${ABS_FIL} + +diff --git a/cdk/cmake/DepFindRapidJSON.cmake b/cdk/cmake/DepFindRapidJSON.cmake +index 24f2c486..ed09e7bf 100644 +--- a/cdk/cmake/DepFindRapidJSON.cmake ++++ b/cdk/cmake/DepFindRapidJSON.cmake +@@ -36,6 +36,9 @@ if(TARGET RapidJSON::rapidjson) + return() + endif() + ++find_package(RapidJSON REQUIRED CONFIG) ++return() ++ + message(STATUS "Setting up RapidJSON.") + + # TODO: how to make it GLOBAL... +diff --git a/cdk/core/CMakeLists.txt b/cdk/core/CMakeLists.txt +index ba7ee3e0..c8242233 100644 +--- a/cdk/core/CMakeLists.txt ++++ b/cdk/core/CMakeLists.txt +@@ -42,7 +42,7 @@ SET(cdk_sources + file(GLOB HEADERS *.h) + + add_library(cdk STATIC ${cdk_sources} ${HEADERS}) +- ++find_dep(Protobuf) + target_link_libraries(cdk + PUBLIC cdk_mysqlx cdk_parser + PRIVATE ext::protobuf-lite # required by codecc.cc diff --git a/recipes/mysql-connector-cpp/all/patches/9.0.0/0004-add-target_include_directories.patch b/recipes/mysql-connector-cpp/all/patches/9.0.0/0004-add-target_include_directories.patch new file mode 100644 index 0000000000000..218370a1d19c9 --- /dev/null +++ b/recipes/mysql-connector-cpp/all/patches/9.0.0/0004-add-target_include_directories.patch @@ -0,0 +1,43 @@ +From e27ed801e587a6227464ec4638cad0333c9fa504 Mon Sep 17 00:00:00 2001 +From: Martin Valgur +Date: Fri, 6 Sep 2024 23:10:36 +0300 +Subject: [PATCH] Add target_include_directories for Conan v1 + +--- + cdk/foundation/CMakeLists.txt | 1 + + cdk/protocol/mysqlx/CMakeLists.txt | 7 +++++++ + 2 files changed, 8 insertions(+) + +diff --git a/cdk/foundation/CMakeLists.txt b/cdk/foundation/CMakeLists.txt +index 3cd3bfc4..4d1b1e77 100644 +--- a/cdk/foundation/CMakeLists.txt ++++ b/cdk/foundation/CMakeLists.txt +@@ -64,6 +64,7 @@ target_link_libraries(cdk_foundation + PUBLIC RapidJSON::rapidjson + PRIVATE OpenSSL::SSL + ) ++target_include_directories(cdk_foundation PUBLIC ${RapidJSON_INCLUDE_DIRS}) + + IF(WIN32) + target_link_libraries(cdk_foundation PRIVATE dnsapi) +diff --git a/cdk/protocol/mysqlx/CMakeLists.txt b/cdk/protocol/mysqlx/CMakeLists.txt +index 2ee4f937..aa5bc8bc 100644 +--- a/cdk/protocol/mysqlx/CMakeLists.txt ++++ b/cdk/protocol/mysqlx/CMakeLists.txt +@@ -139,6 +139,13 @@ target_link_libraries(cdk_proto_mysqlx + PRIVATE cdk_foundation ext::z ext::lz4 ext::zstd + ) + ++target_include_directories(cdk_proto_mysqlx PUBLIC ++ ${Protobuf_INCLUDE_DIRS} ${protobuf_INCLUDE_DIRS} ++ ${ZLIB_INCLUDE_DIRS} ${zlib_INCLUDE_DIRS} ++ ${LZ4_INCLUDE_DIRS} ${lz4_INCLUDE_DIRS} ++ ${ZStd_INCLUDE_DIRS} ${zstd_INCLUDE_DIRS} ++) ++ + ADD_COVERAGE(cdk_proto_mysqlx) + + source_group("Protobuf Definitions" FILES ${proto_mysqlx_defs}) +-- +2.45.2.windows.1 + diff --git a/recipes/mysql-connector-cpp/all/patches/9.0.0/0005-simplify-install-directories.patch b/recipes/mysql-connector-cpp/all/patches/9.0.0/0005-simplify-install-directories.patch new file mode 100644 index 0000000000000..08bfda6a175b9 --- /dev/null +++ b/recipes/mysql-connector-cpp/all/patches/9.0.0/0005-simplify-install-directories.patch @@ -0,0 +1,55 @@ +From 1ffe4bab11b9fce2db4d4d61e2f838912bc89a67 Mon Sep 17 00:00:00 2001 +From: Martin Valgur +Date: Fri, 6 Sep 2024 23:34:25 +0300 +Subject: [PATCH] Simplify install directories + +--- + CMakeLists.txt | 33 ++++----------------------------- + 1 file changed, 4 insertions(+), 29 deletions(-) + +diff --git a/CMakeLists.txt b/CMakeLists.txt +index 246bf3a6..548ac6aa 100644 +--- a/CMakeLists.txt ++++ b/CMakeLists.txt +@@ -535,38 +535,12 @@ set_target_properties(connector PROPERTIES + SOVERSION "${ABI_VERSION_MAJOR}" + ) + +- +-install(TARGETS connector +- CONFIGURATIONS Release RelWithDebInfo +- ARCHIVE DESTINATION "${INSTALL_LIB_DIR_STATIC}" COMPONENT XDevAPIDev +- RUNTIME DESTINATION "${INSTALL_LIB_DIR}" 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 ++ ARCHIVE DESTINATION lib ++ LIBRARY DESTINATION lib ++ RUNTIME DESTINATION bin + ) + +-if(MSVC AND NOT BUILD_STATIC) +- +- install(FILES $ +- CONFIGURATIONS RelWithDebInfo +- DESTINATION "${INSTALL_LIB_DIR}" +- COMPONENT Debuginfo +- ) +- +- install(FILES $ +- CONFIGURATIONS Debug +- DESTINATION "${INSTALL_LIB_DIR_DEBUG}" +- COMPONENT Debuginfo +- ) +- +-endif() +- +- + # + # Tests + # ===== diff --git a/recipes/mysql-connector-cpp/all/test_package/CMakeLists.txt b/recipes/mysql-connector-cpp/all/test_package/CMakeLists.txt index fefd7a2e00086..b46c3cde8da16 100644 --- a/recipes/mysql-connector-cpp/all/test_package/CMakeLists.txt +++ b/recipes/mysql-connector-cpp/all/test_package/CMakeLists.txt @@ -1,8 +1,8 @@ cmake_minimum_required(VERSION 3.15) project(test_package LANGUAGES CXX) -find_package(mysql-connector-cpp REQUIRED CONFIG) +find_package(mysql-concpp REQUIRED CONFIG) add_executable(${PROJECT_NAME} test_package.cpp) -target_link_libraries(${PROJECT_NAME} PRIVATE mysql-connector-cpp::mysql-connector-cpp) +target_link_libraries(${PROJECT_NAME} PRIVATE mysql::concpp) target_compile_features(${PROJECT_NAME} PRIVATE cxx_std_17) From ca62fac3eb824552f8366dc106b218cdd3660d2a Mon Sep 17 00:00:00 2001 From: Martin Valgur Date: Sat, 7 Sep 2024 00:37:19 +0300 Subject: [PATCH 04/16] mysql-connector-cpp: drop example.cpp --- .../mysql-connector-cpp/all/test_package/src/example.cpp | 7 ------- 1 file changed, 7 deletions(-) delete mode 100644 recipes/mysql-connector-cpp/all/test_package/src/example.cpp diff --git a/recipes/mysql-connector-cpp/all/test_package/src/example.cpp b/recipes/mysql-connector-cpp/all/test_package/src/example.cpp deleted file mode 100644 index 28ac0d69f3e4c..0000000000000 --- a/recipes/mysql-connector-cpp/all/test_package/src/example.cpp +++ /dev/null @@ -1,7 +0,0 @@ -#include - -int main() -{ - mysqlx::SessionSettings from_url("mysqlx://user:pwd@127.0.0.1:1234/db?ssl-mode=required"); - return 0; -} \ No newline at end of file From 3169bfe0f254628a2b09057f3471d27786e3a5be Mon Sep 17 00:00:00 2001 From: Martin Valgur Date: Sat, 7 Sep 2024 00:43:01 +0300 Subject: [PATCH 05/16] mysql-connector-cpp: fix shared build --- recipes/mysql-connector-cpp/all/conanfile.py | 15 ++++----------- 1 file changed, 4 insertions(+), 11 deletions(-) diff --git a/recipes/mysql-connector-cpp/all/conanfile.py b/recipes/mysql-connector-cpp/all/conanfile.py index a94c793894053..c538fc5d260bf 100644 --- a/recipes/mysql-connector-cpp/all/conanfile.py +++ b/recipes/mysql-connector-cpp/all/conanfile.py @@ -4,9 +4,9 @@ from conan.errors import ConanInvalidConfiguration from conan.tools.build import check_min_cppstd from conan.tools.cmake import CMake, CMakeToolchain, CMakeDeps, cmake_layout -from conan.tools.env import VirtualBuildEnv +from conan.tools.env import VirtualBuildEnv, VirtualRunEnv from conan.tools.files import get, copy, rm, export_conandata_patches, apply_conandata_patches -from conan.tools.microsoft import is_msvc_static_runtime, is_msvc, msvs_toolset +from conan.tools.microsoft import is_msvc_static_runtime from conan.tools.scm import Version required_conan_version = ">=1.55.0" @@ -83,6 +83,8 @@ def source(self): def generate(self): VirtualBuildEnv(self).generate() + if self.dependencies["protobuf"].options.shared: + VirtualRunEnv(self).generate(scope="build") tc = CMakeToolchain(self) tc.cache_variables["BUNDLE_DEPENDENCIES"] = False @@ -117,10 +119,6 @@ def package(self): rm(self, "INFO_BIN", self.package_folder) rm(self, "*.cmake", self.package_folder) - @property - def _abi_version_major(self): - return 2 - def package_info(self): self.cpp_info.set_property("cmake_file_name", "mysql-concpp") self.cpp_info.set_property("cmake_target_name", "mysql::concpp") @@ -140,11 +138,6 @@ def package_info(self): lib += "-static" if is_msvc_static_runtime(self): lib += "-mt" - elif self.settings.os == "Windows": - lib += f"-{self._abi_version_major}" - if is_msvc(self): - # e.g. v143 -> -vs14 - lib += f"-vs{msvs_toolset(self)[1:-1]}" self.cpp_info.libs = [lib] if self.settings.os == "Windows": From 959f42d61d5d68d3f4238366aefcbed91c27aaf6 Mon Sep 17 00:00:00 2001 From: Martin Valgur Date: Sat, 7 Sep 2024 01:04:17 +0300 Subject: [PATCH 06/16] mysql-connector-cpp: use GLOBAL on find_package() --- .../all/patches/9.0.0/0003-inject-conan-dependencies.patch | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/recipes/mysql-connector-cpp/all/patches/9.0.0/0003-inject-conan-dependencies.patch b/recipes/mysql-connector-cpp/all/patches/9.0.0/0003-inject-conan-dependencies.patch index e9c7da17bf6e7..2af196334a737 100644 --- a/recipes/mysql-connector-cpp/all/patches/9.0.0/0003-inject-conan-dependencies.patch +++ b/recipes/mysql-connector-cpp/all/patches/9.0.0/0003-inject-conan-dependencies.patch @@ -36,7 +36,7 @@ index 1fc785e3..f371e29a 100644 -# Setup extrnal project that builds protobuf from bundled sources -add_ext(protobuf google/protobuf/api.pb.h) -+find_package(Protobuf REQUIRED CONFIG) ++find_package(Protobuf REQUIRED CONFIG GLOBAL) -if(NOT PROTOBUF_FOUND) - message(FATAL_ERROR "Can't build without protobuf support") From b4a8ed3df2eafaee24efedc6dfab8793ac9b83fe Mon Sep 17 00:00:00 2001 From: Martin Valgur Date: Sat, 7 Sep 2024 07:21:27 +0300 Subject: [PATCH 07/16] mysql-connector-cpp: require CMake 3.24+ for GLOBAL --- recipes/mysql-connector-cpp/all/conanfile.py | 1 + 1 file changed, 1 insertion(+) diff --git a/recipes/mysql-connector-cpp/all/conanfile.py b/recipes/mysql-connector-cpp/all/conanfile.py index c538fc5d260bf..3487d08868001 100644 --- a/recipes/mysql-connector-cpp/all/conanfile.py +++ b/recipes/mysql-connector-cpp/all/conanfile.py @@ -76,6 +76,7 @@ def validate(self): raise ConanInvalidConfiguration(f"{self.ref} requires {self.settings.compiler} {minimum_version} or newer") def build_requirements(self): + self.tool_requires("cmake/[>=3.24 <4]") self.tool_requires("protobuf/") def source(self): From 11c40230746694c8c6f24f01cceb8c2d12a22a3d Mon Sep 17 00:00:00 2001 From: Martin Valgur Date: Sat, 7 Sep 2024 10:10:24 +0300 Subject: [PATCH 08/16] mysql-connector-cpp: workaound for macOS cross-compilation --- recipes/mysql-connector-cpp/all/conanfile.py | 15 ++++++++++++++- 1 file changed, 14 insertions(+), 1 deletion(-) diff --git a/recipes/mysql-connector-cpp/all/conanfile.py b/recipes/mysql-connector-cpp/all/conanfile.py index 3487d08868001..dfa3b10c8f297 100644 --- a/recipes/mysql-connector-cpp/all/conanfile.py +++ b/recipes/mysql-connector-cpp/all/conanfile.py @@ -2,10 +2,11 @@ from conan import ConanFile from conan.errors import ConanInvalidConfiguration +from conan.tools.apple import is_apple_os from conan.tools.build import check_min_cppstd from conan.tools.cmake import CMake, CMakeToolchain, CMakeDeps, cmake_layout from conan.tools.env import VirtualBuildEnv, VirtualRunEnv -from conan.tools.files import get, copy, rm, export_conandata_patches, apply_conandata_patches +from conan.tools.files import get, copy, rm, export_conandata_patches, apply_conandata_patches, save from conan.tools.microsoft import is_msvc_static_runtime from conan.tools.scm import Version @@ -95,6 +96,7 @@ def generate(self): tc.cache_variables["CMAKE_TRY_COMPILE_CONFIGURATION"] = str(self.settings.build_type) tc.cache_variables["WITH_SSL"] = self.dependencies["openssl"].package_folder.replace("\\", "/") tc.cache_variables["CMAKE_PREFIX_PATH"] = self.generators_folder.replace("\\", "/") + tc.cache_variables["IS64BIT"] = True tc.generate() deps = CMakeDeps(self) @@ -108,6 +110,11 @@ def generate(self): def build(self): apply_conandata_patches(self) + if is_apple_os(self): + # The CMAKE_OSX_ARCHITECTURES value set by Conan seems to be having no effect for some reason. + # This is a workaround for that. + save(self, os.path.join(self.source_folder, "cdk", "cmake", "platform.cmake"), + f"\nadd_compile_options(-arch {self.settings.arch})\n", append=True) cmake = CMake(self) cmake.configure() cmake.build() @@ -152,3 +159,9 @@ def package_info(self): if not self.options.shared: self.cpp_info.defines = ["MYSQL_STATIC", "STATIC_CONCPP"] + + + if is_apple_os(self) or self.settings.os in ["Linux", "FreeBSD"]: + self.cpp_info.system_libs.extend(["resolv"]) + if self.settings.os in ["Linux", "FreeBSD"]: + self.cpp_info.system_libs.extend(["m", "pthread"]) \ No newline at end of file From 70c612ac7baa0fa801d1635cb1e6020f9e1d9941 Mon Sep 17 00:00:00 2001 From: Martin Valgur Date: Sat, 7 Sep 2024 10:55:31 +0300 Subject: [PATCH 09/16] mysql-connector-cpp: another try at macOS cross-compilation --- recipes/mysql-connector-cpp/all/conanfile.py | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/recipes/mysql-connector-cpp/all/conanfile.py b/recipes/mysql-connector-cpp/all/conanfile.py index dfa3b10c8f297..e9877dcbb4b24 100644 --- a/recipes/mysql-connector-cpp/all/conanfile.py +++ b/recipes/mysql-connector-cpp/all/conanfile.py @@ -6,7 +6,7 @@ from conan.tools.build import check_min_cppstd from conan.tools.cmake import CMake, CMakeToolchain, CMakeDeps, cmake_layout from conan.tools.env import VirtualBuildEnv, VirtualRunEnv -from conan.tools.files import get, copy, rm, export_conandata_patches, apply_conandata_patches, save +from conan.tools.files import get, copy, rm, export_conandata_patches, apply_conandata_patches, replace_in_file from conan.tools.microsoft import is_msvc_static_runtime from conan.tools.scm import Version @@ -108,13 +108,17 @@ def generate(self): deps.set_property("zstd", "cmake_target_name", "ext::zstd") deps.generate() - def build(self): + def _patch_sources(self): apply_conandata_patches(self) if is_apple_os(self): # The CMAKE_OSX_ARCHITECTURES value set by Conan seems to be having no effect for some reason. # This is a workaround for that. - save(self, os.path.join(self.source_folder, "cdk", "cmake", "platform.cmake"), - f"\nadd_compile_options(-arch {self.settings.arch})\n", append=True) + replace_in_file(self, os.path.join(self.source_folder, "CMakeLists.txt"), + "PROJECT(MySQL_CONCPP)", + f"PROJECT(MySQL_CONCPP)\n\nadd_compile_options(-arch {self.settings.arch})\n") + + def build(self): + self._patch_sources() cmake = CMake(self) cmake.configure() cmake.build() From f59bd4a8a686598f06f98fd57c2c43223eb66ee1 Mon Sep 17 00:00:00 2001 From: Martin Valgur Date: Sun, 8 Sep 2024 21:25:46 +0300 Subject: [PATCH 10/16] mysql-connector-cpp: disable bootstrap() in CMakeLists.txt --- recipes/mysql-connector-cpp/all/conanfile.py | 12 +++++------- 1 file changed, 5 insertions(+), 7 deletions(-) diff --git a/recipes/mysql-connector-cpp/all/conanfile.py b/recipes/mysql-connector-cpp/all/conanfile.py index e9877dcbb4b24..49d18e8a2ab44 100644 --- a/recipes/mysql-connector-cpp/all/conanfile.py +++ b/recipes/mysql-connector-cpp/all/conanfile.py @@ -110,12 +110,10 @@ def generate(self): def _patch_sources(self): apply_conandata_patches(self) - if is_apple_os(self): - # The CMAKE_OSX_ARCHITECTURES value set by Conan seems to be having no effect for some reason. - # This is a workaround for that. - replace_in_file(self, os.path.join(self.source_folder, "CMakeLists.txt"), - "PROJECT(MySQL_CONCPP)", - f"PROJECT(MySQL_CONCPP)\n\nadd_compile_options(-arch {self.settings.arch})\n") + # Disable boostrap(), which is unnecessary and fragile with variables set by Conan + # https://github.com/mysql/mysql-connector-cpp/blob/9.0.0/CMakeLists.txt#L69-L71 + # https://github.com/mysql/mysql-connector-cpp/blob/9.0.0/cdk/cmake/bootstrap.cmake#L55 + replace_in_file(self, os.path.join(self.source_folder, "CMakeLists.txt"), "bootstrap()", "") def build(self): self._patch_sources() @@ -168,4 +166,4 @@ def package_info(self): if is_apple_os(self) or self.settings.os in ["Linux", "FreeBSD"]: self.cpp_info.system_libs.extend(["resolv"]) if self.settings.os in ["Linux", "FreeBSD"]: - self.cpp_info.system_libs.extend(["m", "pthread"]) \ No newline at end of file + self.cpp_info.system_libs.extend(["m", "pthread"]) From f8f313ec86baa55cca1940001e766eddbd1b5693 Mon Sep 17 00:00:00 2001 From: Martin Valgur Date: Sun, 8 Sep 2024 22:32:57 +0300 Subject: [PATCH 11/16] mysql-connector-cpp: replace fragile merge_libraries() with object libs --- recipes/mysql-connector-cpp/all/conandata.yml | 3 + ...ace-merge_libraries-with-object-libs.patch | 136 ++++++++++++++++++ 2 files changed, 139 insertions(+) create mode 100644 recipes/mysql-connector-cpp/all/patches/9.0.0/0006-replace-merge_libraries-with-object-libs.patch diff --git a/recipes/mysql-connector-cpp/all/conandata.yml b/recipes/mysql-connector-cpp/all/conandata.yml index 76bb1f03918af..ba697b0a1c517 100644 --- a/recipes/mysql-connector-cpp/all/conandata.yml +++ b/recipes/mysql-connector-cpp/all/conandata.yml @@ -19,3 +19,6 @@ patches: - patch_file: "patches/9.0.0/0005-simplify-install-directories.patch" patch_description: "Do not install libraries into subdirectories" patch_type: "conan" + - patch_file: "patches/9.0.0/0006-replace-merge_libraries-with-object-libs.patch" + patch_description: "Replace fragile merge_libraries() call with object libraries" + patch_type: "conan" diff --git a/recipes/mysql-connector-cpp/all/patches/9.0.0/0006-replace-merge_libraries-with-object-libs.patch b/recipes/mysql-connector-cpp/all/patches/9.0.0/0006-replace-merge_libraries-with-object-libs.patch new file mode 100644 index 0000000000000..fc13996f07e96 --- /dev/null +++ b/recipes/mysql-connector-cpp/all/patches/9.0.0/0006-replace-merge_libraries-with-object-libs.patch @@ -0,0 +1,136 @@ +From 5fccd58b35f4a4536d6aacc055bb4246f322f880 Mon Sep 17 00:00:00 2001 +From: Martin Valgur +Date: Sun, 8 Sep 2024 22:23:16 +0300 +Subject: [PATCH] Use OBJECT internal libs instead of fragile merge_libraries() + +merge_libraries() also merges all external static Conan dependencies into the library, which is unwanted in most cases. +This causes AppleClang builds to fail due to duplicate symbols in the final library, for instance. + +--- + CMakeLists.txt | 4 ++-- + cdk/core/CMakeLists.txt | 2 +- + cdk/foundation/CMakeLists.txt | 2 +- + cdk/mysqlx/CMakeLists.txt | 2 +- + cdk/parser/CMakeLists.txt | 2 +- + cdk/protocol/mysqlx/CMakeLists.txt | 2 +- + common/CMakeLists.txt | 2 +- + devapi/CMakeLists.txt | 2 +- + xapi/CMakeLists.txt | 2 +- + 9 files changed, 10 insertions(+), 10 deletions(-) + +diff --git a/CMakeLists.txt b/CMakeLists.txt +index 341ed2de..5a55caff 100644 +--- a/CMakeLists.txt ++++ b/CMakeLists.txt +@@ -409,8 +409,8 @@ add_subdirectory(devapi) + # + + # Generate the main connector library. +- +-merge_libraries(connector xapi devapi) ++add_library(connector cmake/libutils/empty.cc) ++target_link_libraries(connector PUBLIC cdk cdk_foundation cdk_mysqlx cdk_parser cdk_proto_mysqlx common devapi xapi) + add_version_info(connector + "MySQL Connector/C++ XDevAPI library." + "Implements MySQL Connector/C++ XDevAPI." +diff --git a/cdk/core/CMakeLists.txt b/cdk/core/CMakeLists.txt +index ba7ee3e0..25a48433 100644 +--- a/cdk/core/CMakeLists.txt ++++ b/cdk/core/CMakeLists.txt +@@ -41,4 +41,4 @@ SET(cdk_sources + + file(GLOB HEADERS *.h) + +-add_library(cdk STATIC ${cdk_sources} ${HEADERS}) ++add_library(cdk OBJECT ${cdk_sources} ${HEADERS}) +diff --git a/cdk/foundation/CMakeLists.txt b/cdk/foundation/CMakeLists.txt +index 3cd3bfc4..778516f4 100644 +--- a/cdk/foundation/CMakeLists.txt ++++ b/cdk/foundation/CMakeLists.txt +@@ -52,7 +52,7 @@ file(GLOB HEADERS *.h) + + #message("cdk foundation sources: ${sources}") + +-add_library(cdk_foundation STATIC ${sources} ${HEADERS}) ++add_library(cdk_foundation OBJECT ${sources} ${HEADERS}) + add_coverage(cdk_foundation) + + target_include_directories(cdk_foundation PUBLIC +diff --git a/cdk/mysqlx/CMakeLists.txt b/cdk/mysqlx/CMakeLists.txt +index aa358f03..af48bb11 100644 +--- a/cdk/mysqlx/CMakeLists.txt ++++ b/cdk/mysqlx/CMakeLists.txt +@@ -41,7 +41,7 @@ endif() + + file(GLOB HEADERS *.h) + +-ADD_LIBRARY(cdk_mysqlx STATIC ++ADD_LIBRARY(cdk_mysqlx OBJECT + session.cc + result.cc + auth_hash.cc +diff --git a/cdk/parser/CMakeLists.txt b/cdk/parser/CMakeLists.txt +index 5e1a4bd8..4e5e1b49 100644 +--- a/cdk/parser/CMakeLists.txt ++++ b/cdk/parser/CMakeLists.txt +@@ -31,7 +31,7 @@ ADD_SUBDIRECTORY(tests) + + file(GLOB HEADERS *.h) + +-add_library(cdk_parser STATIC ++add_library(cdk_parser OBJECT + tokenizer.cc + json_parser.cc + expr_parser.cc +diff --git a/cdk/protocol/mysqlx/CMakeLists.txt b/cdk/protocol/mysqlx/CMakeLists.txt +index a9873127..21f1a8a2 100644 +--- a/cdk/protocol/mysqlx/CMakeLists.txt ++++ b/cdk/protocol/mysqlx/CMakeLists.txt +@@ -116,7 +116,7 @@ mysqlx_protobuf_generate_cpp(PB_SRCS PB_HDRS ${proto_mysqlx_defs}) + + file(GLOB HEADERS *.h) + +-ADD_LIBRARY(cdk_proto_mysqlx STATIC ++ADD_LIBRARY(cdk_proto_mysqlx OBJECT + protocol.cc protocol_compression.cc session.cc rset.cc + stmt.cc crud.cc + ${PB_SRCS} +diff --git a/common/CMakeLists.txt b/common/CMakeLists.txt +index 587340e3..fec8ae01 100644 +--- a/common/CMakeLists.txt ++++ b/common/CMakeLists.txt +@@ -29,7 +29,7 @@ + + file(GLOB HEADERS *.h) + +-add_library(common STATIC ++add_library(common OBJECT + session.cc result.cc collection.cc value.cc + ${HEADERS} + ) +diff --git a/devapi/CMakeLists.txt b/devapi/CMakeLists.txt +index e6982d2e..32f60a7c 100644 +--- a/devapi/CMakeLists.txt ++++ b/devapi/CMakeLists.txt +@@ -32,7 +32,7 @@ + + file(GLOB HEADERS *.h) + +-add_library(devapi STATIC ++add_library(devapi OBJECT + session.cc + result.cc + document.cc +diff --git a/xapi/CMakeLists.txt b/xapi/CMakeLists.txt +index 25f3e579..e73bb334 100644 +--- a/xapi/CMakeLists.txt ++++ b/xapi/CMakeLists.txt +@@ -53,7 +53,7 @@ set(_libmysqlx_cc_src + + file(GLOB HEADERS *.h) + +-add_library(xapi STATIC ${_libmysqlx_cc_src} ${HEADERS}) ++add_library(xapi OBJECT ${_libmysqlx_cc_src} ${HEADERS}) + target_link_libraries(xapi PUBLIC common) + add_coverage(xapi) + From a236350ced229cba557d2afc88a17cb4fed564d9 Mon Sep 17 00:00:00 2001 From: Martin Valgur Date: Sun, 8 Sep 2024 22:46:41 +0300 Subject: [PATCH 12/16] mysql-connector-cpp: drop target_include_dirs patch No longer needed after removing bootstrap(). --- recipes/mysql-connector-cpp/all/conandata.yml | 3 -- .../0004-add-target_include_directories.patch | 43 ------------------- 2 files changed, 46 deletions(-) delete mode 100644 recipes/mysql-connector-cpp/all/patches/9.0.0/0004-add-target_include_directories.patch diff --git a/recipes/mysql-connector-cpp/all/conandata.yml b/recipes/mysql-connector-cpp/all/conandata.yml index ba697b0a1c517..86a0f4bada82e 100644 --- a/recipes/mysql-connector-cpp/all/conandata.yml +++ b/recipes/mysql-connector-cpp/all/conandata.yml @@ -13,9 +13,6 @@ patches: - patch_file: "patches/9.0.0/0003-inject-conan-dependencies.patch" patch_description: "Inject Conan dependencies" patch_type: "conan" - - patch_file: "patches/9.0.0/0004-add-target_include_directories.patch" - patch_description: "Add target_include_directories() for compatibility with Conan v1" - patch_type: "conan" - patch_file: "patches/9.0.0/0005-simplify-install-directories.patch" patch_description: "Do not install libraries into subdirectories" patch_type: "conan" diff --git a/recipes/mysql-connector-cpp/all/patches/9.0.0/0004-add-target_include_directories.patch b/recipes/mysql-connector-cpp/all/patches/9.0.0/0004-add-target_include_directories.patch deleted file mode 100644 index 218370a1d19c9..0000000000000 --- a/recipes/mysql-connector-cpp/all/patches/9.0.0/0004-add-target_include_directories.patch +++ /dev/null @@ -1,43 +0,0 @@ -From e27ed801e587a6227464ec4638cad0333c9fa504 Mon Sep 17 00:00:00 2001 -From: Martin Valgur -Date: Fri, 6 Sep 2024 23:10:36 +0300 -Subject: [PATCH] Add target_include_directories for Conan v1 - ---- - cdk/foundation/CMakeLists.txt | 1 + - cdk/protocol/mysqlx/CMakeLists.txt | 7 +++++++ - 2 files changed, 8 insertions(+) - -diff --git a/cdk/foundation/CMakeLists.txt b/cdk/foundation/CMakeLists.txt -index 3cd3bfc4..4d1b1e77 100644 ---- a/cdk/foundation/CMakeLists.txt -+++ b/cdk/foundation/CMakeLists.txt -@@ -64,6 +64,7 @@ target_link_libraries(cdk_foundation - PUBLIC RapidJSON::rapidjson - PRIVATE OpenSSL::SSL - ) -+target_include_directories(cdk_foundation PUBLIC ${RapidJSON_INCLUDE_DIRS}) - - IF(WIN32) - target_link_libraries(cdk_foundation PRIVATE dnsapi) -diff --git a/cdk/protocol/mysqlx/CMakeLists.txt b/cdk/protocol/mysqlx/CMakeLists.txt -index 2ee4f937..aa5bc8bc 100644 ---- a/cdk/protocol/mysqlx/CMakeLists.txt -+++ b/cdk/protocol/mysqlx/CMakeLists.txt -@@ -139,6 +139,13 @@ target_link_libraries(cdk_proto_mysqlx - PRIVATE cdk_foundation ext::z ext::lz4 ext::zstd - ) - -+target_include_directories(cdk_proto_mysqlx PUBLIC -+ ${Protobuf_INCLUDE_DIRS} ${protobuf_INCLUDE_DIRS} -+ ${ZLIB_INCLUDE_DIRS} ${zlib_INCLUDE_DIRS} -+ ${LZ4_INCLUDE_DIRS} ${lz4_INCLUDE_DIRS} -+ ${ZStd_INCLUDE_DIRS} ${zstd_INCLUDE_DIRS} -+) -+ - ADD_COVERAGE(cdk_proto_mysqlx) - - source_group("Protobuf Definitions" FILES ${proto_mysqlx_defs}) --- -2.45.2.windows.1 - From 2f459ec26ba62ce689617c90147d88b98b6cfc09 Mon Sep 17 00:00:00 2001 From: Martin Valgur Date: Mon, 9 Sep 2024 12:32:04 +0300 Subject: [PATCH 13/16] mysql-connector-cpp: apply review suggestions Co-authored-by: PerseoGI --- recipes/mysql-connector-cpp/all/conanfile.py | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/recipes/mysql-connector-cpp/all/conanfile.py b/recipes/mysql-connector-cpp/all/conanfile.py index 49d18e8a2ab44..9e40cb3634f6e 100644 --- a/recipes/mysql-connector-cpp/all/conanfile.py +++ b/recipes/mysql-connector-cpp/all/conanfile.py @@ -151,13 +151,11 @@ def package_info(self): self.cpp_info.libs = [lib] if self.settings.os == "Windows": - self.cpp_info.system_libs.append("dnsapi") - self.cpp_info.system_libs.append("ws2_32") + self.cpp_info.system_libs.extend(["dnsapi", "ws2_32"]) elif self.settings.os != "FreeBSD": self.cpp_info.system_libs.append("resolv") if self.settings.os == "SunOS": - self.cpp_info.system_libs.append("socket") - self.cpp_info.system_libs.append("nsl") + self.cpp_info.system_libs.append(["socket", "nsl"]) if not self.options.shared: self.cpp_info.defines = ["MYSQL_STATIC", "STATIC_CONCPP"] From ed0bb9dec6b204c7bc1117e4e9f80b0d490225a9 Mon Sep 17 00:00:00 2001 From: Martin Valgur Date: Mon, 9 Sep 2024 15:45:40 +0300 Subject: [PATCH 14/16] mysql-connector-cpp: drop override-cmake-policy-version.patch --- recipes/mysql-connector-cpp/all/conandata.yml | 3 -- recipes/mysql-connector-cpp/all/conanfile.py | 1 + .../0001-override-cmake-policy-version.patch | 45 ------------------- 3 files changed, 1 insertion(+), 48 deletions(-) delete mode 100644 recipes/mysql-connector-cpp/all/patches/9.0.0/0001-override-cmake-policy-version.patch diff --git a/recipes/mysql-connector-cpp/all/conandata.yml b/recipes/mysql-connector-cpp/all/conandata.yml index 86a0f4bada82e..50c8359338456 100644 --- a/recipes/mysql-connector-cpp/all/conandata.yml +++ b/recipes/mysql-connector-cpp/all/conandata.yml @@ -4,9 +4,6 @@ sources: sha256: "9d4b90a4efe8861e821136fb3024074d14875749d8b69d1821361b2f2b8bfe55" patches: "9.0.0": - - patch_file: "patches/9.0.0/0001-override-cmake-policy-version.patch" - patch_description: "Set CMake policy version to 3.15, move project() statement" - patch_type: "conan" - patch_file: "patches/9.0.0/0002-rename-find_dependency.patch" patch_description: "Rename find_dependency() to avoid conflicts with the official CMake function" patch_type: "conan" diff --git a/recipes/mysql-connector-cpp/all/conanfile.py b/recipes/mysql-connector-cpp/all/conanfile.py index 9e40cb3634f6e..f395a4d708277 100644 --- a/recipes/mysql-connector-cpp/all/conanfile.py +++ b/recipes/mysql-connector-cpp/all/conanfile.py @@ -97,6 +97,7 @@ def generate(self): tc.cache_variables["WITH_SSL"] = self.dependencies["openssl"].package_folder.replace("\\", "/") tc.cache_variables["CMAKE_PREFIX_PATH"] = self.generators_folder.replace("\\", "/") tc.cache_variables["IS64BIT"] = True + tc.cache_variables["CMAKE_POLICY_DEFAULT_CMP0077"] = "NEW" tc.generate() deps = CMakeDeps(self) diff --git a/recipes/mysql-connector-cpp/all/patches/9.0.0/0001-override-cmake-policy-version.patch b/recipes/mysql-connector-cpp/all/patches/9.0.0/0001-override-cmake-policy-version.patch deleted file mode 100644 index 8007cf0e4bedb..0000000000000 --- a/recipes/mysql-connector-cpp/all/patches/9.0.0/0001-override-cmake-policy-version.patch +++ /dev/null @@ -1,45 +0,0 @@ -From fdc950d95b215527fb1bd1790fb24b4c427bf807 Mon Sep 17 00:00:00 2001 -From: Martin Valgur -Date: Fri, 6 Sep 2024 17:56:39 +0300 -Subject: [PATCH 1/2] Set CMake policy version to 3.15, move project() - ---- - CMakeLists.txt | 8 ++++---- - 1 file changed, 4 insertions(+), 4 deletions(-) - -diff --git a/CMakeLists.txt b/CMakeLists.txt -index 341ed2de..4d747849 100644 ---- a/CMakeLists.txt -+++ b/CMakeLists.txt -@@ -27,10 +27,10 @@ - # 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA - - --CMAKE_MINIMUM_REQUIRED(VERSION 3.8) -+CMAKE_MINIMUM_REQUIRED(VERSION 3.15) -+PROJECT(MySQL_CONCPP) -+ - --CMAKE_POLICY(VERSION 3.1) --cmake_policy(SET CMP0022 NEW) - - - SET(BUILDTYPE_DOCSTRING -@@ -73,7 +73,7 @@ endif() - - ########################################################################## - --PROJECT(MySQL_CONCPP) -+ - - # Load cmake modules - -@@ -87,7 +87,7 @@ - # Detect if we are configured as stand-alone project, or sub-project. - # - --if(PROJECT_NAME STREQUAL CMAKE_PROJECT_NAME) -+if(1) - - SET(concpp_stand_alone 1) - From 3b0ea6beeb8a0957e2eefca6257d35fd1678ce65 Mon Sep 17 00:00:00 2001 From: Martin Valgur Date: Mon, 9 Sep 2024 15:46:45 +0300 Subject: [PATCH 15/16] mysql-connector-cpp: add dl to system_libs --- recipes/mysql-connector-cpp/all/conanfile.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/recipes/mysql-connector-cpp/all/conanfile.py b/recipes/mysql-connector-cpp/all/conanfile.py index f395a4d708277..8892e72dc2cc4 100644 --- a/recipes/mysql-connector-cpp/all/conanfile.py +++ b/recipes/mysql-connector-cpp/all/conanfile.py @@ -165,4 +165,4 @@ def package_info(self): if is_apple_os(self) or self.settings.os in ["Linux", "FreeBSD"]: self.cpp_info.system_libs.extend(["resolv"]) if self.settings.os in ["Linux", "FreeBSD"]: - self.cpp_info.system_libs.extend(["m", "pthread"]) + self.cpp_info.system_libs.extend(["m", "pthread", "dl"]) From d1e517b5cb7ee06d70890f3d5ccda750fd9c760b Mon Sep 17 00:00:00 2001 From: Martin Valgur Date: Mon, 9 Sep 2024 15:48:27 +0300 Subject: [PATCH 16/16] mysql-connector-cpp: tidy system_libs --- recipes/mysql-connector-cpp/all/conanfile.py | 13 ++++--------- 1 file changed, 4 insertions(+), 9 deletions(-) diff --git a/recipes/mysql-connector-cpp/all/conanfile.py b/recipes/mysql-connector-cpp/all/conanfile.py index 8892e72dc2cc4..6107b36d8f47a 100644 --- a/recipes/mysql-connector-cpp/all/conanfile.py +++ b/recipes/mysql-connector-cpp/all/conanfile.py @@ -2,7 +2,6 @@ from conan import ConanFile from conan.errors import ConanInvalidConfiguration -from conan.tools.apple import is_apple_os from conan.tools.build import check_min_cppstd from conan.tools.cmake import CMake, CMakeToolchain, CMakeDeps, cmake_layout from conan.tools.env import VirtualBuildEnv, VirtualRunEnv @@ -153,16 +152,12 @@ def package_info(self): if self.settings.os == "Windows": self.cpp_info.system_libs.extend(["dnsapi", "ws2_32"]) - elif self.settings.os != "FreeBSD": - self.cpp_info.system_libs.append("resolv") + if self.settings.os in ["Linux", "FreeBSD"]: + self.cpp_info.system_libs.extend(["m", "pthread", "dl"]) if self.settings.os == "SunOS": self.cpp_info.system_libs.append(["socket", "nsl"]) + if self.settings.os not in ["Windows", "FreeBSD"]: + self.cpp_info.system_libs.append("resolv") if not self.options.shared: self.cpp_info.defines = ["MYSQL_STATIC", "STATIC_CONCPP"] - - - if is_apple_os(self) or self.settings.os in ["Linux", "FreeBSD"]: - self.cpp_info.system_libs.extend(["resolv"]) - if self.settings.os in ["Linux", "FreeBSD"]: - self.cpp_info.system_libs.extend(["m", "pthread", "dl"])