Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

mysql-connector-cpp: new recipe #25170

Open
wants to merge 17 commits into
base: master
Choose a base branch
from

Conversation

valgur
Copy link
Contributor

@valgur valgur commented Sep 6, 2024

Summary

Changes to recipe: mysql-connector-cpp/9.0.0

Motivation

MySQL Connector/C++ is a MySQL database connector for C++. It lets you develop C++ and C applications that connect to MySQL Server.

https://github.com/mysql/mysql-connector-cpp

Packaging status

Details

The project is not doing anything particularly too complex or special in its CMake files overall, but chooses to do some things in quite convoluted and non-standard ways:

  • boostrap(), which is done by default before project() call. This breaks many Conan variables and targets and does not appear to really be necessary (it's disabled for Ninja, for example).
  • merge_libraries(). This assumes that all external deps have been built as shared. Static external deps get merged into the final archive file, which leads to "duplicate symbol" linker errors on some compilers, such as apple-clang. I replaced it with the much simpler and more common approach of using OBJECT-type libs for the internal libraries.

Based on

Closes


valgur and others added 6 commits December 26, 2023 19:44
…-cpp' into new/mysql-connector-cpp-2

# Conflicts:
#	recipes/mysql-connector-cpp/all/conandata.yml
#	recipes/mysql-connector-cpp/all/conanfile.py
#	recipes/mysql-connector-cpp/all/test_package/CMakeLists.txt
#	recipes/mysql-connector-cpp/all/test_package/conanfile.py
#	recipes/mysql-connector-cpp/config.yml
@conan-center-bot

This comment has been minimized.

@conan-center-bot

This comment has been minimized.

@conan-center-bot

This comment has been minimized.

@conan-center-bot

This comment has been minimized.

@conan-center-bot

This comment has been minimized.

@conan-center-bot

This comment has been minimized.

@valgur valgur force-pushed the new/mysql-connector-cpp-2 branch from 1723b98 to f53cac3 Compare September 8, 2024 18:26
@valgur valgur force-pushed the new/mysql-connector-cpp-2 branch from f53cac3 to f59bd4a Compare September 8, 2024 18:28
@conan-center-bot

This comment has been minimized.

@conan-center-bot

This comment has been minimized.

@valgur valgur marked this pull request as ready for review September 9, 2024 05:59
@valgur valgur mentioned this pull request Sep 9, 2024
3 tasks
Copy link
Contributor

@perseoGI perseoGI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looking good

@perseoGI perseoGI self-assigned this Sep 9, 2024
@conan-center-bot

This comment has been minimized.

Copy link
Member

@uilianries uilianries left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you for your PR! This project is one that we tried to package many time, but now, with this PR, we are much closer to achieve it.

I have some concerns about those patches, they are related to the upstream directly, and I don't find any other package manager doing the same. I would suggest opening issues to the upstream reporting about find_dependency and merge_library, otherwise, we will need to keep updating the same patch always.

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"])
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
self.cpp_info.system_libs.extend(["m", "pthread"])
self.cpp_info.system_libs.extend(["m", "pthread", "dl"])

https://github.com/mysql/mysql-connector-cpp/blob/9.0.0/mysql-concpp-config.cmake.in#L463

Comment on lines 7 to 9
- 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"
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
- 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"

I really don't see an error when not using this patch. I would avoid if possible.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah, looks like the issues were caused by bootstrap() rather than the policy version or project() call location.

- 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"
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I would prefer having an issue pointed in the upstream about this. I understand the risk of name collision, but keeping it only here is not good as well.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It's not just a potential risk. The CMake configuration step consistently failed for me due to find_package() calls importing CMakeFindDependencyMacro.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I could not find any other package manager (ubuntu, aur, gentoo and conda) using similar approach. I understand the risk of having duplicated symbols and causing a mess, but this case should be reported to the upstream as well.

Copy link
Contributor Author

@valgur valgur Sep 9, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Don't be overly reliant on the system-wide package managers as a reference. The issue precisely stems from the upstream project assuming that all of the external libraries are system-wide shared libraries rather than static libs.

It's not just a risk either. The apple-clang compiler refuses to link test_package due to duplicate symbols from OpenSSL and the mysql-connector-cpp lib when OpenSSL is built as static, for example.

I'm not going to reach out to upstream regarding these issues at this time, sorry.

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Concerning duplicate symbols and OpenSSL, do you think it's worth trying my approach in the latest commits? In short, remove the OpenSSL dependency from mysqlx and only link it in the foundation target.

In their 'docs' they do explain that an external openssl lib can be included via a new common target.

@valgur valgur force-pushed the new/mysql-connector-cpp-2 branch from 4d3c98c to d1e517b Compare September 9, 2024 12:48
@conan-center-bot
Copy link
Collaborator

Conan v1 pipeline ✔️

All green in build 14 (d1e517b5cb7ee06d70890f3d5ccda750fd9c760b):

  • mysql-connector-cpp/9.0.0:
    All packages built successfully! (All logs)

Conan v2 pipeline ✔️

Note: Conan v2 builds are now mandatory. Please read our discussion about it.

All green in build 14 (d1e517b5cb7ee06d70890f3d5ccda750fd9c760b):

  • mysql-connector-cpp/9.0.0:
    All packages built successfully! (All logs)

@husitawi
Copy link

husitawi commented Sep 10, 2024

Despite that hot mess of CMAKE abstraction files and function, you actually did it, nice finds and well done! 🎉

@perseoGI
Copy link
Contributor

@husitawi yes! These are good news!
Lets continue in this one now that is actually passing the CI and try to merge ASAP.

@AbrilRBS AbrilRBS self-assigned this Sep 12, 2024
@perseoGI
Copy link
Contributor

Would you mind @valgur to add @samuaz with_jdbc option to your recipe?

@valgur
Copy link
Contributor Author

valgur commented Nov 21, 2024

Would you mind @valgur to add @samuaz with_jdbc option to your recipe?

Sure, gladly, but not right now. Maybe after a couple of weeks.

@AbrilRBS AbrilRBS removed their assignment Dec 3, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[request] mysql_connector_cpp/8.0.32 [request] mysql-connector-cpp/8.0
6 participants