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

fix(cmake): Add Homebrew path detection for mariadb-connector-c to fix macOS build failure. #582

Merged
merged 5 commits into from
Nov 10, 2024
Merged
Changes from 3 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 19 additions & 0 deletions components/core/cmake/Modules/FindMariaDBClient.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,25 @@ include(cmake/Modules/FindLibraryDependencies.cmake)
find_package(PkgConfig)
pkg_check_modules(mariadbclient_PKGCONF QUIET "lib${mariadbclient_LIBNAME}")

if(NOT mariadbclient_PKGCONF_FOUND AND APPLE)
execute_process(
COMMAND brew --prefix mariadb-connector-c
RESULT_VARIABLE brew_result
LinZhihao-723 marked this conversation as resolved.
Show resolved Hide resolved
OUTPUT_VARIABLE mariadbclient_MACOS_PREFIX
ERROR_QUIET
LinZhihao-723 marked this conversation as resolved.
Show resolved Hide resolved
)
if(NOT brew_result EQUAL 0)
message(FATAL_ERROR "mariadb-connector-c not found in Homebrew")
LinZhihao-723 marked this conversation as resolved.
Show resolved Hide resolved
endif()
string(STRIP "${mariadbclient_MACOS_PREFIX}" mariadbclient_MACOS_PREFIX)
list(PREPEND CMAKE_PREFIX_PATH ${mariadbclient_MACOS_PREFIX})
pkg_check_modules(mariadbclient_PKGCONF QUIET "lib${mariadbclient_LIBNAME}")
Copy link
Member Author

Choose a reason for hiding this comment

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

We might not need QUIET here

Suggested change
pkg_check_modules(mariadbclient_PKGCONF QUIET "lib${mariadbclient_LIBNAME}")
pkg_check_modules(mariadbclient_PKGCONF "lib${mariadbclient_LIBNAME}")

LinZhihao-723 marked this conversation as resolved.
Show resolved Hide resolved
endif()

if(NOT mariadbclient_PKGCONF_FOUND)
message(FATAL_ERROR "PkgConfig cannot find mariadb")
LinZhihao-723 marked this conversation as resolved.
Show resolved Hide resolved
endif()

# Set include directory
find_path(MariaDBClient_INCLUDE_DIR mysql.h
HINTS ${mariadbclient_PKGCONF_INCLUDEDIR}
Expand Down
Loading