Warning, /multimedia/amarok/cmake/modules/FindMySQLe.cmake is written in an unsupported language. File is not indexed.

0001 # - Try to find MySQL Embedded library
0002 # Find the MySQL embedded library
0003 # This module defines
0004 #  MYSQLE_LIBRARIES, the libraries needed to use MySQL Embedded.
0005 #  MySQLe_FOUND, If false, do not try to use MySQL Embedded.
0006 
0007 # Copyright (c) 2006-2018, Jarosław Staniek <staniek@kde.org>
0008 #
0009 # Redistribution and use is allowed according to the terms of the BSD license.
0010 # For details see the accompanying COPYING-CMAKE-SCRIPTS file.
0011 
0012 include(CheckCXXSourceCompiles)
0013 include(CMakePushCheckState)
0014 
0015 if(NOT MySQL_FOUND)
0016     find_package(MySQL)
0017 
0018     if( NOT MySQL_FOUND )
0019         find_package(MariaDB REQUIRED)
0020     endif()
0021 endif()
0022 
0023 if(MySQL_FOUND OR MariaDB_FOUND)
0024 
0025 # First try to get information from mysql_config which might be a shell script
0026 # or an executable. Unfortunately not every distro has pkgconfig files for
0027 # MySQL/MariaDB.
0028 find_program(MYSQLCONFIG_EXECUTABLE
0029     NAMES mysql_config mysql_config5
0030     HINTS ${BIN_INSTALL_DIR}
0031 )
0032 
0033 if(MYSQLCONFIG_EXECUTABLE)
0034     execute_process(
0035         COMMAND ${MYSQLCONFIG_EXECUTABLE} --libmysqld-libs
0036         RESULT_VARIABLE MC_return_embedded
0037         OUTPUT_VARIABLE MC_MYSQLE_LIBRARIES
0038         OUTPUT_STRIP_TRAILING_WHITESPACE
0039     )
0040 
0041     if ("${MC_return_embedded}" STREQUAL "0")
0042         set(MYSQLE_LIBRARIES ${MC_MYSQLE_LIBRARIES})
0043     endif()
0044 endif()
0045 
0046 # Try searching manually via find_path/find_library, possibly with hints
0047 # from pkg-config
0048 find_package(PkgConfig)
0049 pkg_check_modules(PC_MYSQL QUIET mysql mariadb)
0050 
0051 if(NOT MYSQLE_LIBRARIES)
0052 # mysql-config removed --libmysql-libs, but amarok needs libmysqld other
0053 # than libmysqlclient to run mysql embedded server.
0054     find_library(MYSQLE_LIBRARIES NAMES mysqld libmysqld
0055         PATHS
0056             $ENV{MYSQL_DIR}/libmysql_r/.libs
0057             $ENV{MYSQL_DIR}/lib
0058             $ENV{MYSQL_DIR}/lib/mysql
0059             ${PC_MYSQL_LIBDIR}
0060             ${PC_MYSQL_LIBRARY_DIRS}
0061         PATH_SUFFIXES
0062             mysql
0063     )
0064 endif()
0065 
0066 if(PC_MYSQL_VERSION)
0067     set(MySQLe_VERSION_STRING ${PC_MYSQL_VERSION})
0068 endif()
0069 
0070 if(MYSQLE_LIBRARIES)
0071     # libmysqld on FreeBSD apparently doesn't properly report what libraries
0072     # it likes to link with, libmysqlclient does though.
0073     #if(${CMAKE_HOST_SYSTEM_NAME} MATCHES "FreeBSD")
0074     #    string(REGEX REPLACE "-lmysqlclient" "-lmysqld" _mysql_libs ${MYSQL_LIBRARIES})
0075     #    string(STRIP ${_mysql_libs} _mysql_libs)
0076     #    set(MYSQLE_LIBRARIES ${_mysql_libs})
0077     #endif()
0078     cmake_push_check_state()
0079     set(CMAKE_REQUIRED_INCLUDES ${MYSQL_INCLUDE_DIR})
0080     set(CMAKE_REQUIRED_LIBRARIES ${MYSQLE_LIBRARIES})
0081     check_cxx_source_compiles( "#include <mysql.h>\nint main() { int i = MYSQL_OPT_USE_EMBEDDED_CONNECTION; }" HAVE_MYSQL_OPT_EMBEDDED_CONNECTION )
0082     cmake_pop_check_state()
0083 endif()
0084 
0085 endif()
0086 
0087 include(FindPackageHandleStandardArgs)
0088 
0089 find_package_handle_standard_args(MySQLe
0090     REQUIRED_VARS MYSQLE_LIBRARIES HAVE_MYSQL_OPT_EMBEDDED_CONNECTION
0091     VERSION_VAR MySQLe_VERSION_STRING
0092 )
0093 
0094 mark_as_advanced(MYSQLE_LIBRARIES HAVE_MYSQL_OPT_EMBEDDED_CONNECTION)
0095 
0096 set_package_properties(MySQLe PROPERTIES
0097     DESCRIPTION "MySQL Embedded Library (libmysqld)"
0098     URL "https://www.mysql.com"
0099 )