Modify cmake files for the mariadb database on linux

This commit is contained in:
an-tao 2018-12-03 17:03:45 +08:00
parent 1e7fe48d80
commit ffbdac36c9
3 changed files with 4 additions and 12 deletions

View File

@ -79,6 +79,7 @@ if(MYSQL_FOUND)
message(STATUS "libs:" ${MYSQL_CLIENT_LIBS})
message(STATUS "version:" ${MYSQL_VERSION_STRING})
if(MYSQL_VERSION_STRING STREQUAL "")
set(MYSQL_FOUND false)
message(STATUS "The mysql in your system is not the mariadb, so we can't use it in drogon")
else()
message(STATUS "Ok! We find the mariadb!")

View File

@ -66,7 +66,7 @@ IF (WIN32)
$ENV{ProgramFiles}/MySQL/*/lib/${libsuffixDist}
$ENV{SystemDrive}/MySQL/*/lib/${libsuffixDist})
ELSE (WIN32)
FIND_LIBRARY(MYSQL_LIB NAMES mysqlclient_r mysqlclient
FIND_LIBRARY(MYSQL_LIB NAMES mariadbclient
PATHS
/usr/lib/mysql
/usr/local/lib/mysql
@ -84,20 +84,11 @@ ENDIF(MYSQL_LIB)
set(MYSQL_VERSION_STRING "")
if( MYSQL_INCLUDE_DIR AND EXISTS "${MYSQL_INCLUDE_DIR}/mariadb_version.h" )
file( STRINGS "${MYSQL_INCLUDE_DIR}/mariadb_version.h"
MYSQL_VERSION_H REGEX "^#define[ \t]+MARIADB_CLIENT_VERSION_STR[ \t]+\"[^\"]+\".*$" )
string( REGEX REPLACE
"^.*MARIADB_CLIENT_VERSION_STR[ \t]+\"([^\"]+)\".*$" "\\1" MYSQL_VERSION_STRING
"${MYSQL_VERSION_H}" )
endif()
EXEC_PROGRAM (grep ARGS "MARIADB_BASE_VERSION ${MYSQL_INCLUDE_DIR}/*.h|awk '{print $3}'" OUTPUT_VARIABLE MYSQL_VERSION_STRING)
IF (MYSQL_INCLUDE_DIR AND MYSQL_LIB_DIR)
SET(MYSQL_FOUND TRUE)
INCLUDE_DIRECTORIES(${MYSQL_INCLUDE_DIR})
LINK_DIRECTORIES(${MYSQL_LIB_DIR})
FIND_LIBRARY(MYSQL_ZLIB zlib PATHS ${MYSQL_LIB_DIR})
FIND_LIBRARY(MYSQL_TAOCRYPT taocrypt PATHS ${MYSQL_LIB_DIR})
IF (MYSQL_LIB)

View File

@ -1,3 +1,3 @@
link_libraries(drogon trantor pthread dl)
add_executable(db_test db_test.cc users.cc)
add_executable(db_test db_test.cc Users.cc)