From edc247918afef427d58c688b0a256773847be83f Mon Sep 17 00:00:00 2001 From: Markus Makela Date: Thu, 29 Jan 2015 14:02:56 +0200 Subject: [PATCH] Fix to bug 683: http://bugs.mariadb.com/show_bug.cgi?id=683 Removed the usage of mysql_config and added warnings if the mysqld provider is something else than MariaDB. --- CMakeLists.txt | 2 +- FindMySQL.cmake | 38 ++++++++++++++++++++++++++++++++++++++ FindMySQLConfig.cmake | 20 -------------------- 3 files changed, 39 insertions(+), 21 deletions(-) create mode 100644 FindMySQL.cmake delete mode 100644 FindMySQLConfig.cmake diff --git a/CMakeLists.txt b/CMakeLists.txt index 0d0752125..ebc293c78 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -20,7 +20,7 @@ check_deps() check_dirs() find_package(Valgrind) find_package(MySQLClient) -find_package(MySQLConfig) +find_package(MySQL) set(CMAKE_INSTALL_RPATH ${CMAKE_INSTALL_RPATH}:${CMAKE_INSTALL_PREFIX}/lib:${CMAKE_INSTALL_PREFIX}/modules) diff --git a/FindMySQL.cmake b/FindMySQL.cmake new file mode 100644 index 000000000..b35408a96 --- /dev/null +++ b/FindMySQL.cmake @@ -0,0 +1,38 @@ +# This CMake file tries to find the the mysqld binary +# The following variables are set: +# MYSQLD_FOUND - System has the mysqld executable +# MYSQLD_EXECUTABLE - The mysqld executable +# MYSQLD_VERSION - The MySQL version number +# MYSQLD_PROVIDER - The MySQL provider e.g. MariaDB + +find_program(MYSQLD_EXECUTABLE mysqld) + +if(MYSQLD_EXECUTABLE MATCHES "MYSQLD_EXECUTABLE-NOTFOUND") + message(FATAL_ERROR "Cannot find the mysqld executable.") + set(MYSQLD_FOUND FALSE CACHE INTERNAL "") + unset(MYSQLD_EXECUTABLE) +else() + execute_process(COMMAND ${MYSQLD_EXECUTABLE} --version OUTPUT_VARIABLE MYSQLD_VERSION) + string(REPLACE "\n" "" MYSQLD_VERSION ${MYSQLD_VERSION}) + string(TOLOWER ${MYSQLD_VERSION} MYSQLD_VERSION) + + if(MYSQLD_VERSION MATCHES "mariadb") + set(MYSQLD_PROVIDER "MariaDB" CACHE INTERNAL "The mysqld provider") + elseif(MYSQLD_VERSION MATCHES "mysql") + set(MYSQLD_PROVIDER "MySQL" CACHE INTERNAL "The mysqld provider") + else() + set(MYSQLD_PROVIDER "Unknown" CACHE INTERNAL "The mysqld provider") + endif() + + string(REGEX REPLACE "[^0-9.]+([0-9.]+).+$" "\\1" MYSQLD_VERSION ${MYSQLD_VERSION}) + + message(STATUS "MySQL version: ${MYSQLD_VERSION}") + message(STATUS "MySQL provider: ${MYSQLD_PROVIDER}") + if(MYSQLD_VERSION VERSION_LESS 5.5.40) + message(WARNING "Required MySQL version is 5.5.40 or greater.") + endif() + if(NOT MYSQLD_PROVIDER MATCHES "MariaDB") + message(WARNING "Using non-MariaDB MySQL server.") + endif() + set(MYSQLD_FOUND TRUE CACHE INTERNAL "") +endif() diff --git a/FindMySQLConfig.cmake b/FindMySQLConfig.cmake deleted file mode 100644 index 377ea2912..000000000 --- a/FindMySQLConfig.cmake +++ /dev/null @@ -1,20 +0,0 @@ -# This CMake file tries to find the the MySQL configuration tool -# The following variables are set: -# MYSQLCONFIG_FOUND - System has MySQL and the tool was found -# MYSQLCONFIG_EXECUTABLE - The MySQL configuration tool executable -# MYSQL_VERSION - The MySQL version number -find_program(MYSQLCONFIG_EXECUTABLE mysql_config) -if(MYSQLCONFIG_EXECUTABLE MATCHES "MYSQLCONFIG_EXECUTABLE-NOTFOUND") - message(FATAL_ERROR "Cannot find mysql_config.") - set(MYSQLCONFIG_FOUND FALSE CACHE INTERNAL "") - unset(MYSQLCONFIG_EXECUTABLE) -else() - execute_process(COMMAND ${MYSQLCONFIG_EXECUTABLE} --version OUTPUT_VARIABLE MYSQL_VERSION) - string(REPLACE "\n" "" MYSQL_VERSION ${MYSQL_VERSION}) - message(STATUS "mysql_config found: ${MYSQLCONFIG_EXECUTABLE}") - message(STATUS "MySQL version: ${MYSQL_VERSION}") - if(MYSQL_VERSION VERSION_LESS 5.5.40) - message(WARNING "Required MySQL version is 5.5.40 or greater.") - endif() - set(MYSQLCONFIG_FOUND TRUE CACHE INTERNAL "") -endif()