1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99
|
# - Try to find MariaDB Embedded library
# Find the MariaDB embedded library
# This module defines
# MARIADBD_LIBRARIES, the libraries needed to use MariaDB Embedded.
# MariaDBd_FOUND, If false, do not try to use MariaDB Embedded.
# Copyright (c) 2006-2018, Jarosław Staniek <staniek@kde.org>
#
# Redistribution and use is allowed according to the terms of the BSD license.
# For details see the accompanying COPYING-CMAKE-SCRIPTS file.
include(CheckCXXSourceCompiles)
include(CMakePushCheckState)
if(NOT MySQL_FOUND)
find_package(MySQL)
if( NOT MySQL_FOUND )
find_package(MariaDB REQUIRED)
endif()
endif()
if(MySQL_FOUND OR MariaDB_FOUND)
# First try to get information from mysql_config which might be a shell script
# or an executable. Unfortunately not every distro has pkgconfig files for
# MySQL/MariaDB.
find_program(MYSQLCONFIG_EXECUTABLE
NAMES mysql_config mysql_config5
HINTS ${BIN_INSTALL_DIR}
)
if(MYSQLCONFIG_EXECUTABLE)
execute_process(
COMMAND ${MYSQLCONFIG_EXECUTABLE} --libmysqld-libs
RESULT_VARIABLE MC_return_embedded
OUTPUT_VARIABLE MC_MYSQLE_LIBRARIES
OUTPUT_STRIP_TRAILING_WHITESPACE
)
if ("${MC_return_embedded}" STREQUAL "0")
set(MARIADBD_LIBRARIES ${MC_MYSQLE_LIBRARIES})
endif()
endif()
# Try searching manually via find_path/find_library, possibly with hints
# from pkg-config
find_package(PkgConfig)
pkg_check_modules(PC_MYSQL QUIET mysql mariadb)
if(NOT MARIADBD_LIBRARIES)
# mysql-config removed --libmysql-libs, but amarok needs libmysqld other
# than libmysqlclient to run mysql embedded server.
find_library(MARIADBD_LIBRARIES NAMES mysqld libmysqld
PATHS
$ENV{MYSQL_DIR}/libmysql_r/.libs
$ENV{MYSQL_DIR}/lib
$ENV{MYSQL_DIR}/lib/mysql
${PC_MYSQL_LIBDIR}
${PC_MYSQL_LIBRARY_DIRS}
PATH_SUFFIXES
mysql
)
endif()
if(PC_MYSQL_VERSION)
set(MySQLe_VERSION_STRING ${PC_MYSQL_VERSION})
endif()
if(MARIADBD_LIBRARIES)
# libmysqld on FreeBSD apparently doesn't properly report what libraries
# it likes to link with, libmysqlclient does though.
#if(${CMAKE_HOST_SYSTEM_NAME} MATCHES "FreeBSD")
# string(REGEX REPLACE "-lmysqlclient" "-lmysqld" _mysql_libs ${MYSQL_LIBRARIES})
# string(STRIP ${_mysql_libs} _mysql_libs)
# set(MARIADBD_LIBRARIES ${_mysql_libs})
#endif()
cmake_push_check_state()
set(CMAKE_REQUIRED_INCLUDES ${MYSQL_INCLUDE_DIR})
set(CMAKE_REQUIRED_LIBRARIES ${MARIADBD_LIBRARIES})
check_cxx_source_compiles( "#include <mysql.h>\nint main() { int i = MYSQL_OPT_USE_EMBEDDED_CONNECTION; }" HAVE_MYSQL_OPT_EMBEDDED_CONNECTION )
cmake_pop_check_state()
endif()
endif()
include(FindPackageHandleStandardArgs)
find_package_handle_standard_args(MariaDBd
REQUIRED_VARS MARIADBD_LIBRARIES HAVE_MYSQL_OPT_EMBEDDED_CONNECTION
VERSION_VAR MySQLe_VERSION_STRING
)
mark_as_advanced(MARIADBD_LIBRARIES HAVE_MYSQL_OPT_EMBEDDED_CONNECTION)
set_package_properties(MariaDBd PROPERTIES
DESCRIPTION "MariaDB Embedded Library (libmariadbd)"
URL "https://mariadb.org"
)
|