Removed the usage of mysql_config and added warnings if the mysqld provider is something else than MariaDB.
This commit is contained in:
Markus Makela 2015-01-29 14:02:56 +02:00
parent 42d2f99006
commit edc247918a
3 changed files with 39 additions and 21 deletions

View File

@ -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)

38
FindMySQL.cmake Normal file
View File

@ -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()

View File

@ -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()