From ffbdac36c911ec5523d35d91c84a5e0e8c4f5d24 Mon Sep 17 00:00:00 2001 From: an-tao Date: Mon, 3 Dec 2018 17:03:45 +0800 Subject: [PATCH] Modify cmake files for the mariadb database on linux --- CMakeLists.txt | 1 + cmake_modules/FindMySQL.cmake | 13 ++----------- orm_lib/tests/CMakeLists.txt | 2 +- 3 files changed, 4 insertions(+), 12 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index d38fc048..de945bcb 100755 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -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!") diff --git a/cmake_modules/FindMySQL.cmake b/cmake_modules/FindMySQL.cmake index 8c95985d..2e0637ff 100644 --- a/cmake_modules/FindMySQL.cmake +++ b/cmake_modules/FindMySQL.cmake @@ -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) diff --git a/orm_lib/tests/CMakeLists.txt b/orm_lib/tests/CMakeLists.txt index fc1351b5..8c721d73 100644 --- a/orm_lib/tests/CMakeLists.txt +++ b/orm_lib/tests/CMakeLists.txt @@ -1,3 +1,3 @@ link_libraries(drogon trantor pthread dl) -add_executable(db_test db_test.cc users.cc) \ No newline at end of file +add_executable(db_test db_test.cc Users.cc)