From 6f8306c2b8ee8ec77dd740010786dbe1cc1b3430 Mon Sep 17 00:00:00 2001 From: LinZhihao-723 Date: Sat, 9 Nov 2024 21:13:52 -0500 Subject: [PATCH 1/5] Fix --- components/core/cmake/Modules/FindMariaDBClient.cmake | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/components/core/cmake/Modules/FindMariaDBClient.cmake b/components/core/cmake/Modules/FindMariaDBClient.cmake index 543f31a6b..e02117763 100644 --- a/components/core/cmake/Modules/FindMariaDBClient.cmake +++ b/components/core/cmake/Modules/FindMariaDBClient.cmake @@ -20,6 +20,17 @@ 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 OUTPUT_VARIABLE mariadb_MACOS_PREFIX) + string(STRIP "${mariadb_MACOS_PREFIX}" mariadb_MACOS_PREFIX) + set(CMAKE_PREFIX_PATH "${mariadb_MACOS_PREFIX};${CMAKE_PREFIX_PATH}") + pkg_check_modules(mariadbclient_PKGCONF QUIET "lib${mariadbclient_LIBNAME}") +endif() + +if (NOT mariadbclient_PKGCONF_FOUND) + message(FATAL_ERROR "pkg_config cannot find mariadb") +endif () + # Set include directory find_path(MariaDBClient_INCLUDE_DIR mysql.h HINTS ${mariadbclient_PKGCONF_INCLUDEDIR} From e882a4924bebc8bcf1c8348c6d5075330f9f687f Mon Sep 17 00:00:00 2001 From: LinZhihao-723 Date: Sat, 9 Nov 2024 21:30:46 -0500 Subject: [PATCH 2/5] Style fix --- components/core/cmake/Modules/FindMariaDBClient.cmake | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/components/core/cmake/Modules/FindMariaDBClient.cmake b/components/core/cmake/Modules/FindMariaDBClient.cmake index e02117763..72de50491 100644 --- a/components/core/cmake/Modules/FindMariaDBClient.cmake +++ b/components/core/cmake/Modules/FindMariaDBClient.cmake @@ -20,16 +20,16 @@ include(cmake/Modules/FindLibraryDependencies.cmake) find_package(PkgConfig) pkg_check_modules(mariadbclient_PKGCONF QUIET "lib${mariadbclient_LIBNAME}") -if (NOT mariadbclient_PKGCONF_FOUND AND APPLE) +if(NOT mariadbclient_PKGCONF_FOUND AND APPLE) execute_process(COMMAND brew --prefix mariadb-connector-c OUTPUT_VARIABLE mariadb_MACOS_PREFIX) string(STRIP "${mariadb_MACOS_PREFIX}" mariadb_MACOS_PREFIX) set(CMAKE_PREFIX_PATH "${mariadb_MACOS_PREFIX};${CMAKE_PREFIX_PATH}") pkg_check_modules(mariadbclient_PKGCONF QUIET "lib${mariadbclient_LIBNAME}") endif() -if (NOT mariadbclient_PKGCONF_FOUND) +if(NOT mariadbclient_PKGCONF_FOUND) message(FATAL_ERROR "pkg_config cannot find mariadb") -endif () +endif() # Set include directory find_path(MariaDBClient_INCLUDE_DIR mysql.h From 26f03e51c49b9393abea249d500e5e66d541283f Mon Sep 17 00:00:00 2001 From: LinZhihao-723 Date: Sat, 9 Nov 2024 22:08:13 -0500 Subject: [PATCH 3/5] Apply code review comments --- .../core/cmake/Modules/FindMariaDBClient.cmake | 16 ++++++++++++---- 1 file changed, 12 insertions(+), 4 deletions(-) diff --git a/components/core/cmake/Modules/FindMariaDBClient.cmake b/components/core/cmake/Modules/FindMariaDBClient.cmake index 72de50491..ac4ab5207 100644 --- a/components/core/cmake/Modules/FindMariaDBClient.cmake +++ b/components/core/cmake/Modules/FindMariaDBClient.cmake @@ -21,14 +21,22 @@ 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 OUTPUT_VARIABLE mariadb_MACOS_PREFIX) - string(STRIP "${mariadb_MACOS_PREFIX}" mariadb_MACOS_PREFIX) - set(CMAKE_PREFIX_PATH "${mariadb_MACOS_PREFIX};${CMAKE_PREFIX_PATH}") + execute_process( + COMMAND brew --prefix mariadb-connector-c + RESULT_VARIABLE brew_result + OUTPUT_VARIABLE mariadbclient_MACOS_PREFIX + ERROR_QUIET + ) + if(NOT brew_result EQUAL 0) + message(FATAL_ERROR "mariadb-connector-c not found in 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 mariadb") + message(FATAL_ERROR "PkgConfig cannot find mariadb") endif() # Set include directory From e12ff43ed2e2b7223160e9a11398c310585336fe Mon Sep 17 00:00:00 2001 From: Lin Zhihao <59785146+LinZhihao-723@users.noreply.github.com> Date: Sat, 9 Nov 2024 22:10:17 -0500 Subject: [PATCH 4/5] Update components/core/cmake/Modules/FindMariaDBClient.cmake Co-authored-by: kirkrodrigues <2454684+kirkrodrigues@users.noreply.github.com> --- components/core/cmake/Modules/FindMariaDBClient.cmake | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/components/core/cmake/Modules/FindMariaDBClient.cmake b/components/core/cmake/Modules/FindMariaDBClient.cmake index ac4ab5207..4d13436e5 100644 --- a/components/core/cmake/Modules/FindMariaDBClient.cmake +++ b/components/core/cmake/Modules/FindMariaDBClient.cmake @@ -36,7 +36,7 @@ if(NOT mariadbclient_PKGCONF_FOUND AND APPLE) endif() if(NOT mariadbclient_PKGCONF_FOUND) - message(FATAL_ERROR "PkgConfig cannot find mariadb") + message(FATAL_ERROR "pkg-config cannot find ${mariadbclient_LIBNAME}") endif() # Set include directory From a0fcffecc1ef934bcd406d09138ed38774562a88 Mon Sep 17 00:00:00 2001 From: LinZhihao-723 Date: Sat, 9 Nov 2024 22:36:11 -0500 Subject: [PATCH 5/5] Update cmake --- components/core/cmake/Modules/FindMariaDBClient.cmake | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/components/core/cmake/Modules/FindMariaDBClient.cmake b/components/core/cmake/Modules/FindMariaDBClient.cmake index 4d13436e5..5801be2e6 100644 --- a/components/core/cmake/Modules/FindMariaDBClient.cmake +++ b/components/core/cmake/Modules/FindMariaDBClient.cmake @@ -23,12 +23,15 @@ 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 + RESULT_VARIABLE mariadbclient_BREW_RESULT OUTPUT_VARIABLE mariadbclient_MACOS_PREFIX - ERROR_QUIET ) - if(NOT brew_result EQUAL 0) - message(FATAL_ERROR "mariadb-connector-c not found in Homebrew") + 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})