Teaspeak-Server/cmake/Modules/Findmysqlclient.cmake
2020-02-16 12:04:23 +01:00

54 lines
1.7 KiB
CMake

# - Try to find mysqlclient include dirs and libraries
#
# Usage of this module as follows:
#
# find_package(mysqlclient)
#
# Variables used by this module, they can change the default behaviour and need
# to be set before calling find_package:
#
# MYSQLCLIENT_ROOT_DIR Set this variable to the root installation of
# mysqlclient if the module has problems finding the
# proper installation path.
#
# Variables defined by this module:
#
# MYSQLCLIENT_FOUND System has mysqlclient, include and library dirs found
# MYSQLCLIENT_INCLUDE_DIR The mysqlclient include directories.
include(FindPackageHandleStandardArgs)
find_package(PkgConfig)
pkg_check_modules(PC_MYSQL_CLIENT QUIET mysqlclient)
message(${PC_MYSQL_CLIENT_INCLUDEDIR})
find_path(MYSQLCLIENT_INCLUDE_DIR
NAMES mysql.h
HINTS ${MYSQLCLIENT_ROOT_DIR} ${MYSQLCLIENT_ROOT_DIR}/include/ ${PC_MYSQL_CLIENT_INCLUDEDIR}
)
if (NOT TARGET mysqlclient::static)
find_library(MYSQLCLIENT_STATIC_LIBS
NAMES libmysqlclient.a
HINTS ${mysqlclient_ROOT_DIR} ${mysqlclient_ROOT_DIR}/lib ${PC_MYSQL_CLIENT_LIBDIR}
)
if (MYSQLCLIENT_STATIC_LIBS)
add_library(mysqlclient::static SHARED IMPORTED)
set_target_properties(mysqlclient::static PROPERTIES
IMPORTED_LOCATION ${MYSQLCLIENT_STATIC_LIBS}
INTERFACE_INCLUDE_DIRECTORIES ${MYSQLCLIENT_INCLUDE_DIR}
)
endif ()
endif ()
find_package_handle_standard_args(mysqlclient DEFAULT_MSG
MYSQLCLIENT_INCLUDE_DIR
)
mark_as_advanced(
MYSQLCLIENT_ROOT_DIR
MYSQLCLIENT_STATIC_LIBS
PC_MYSQL_CLIENT
)