MariaDB Connector C is build from source if it is not found on the system
The FindMariaDBConnector.cmake file now checks if the found library actually is the MariaDB Connector-C library. If the found library is not the MariaDB Connector-C, it will be built from source.
This commit is contained in:
26
cmake/BuildMariaDBConnector.cmake
Normal file
26
cmake/BuildMariaDBConnector.cmake
Normal file
@ -0,0 +1,26 @@
|
||||
# Build the MariaDB Connector-C
|
||||
#
|
||||
# If the MariaDB connector is not found, the last option is to download it
|
||||
# and build it from source. This file downloads and builds the connector and
|
||||
# sets the variables set by FindMariaDBConnector.cmake so that it appears that
|
||||
# the system has the connector.
|
||||
|
||||
include(ExternalProject)
|
||||
|
||||
ExternalProject_Add(connector-c
|
||||
GIT_REPOSITORY https://github.com/MariaDB/mariadb-connector-c.git
|
||||
GIT_TAG v2.2.1
|
||||
CMAKE_ARGS -DCMAKE_INSTALL_PREFIX=${CMAKE_BINARY_DIR}/connector-c/install
|
||||
BINARY_DIR ${CMAKE_BINARY_DIR}/connector-c
|
||||
INSTALL_DIR ${CMAKE_BINARY_DIR}/connector-c/install)
|
||||
|
||||
set(MARIADB_CONNECTOR_FOUND TRUE CACHE INTERNAL "" FORCE)
|
||||
set(MARIADB_CONNECTOR_STATIC_FOUND TRUE CACHE INTERNAL "" FORCE)
|
||||
set(MARIADB_CONNECTOR_INCLUDE_DIR
|
||||
${CMAKE_BINARY_DIR}/connector-c/install/include/mariadb CACHE INTERNAL "" FORCE)
|
||||
set(MARIADB_CONNECTOR_STATIC_LIBRARIES
|
||||
${CMAKE_BINARY_DIR}/connector-c/install/lib/mariadb/libmariadbclient.a
|
||||
CACHE INTERNAL "" FORCE)
|
||||
set(MARIADB_CONNECTOR_LIBRARIES
|
||||
${CMAKE_BINARY_DIR}/connector-c/install/lib/mariadb/libmariadbclient.a
|
||||
CACHE INTERNAL "" FORCE)
|
@ -6,28 +6,37 @@
|
||||
# MARIADB_CONNECTOR_STATIC_LIBRARIES - The static connector libraries
|
||||
# MARIADB_CONNECTOR_INCLUDE_DIR - The connector headers
|
||||
|
||||
find_library(MARIADB_CONNECTOR_LIB NAMES mysqlclient PATH_SUFFIXES mysql mariadb)
|
||||
if(${MARIADB_CONNECTOR_LIB} MATCHES "NOTFOUND")
|
||||
find_library(MARIADB_CONNECTOR_LIBRARIES NAMES mysqlclient PATH_SUFFIXES mysql mariadb)
|
||||
if(${MARIADB_CONNECTOR_LIBRARIES} MATCHES "NOTFOUND")
|
||||
set(MARIADB_CONNECTOR_FOUND FALSE CACHE INTERNAL "")
|
||||
message(STATUS "Dynamic MySQL client library not found.")
|
||||
unset(MARIADB_CONNECTOR_LIB)
|
||||
unset(MARIADB_CONNECTOR_LIBRARIES)
|
||||
else()
|
||||
set(MARIADB_CONNECTOR_FOUND TRUE CACHE INTERNAL "")
|
||||
message(STATUS "Found dynamic MySQL client library: ${MARIADB_CONNECTOR_LIB}")
|
||||
message(STATUS "Found dynamic MySQL client library: ${MARIADB_CONNECTOR_LIBRARIES}")
|
||||
endif()
|
||||
|
||||
set(OLD_SUFFIXES ${CMAKE_FIND_LIBRARY_SUFFIXES})
|
||||
set(CMAKE_FIND_LIBRARY_SUFFIXES ".a")
|
||||
find_library(MARIADB_CONNECTOR_STATIC_LIB NAMES mysqlclient PATH_SUFFIXES mysql mariadb)
|
||||
find_library(MARIADB_CONNECTOR_STATIC_LIBRARIES NAMES mysqlclient PATH_SUFFIXES mysql mariadb)
|
||||
set(CMAKE_FIND_LIBRARY_SUFFIXES ${OLD_SUFFIXES})
|
||||
|
||||
if(${MARIADB_CONNECTOR_STATIC_LIB} MATCHES "NOTFOUND")
|
||||
if(${MARIADB_CONNECTOR_STATIC_LIBRARIES} MATCHES "NOTFOUND")
|
||||
set(MARIADB_CONNECTOR_STATIC_FOUND FALSE CACHE INTERNAL "")
|
||||
message(STATUS "Static MySQL client library not found.")
|
||||
unset(MARIADB_CONNECTOR_STATIC_LIB)
|
||||
unset(MARIADB_CONNECTOR_STATIC_LIBRARIES)
|
||||
else()
|
||||
set(MARIADB_CONNECTOR_STATIC_FOUND TRUE CACHE INTERNAL "")
|
||||
message(STATUS "Found statc MySQL client library: ${MARIADB_CONNECTOR_STATIC_LIB}")
|
||||
message(STATUS "Found statc MySQL client library: ${MARIADB_CONNECTOR_STATIC_LIBRARIES}")
|
||||
endif()
|
||||
|
||||
find_path(MARIADB_CONNECTOR_INCLUDE_DIR mysql.h PATH_SUFFIXES mysql mariadb)
|
||||
|
||||
include(CheckSymbolExists)
|
||||
check_symbol_exists(LIBMARIADB ${MARIADB_CONNECTOR_INCLUDE_DIR}/mysql.h HAVE_MARIADB_CONNECTOR)
|
||||
|
||||
if(HAVE_MARIADB_CONNECTOR)
|
||||
message(STATUS "Found MariaDB Connector-C")
|
||||
else()
|
||||
set(MARIADB_CONNECTOR_FOUND FALSE CACHE INTERNAL "" FORCE)
|
||||
endif()
|
||||
|
Reference in New Issue
Block a user