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
|
# - Try to find MariaDB library
# Find the MariaDB includes and client library
# This module defines
# MYSQL_INCLUDE_DIR, where to find mysql.h
# MYSQL_LIBRARIES, the libraries needed to use MariaDB.
# MariaDB_FOUND, If false, do not try to use MariaDB.
# 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)
# First try to get information from mariadb_config which might be a shell script
# or an executable. Unfortunately not every distro has pkgconfig files for
# MariaDB.
find_program(MARIADBCONFIG_EXECUTABLE
NAMES mariadb_config
HINTS ${BIN_INSTALL_DIR}
)
if(MARIADBCONFIG_EXECUTABLE)
execute_process(
COMMAND ${MARIADBCONFIG_EXECUTABLE} --libs
RESULT_VARIABLE MC_return_libraries
OUTPUT_VARIABLE MYSQL_LIBRARIES
OUTPUT_STRIP_TRAILING_WHITESPACE
)
endif()
# Try searching manually via find_path/find_library, possibly with hints
# from pkg-config
find_package(PkgConfig)
pkg_check_modules(PC_MARIADB libmariadb)
find_path(MYSQL_INCLUDE_DIR mysql.h
PATHS
$ENV{MYSQL_INCLUDE_DIR}
$ENV{MYSQL_DIR}/include
${PC_MARIADB_INCLUDEDIR}
${PC_MARIADB_INCLUDE_DIRS}
/usr/local/mariadb/include
/opt/mariadb/mariadb/include
PATH_SUFFIXES
mariadb
)
if(PC_MARIADB_VERSION)
set(MySQL_VERSION_STRING ${PC_MARIADB_VERSION})
endif()
include(FindPackageHandleStandardArgs)
find_package_handle_standard_args(MariaDB
REQUIRED_VARS MYSQL_LIBRARIES MYSQL_INCLUDE_DIR
VERSION_VAR MySQL_VERSION_STRING
)
mark_as_advanced(MYSQL_INCLUDE_DIR MYSQL_LIBRARIES)
set_package_properties(MariaDB PROPERTIES
DESCRIPTION "MariaDB Client Library (libmariadb)"
URL "https://mariadb.org/"
)
|