From 4446eb56e315c30f8ccc7a779f0b5a8cc3544575 Mon Sep 17 00:00:00 2001 From: Lin Zhihao <59785146+LinZhihao-723@users.noreply.github.com> Date: Sat, 9 Nov 2024 23:00:11 -0500 Subject: [PATCH] fix(cmake): Add Homebrew path detection for `mariadb-connector-c` to fix macOS build failure. (#582) Co-authored-by: kirkrodrigues <2454684+kirkrodrigues@users.noreply.github.com> --- .../cmake/Modules/FindMariaDBClient.cmake | 22 +++++++++++++++++++ 1 file changed, 22 insertions(+) diff --git a/components/core/cmake/Modules/FindMariaDBClient.cmake b/components/core/cmake/Modules/FindMariaDBClient.cmake index 543f31a6b..5801be2e6 100644 --- a/components/core/cmake/Modules/FindMariaDBClient.cmake +++ b/components/core/cmake/Modules/FindMariaDBClient.cmake @@ -20,6 +20,28 @@ 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 mariadbclient_BREW_RESULT + OUTPUT_VARIABLE mariadbclient_MACOS_PREFIX + ) + if(NOT mariadbclient_BREW_RESULT EQUAL 0) + message( + FATAL_ERROR + "pkg-config cannot find ${mariadbclient_LIBNAME} and mariadb-connector-c isn't" + " installed via Homebrew" + ) + 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}") +endif() + +if(NOT mariadbclient_PKGCONF_FOUND) + message(FATAL_ERROR "pkg-config cannot find ${mariadbclient_LIBNAME}") +endif() + # Set include directory find_path(MariaDBClient_INCLUDE_DIR mysql.h HINTS ${mariadbclient_PKGCONF_INCLUDEDIR}