From 77a89e083d64e4c862e61b9716a1e7d1f1892df4 Mon Sep 17 00:00:00 2001 From: aaron Date: Sun, 1 Sep 2024 20:33:20 -0400 Subject: [PATCH] Update to find mysql during build --- CMakeLists.txt | 26 +++++++++++++++++++++----- 1 file changed, 21 insertions(+), 5 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index dae4b81ab..4e137f147 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -42,6 +42,26 @@ enable_testing() # Find OpenSSL find_package(OpenSSL REQUIRED) +# Attempt to find the MySQL header files +find_path(MYSQL_INCLUDE_DIR + NAMES mysql.h + PATHS /usr/include /usr/local/include /usr/include/mysql /usr/local/include/mysql /usr/local/opt/mysql-client/include + ) + +# Attempt to find the MySQL library files +find_library(MYSQL_LIBRARY + NAMES mysqlclient + PATHS /usr/lib /usr/local/lib /usr/lib/x86_64-linux-gnu /usr/local/lib/x86_64-linux-gnu /usr/local/opt/mysql-client/lib + ) + +# Check if both the header and library were found +if(MYSQL_INCLUDE_DIR AND MYSQL_LIBRARY) + message(STATUS "MySQL include directory: ${MYSQL_INCLUDE_DIR}") + message(STATUS "MySQL library: ${MYSQL_LIBRARY}") +else() + message(FATAL_ERROR "MySQL not found. Please install MySQL development libraries.") +endif() + # Check for pkg-config and find MySQL client find_package(PkgConfig REQUIRED) pkg_search_module(MYSQL REQUIRED mysqlclient) @@ -51,8 +71,4 @@ link_directories(${MySQL_LIBRARY_DIRS} ${OPENSSL_LIBRARY_DIRS}) # Include the src subdirectory add_subdirectory(utils) -add_subdirectory(test) - -# Optionally print the paths for debugging -message(STATUS "MySQL include directory: ${MYSQL_INCLUDE_DIR}") -message(STATUS "MySQL libraries: ${MYSQL_LIBRARY}") \ No newline at end of file +add_subdirectory(test) \ No newline at end of file