Skip to content

[drogon] Fix MySQL finding#22378

Closed
kotori2 wants to merge 2 commits intomicrosoft:masterfrom
kotori2:drogon-fix
Closed

[drogon] Fix MySQL finding#22378
kotori2 wants to merge 2 commits intomicrosoft:masterfrom
kotori2:drogon-fix

Conversation

@kotori2
Copy link
Copy Markdown
Contributor

@kotori2 kotori2 commented Jan 5, 2022

Describe the pull request
#21359 changed paths for libmariadb, which makes drogon fails to find them

If you are still working on the PR, open it as a Draft: https://github.blog/2019-02-14-introducing-draft-pull-requests/

Copy link
Copy Markdown

@github-actions github-actions bot left a comment

Choose a reason for hiding this comment

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

This is a new experimental fast check for PR issues. Please let us know if this bot is helpful!

PRs must add only one version and must not modify any published versions

When making any changes to a library, the version or port-version in vcpkg.json or CONTROL must be modified.

Error: Local changes detected for drogon but no changes to version or port version.
-- Version: 1.7.4
-- Old SHA: 275d55a78bb61a79f0d66cd4f71e6b5892566666
-- New SHA: d7a1f5f19430546a7029c491986f87f9dcd954be
-- Did you remember to update the version or port version?
-- Pass `--overwrite-version` to bypass this check.
***No files were updated.***
After committing all other changes, the version database must be updated
git add -u && git commit
git checkout b934807c799fd84c2e1e168b8d3472d4904a6f90 -- versions
./vcpkg x-add-version --all
Diff
diff --git a/versions/d-/drogon.json b/versions/d-/drogon.json
index 566ebb7..d929cf6 100644
--- a/versions/d-/drogon.json
+++ b/versions/d-/drogon.json
@@ -1,10 +1,5 @@
 {
   "versions": [
-    {
-      "git-tree": "d7a1f5f19430546a7029c491986f87f9dcd954be",
-      "version-semver": "1.7.4",
-      "port-version": 1
-    },
     {
       "git-tree": "275d55a78bb61a79f0d66cd4f71e6b5892566666",
       "version-semver": "1.7.4",

@kotori2 kotori2 force-pushed the drogon-fix branch 2 times, most recently from 1821015 to 6f94d62 Compare January 5, 2022 13:09
Copy link
Copy Markdown

@github-actions github-actions bot left a comment

Choose a reason for hiding this comment

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

This is a new experimental fast check for PR issues. Please let us know if this bot is helpful!

After committing all other changes, the version database must be updated
git add -u && git commit
git checkout b934807c799fd84c2e1e168b8d3472d4904a6f90 -- versions
./vcpkg x-add-version --all
Diff
diff --git a/versions/d-/drogon.json b/versions/d-/drogon.json
index 0f2a526..c38c515 100644
--- a/versions/d-/drogon.json
+++ b/versions/d-/drogon.json
@@ -1,7 +1,7 @@
 {
   "versions": [
     {
-      "git-tree": "554d8b686b5422c8e2489f4877f638c02acb0d5f",
+      "git-tree": "d9488b60c0805941903425f6dfac74195d4cb6fb",
       "version-semver": "1.7.4",
       "port-version": 1
     },

@JackBoosY JackBoosY added the category:port-bug The issue is with a library, which is something the port should already support label Jan 5, 2022
@JackBoosY JackBoosY self-assigned this Jan 5, 2022
@JackBoosY JackBoosY requested a review from FrankXie05 January 5, 2022 16:49
@FrankXie05 FrankXie05 added the info:needs-maintainer-attention Lets the current 'on rotation' vcpkg maintainer know they need to look at this. label Jan 7, 2022
@strega-nil-ms
Copy link
Copy Markdown
Contributor

I really don't like this; I'd much prefer if we fixed libmariadb to support find_package(MySql). Marking requires:discussion so we can talk about it at the thursday meeting.

@strega-nil-ms strega-nil-ms added requires:discussion and removed info:needs-maintainer-attention Lets the current 'on rotation' vcpkg maintainer know they need to look at this. labels Jan 7, 2022
- find_package(MySQL)
- if (MySQL_FOUND)
+ find_package(unofficial-libmariadb CONFIG REQUIRED)
+ if (unofficial-libmariadb_FOUND)
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

A minimal patch would just take

     # Find mysql, only mariadb client liberary is supported
-    find_package(MySQL)
+    find_package(unofficial-libmariadb CONFIG REQUIRED)
+    set(MySQL_FOUND TRUE)
+    set(MySQL_lib unofficial::libmariadb)
     if (MySQL_FOUND)

The REQUIRED implies that the build stops if unofficial-libmariadb isn't found.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

A minimal patch would just take

     # Find mysql, only mariadb client liberary is supported
-    find_package(MySQL)
+    find_package(unofficial-libmariadb CONFIG REQUIRED)
+    set(MySQL_FOUND TRUE)
+    set(MySQL_lib unofficial::libmariadb)
     if (MySQL_FOUND)

The REQUIRED implies that the build stops if unofficial-libmariadb isn't found.

I've tried set(MySQL_FOUND TRUE) before, but it will throw an error when you are syncing your own project since MySQL can't be found. Does set(MySQL_lib unofficial::libmariadb) solve this issue?

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

I've tried set(MySQL_FOUND TRUE) before, but it will throw an error when you are syncing your own project since MySQL can't be found.

I see.

Does set(MySQL_lib unofficial::libmariadb) solve this issue?

I cannot answer that without know the error message. "syncing your own project " isn't clear.
But it seems either your project shouldn't directly depend on MySQL_FOUND when MySQL actually isn't used, or it is implicitly relying on drogon's FindMySQL.cmake, and then you need to patch that script instead.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

"syncing your own project " isn't clear.

Actually I mean generating Makefile from CMake after all vcpkg packages installed.

I cannot answer that without know the error message.

CMake will generate DrogonConfig.cmake in vcpkg_installed/[triplet]/share/drogon. It will call find_dependency(MySQL), which will fail since mariadb changed its name.

Also when trying your patch, I got build error.

FAILED: CMakeFiles/drogon.dir/orm_lib/src/mysql_impl/MysqlConnection.cc.o 
/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/c++ -DUSE_BROTLI -DUSE_OSSP_UUID=0 -I/Users/kotori0/vcpkg/buildtrees/drogon/src/v1.7.4-3e6a1930a1.clean/lib/inc -I/Users/kotori0/vcpkg/buildtrees/drogon/src/v1.7.4-3e6a1930a1.clean/orm_lib/inc -I/Users/kotori0/vcpkg/buildtrees/drogon/src/v1.7.4-3e6a1930a1.clean/nosql_lib/redis/inc -I/Users/kotori0/vcpkg/buildtrees/drogon/x64-osx-dbg -I/Users/kotori0/vcpkg/buildtrees/drogon/src/v1.7.4-3e6a1930a1.clean/trantor -I/Users/kotori0/vcpkg/buildtrees/drogon/x64-osx-dbg/exports -isystem /Users/kotori0/Downloads/test/cmake-build-debug/vcpkg_installed/x64-osx/include -isystem /Users/kotori0/Downloads/test/cmake-build-debug/vcpkg_installed/x64-osx/include/uuid -isystem /Library/Frameworks/Mono.framework/Headers -fPIC -g -arch x86_64 -isysroot /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX12.1.sdk -std=c++17 -MD -MT CMakeFiles/drogon.dir/orm_lib/src/mysql_impl/MysqlConnection.cc.o -MF CMakeFiles/drogon.dir/orm_lib/src/mysql_impl/MysqlConnection.cc.o.d -o CMakeFiles/drogon.dir/orm_lib/src/mysql_impl/MysqlConnection.cc.o -c /Users/kotori0/vcpkg/buildtrees/drogon/src/v1.7.4-3e6a1930a1.clean/orm_lib/src/mysql_impl/MysqlConnection.cc
In file included from /Users/kotori0/vcpkg/buildtrees/drogon/src/v1.7.4-3e6a1930a1.clean/orm_lib/src/mysql_impl/MysqlConnection.cc:15:
/Users/kotori0/vcpkg/buildtrees/drogon/src/v1.7.4-3e6a1930a1.clean/orm_lib/src/mysql_impl/MysqlConnection.h:25:10: fatal error: 'mysql.h' file not found
#include <mysql.h>
         ^~~~~~~~~
1 error generated.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

MySQL_lib is a target, so my proposed set(MySQL_lib ...) can't help - sorry for the confusion. Your change to the target_link_libraries is already the right thing at this point.

Variable or not, when linking unofficial::libmariadb while building, the exported config will link to unofficial::libmariadb, too. So you need to replace the find_dependency(MySQL) with find_dependency(unofficial-libmariadb).

(@strega-nil-ms proposed to only patch FindMySQL.cmake. It is possible to handle the redirection entirely in that module, but it might be even more confusing when something goes wrong.)

I wanted to attach a test patch now, but I just run into another build issue with drogon. Either you try yourself again, or you wait a moment.

@dg0yt
Copy link
Copy Markdown
Contributor

dg0yt commented Jan 8, 2022

I really don't like this; I'd much prefer if we fixed libmariadb to support find_package(MySql). Marking requires:discussion so we can talk about it at the thursday meeting.

Note that FindMySQL.cmake is part of drogon. It takes a patch anyway.

@dg0yt
Copy link
Copy Markdown
Contributor

dg0yt commented Jan 11, 2022

This PR is obsolete now with #22426 merged. But many thanks for the initial work and discussion @kotori2.

@JackBoosY
Copy link
Copy Markdown
Contributor

Can you please resolve the file conflict?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

category:port-bug The issue is with a library, which is something the port should already support

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants