diff options
author | Sascha Kuehndel (InuSasha) <dev@inusasha.de> | 2018-01-05 18:14:12 +0100 |
---|---|---|
committer | Sascha Kuehndel (InuSasha) <dev@inusasha.de> | 2018-01-31 19:07:50 +0100 |
commit | 35c299575feaf12dd09e9571e981347436063806 (patch) | |
tree | d1d8fb653000976507fa3790e34673c50f77c149 /cmake | |
parent | e1e969b866dfd88309241dce72c6793619b0f4e1 (diff) |
sql-client: add support for mariadb-client
mariadb is a place-in for mysql. only, the search pathes and the include path are changed.
Diffstat (limited to 'cmake')
-rw-r--r-- | cmake/modules/FindMariaDBClient.cmake | 69 |
1 files changed, 69 insertions, 0 deletions
diff --git a/cmake/modules/FindMariaDBClient.cmake b/cmake/modules/FindMariaDBClient.cmake new file mode 100644 index 0000000000..1e5e736f46 --- /dev/null +++ b/cmake/modules/FindMariaDBClient.cmake @@ -0,0 +1,69 @@ +#.rst: +# FindMariaDBClient +# --------------- +# Finds the MariaDBClient library +# +# This will will define the following variables:: +# +# MARIADBCLIENT_FOUND - system has MariaDBClient +# MARIADBCLIENT_INCLUDE_DIRS - the MariaDBClient include directory +# MARIADBCLIENT_LIBRARIES - the MariaDBClient libraries +# MARIADBCLIENT_DEFINITIONS - the MariaDBClient compile definitions +# +# and the following imported targets:: +# +# MariaDBClient::MariaDBClient - The MariaDBClient library + +# Don't find system wide installed version on Windows +if(WIN32) + set(EXTRA_FIND_ARGS NO_SYSTEM_ENVIRONMENT_PATH) +else() + set(EXTRA_FIND_ARGS) +endif() + +find_path(MARIADBCLIENT_INCLUDE_DIR NAMES mariadb/mysql.h mariadb/server/mysql.h) +find_library(MARIADBCLIENT_LIBRARY_RELEASE NAMES mariadbclient libmariadb + PATH_SUFFIXES mariadb + ${EXTRA_FIND_ARGS}) +find_library(MARIADBCLIENT_LIBRARY_DEBUG NAMES mariadbclient libmariadb + PATH_SUFFIXES mariadb + ${EXTRA_FIND_ARGS}) + +if(MARIADBCLIENT_INCLUDE_DIR AND EXISTS "${MARIADBCLIENT_INCLUDE_DIR}/mariadb/mariadb_version.h") + file(STRINGS "${MARIADBCLIENT_INCLUDE_DIR}/mariadb/mariadb_version.h" mariadb_version_str REGEX "^#define[\t ]+MARIADB_CLIENT_VERSION_STR[\t ]+\".*\".*") + string(REGEX REPLACE "^#define[\t ]+MARIADB_CLIENT_VERSION_STR[\t ]+\"([^\"]+)\".*" "\\1" MARIADBCLIENT_VERSION_STRING "${mariadb_version_str}") + unset(mariadb_version_str) +endif() + +include(SelectLibraryConfigurations) +select_library_configurations(MARIADBCLIENT) + +include(FindPackageHandleStandardArgs) +find_package_handle_standard_args(MariaDBClient + REQUIRED_VARS MARIADBCLIENT_LIBRARY MARIADBCLIENT_INCLUDE_DIR + VERSION_VAR MARIADBCLIENT_VERSION_STRING) + +if(MARIADBCLIENT_FOUND) + set(MARIADBCLIENT_LIBRARIES ${MARIADBCLIENT_LIBRARY}) + set(MARIADBCLIENT_INCLUDE_DIRS ${MARIADBCLIENT_INCLUDE_DIR}) + set(MARIADBCLIENT_DEFINITIONS -DHAS_MARIADB=1) + + if(NOT TARGET MariaDBClient::MariaDBClient) + add_library(MariaDBClient::MariaDBClient UNKNOWN IMPORTED) + if(MARIADBCLIENT_LIBRARY_RELEASE) + set_target_properties(MariaDBClient::MariaDBClient PROPERTIES + IMPORTED_CONFIGURATIONS RELEASE + IMPORTED_LOCATION "${MARIADBCLIENT_LIBRARY_RELEASE}") + endif() + if(MARIADBCLIENT_LIBRARY_DEBUG) + set_target_properties(MariaDBClient::MariaDBClient PROPERTIES + IMPORTED_CONFIGURATIONS DEBUG + IMPORTED_LOCATION "${MARIADBCLIENT_LIBRARY_DEBUG}") + endif() + set_target_properties(MariaDBClient::MariaDBClient PROPERTIES + INTERFACE_INCLUDE_DIRECTORIES "${MARIADBCLIENT_INCLUDE_DIR}" + INTERFACE_COMPILE_DEFINITIONS HAS_MARIADB=1) + endif() +endif() + +mark_as_advanced(MARIADBCLIENT_INCLUDE_DIR MARIADBCLIENT_LIBRARY) |