From 3c26ea16e280932d741c1d0841f1d586810da5ce Mon Sep 17 00:00:00 2001 From: Markus Makela Date: Fri, 28 Oct 2016 12:23:47 +0300 Subject: [PATCH] Add and use FindSQLite.cmake Added a find_package module for SQLite development libraries. --- CMakeLists.txt | 1 + cmake/FindJansson.cmake | 4 ++-- cmake/FindSQLite.cmake | 23 ++++++++++++++++++ server/modules/authenticator/CMakeLists.txt | 26 +++++++++++++-------- 4 files changed, 42 insertions(+), 12 deletions(-) create mode 100644 cmake/FindSQLite.cmake diff --git a/CMakeLists.txt b/CMakeLists.txt index 78d70c26e..218964698 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -44,6 +44,7 @@ find_package(LibUUID) find_package(Jansson) find_package(Avro) find_package(GSSAPI) +find_package(SQLite) # Find or build PCRE2 # Read BuildPCRE2 for details about how to add pcre2 as a dependency to a target diff --git a/cmake/FindJansson.cmake b/cmake/FindJansson.cmake index 7116d6f0f..8c2216cac 100644 --- a/cmake/FindJansson.cmake +++ b/cmake/FindJansson.cmake @@ -1,9 +1,9 @@ # This CMake file locates the Jansson libraries and headers # # The following variables are set: -# JANSSON_FOUND - If the Avro C library was found +# JANSSON_FOUND - If the Jansson library was found # JANSSON_LIBRARIES - Path to the static library -# JANSSON_INCLUDE_DIR - Path to Avro headers +# JANSSON_INCLUDE_DIR - Path to Jansson headers find_path(JANSSON_INCLUDE_DIR jansson.h) find_library(JANSSON_LIBRARIES NAMES libjansson.so libjansson.a) diff --git a/cmake/FindSQLite.cmake b/cmake/FindSQLite.cmake new file mode 100644 index 000000000..e5feb5300 --- /dev/null +++ b/cmake/FindSQLite.cmake @@ -0,0 +1,23 @@ +# This CMake file locates the SQLite3 development libraries +# +# The following variables are set: +# SQLITE_FOUND - If the SQLite library was found +# SQLITE_LIBRARIES - Path to the static library +# SQLITE_INCLUDE_DIR - Path to SQLite headers +# SQLITE_VERSION - Library version + +find_path(SQLITE_INCLUDE_DIR sqlite3.h) +find_library(SQLITE_LIBRARIES NAMES libsqlite3.so) + +if (SQLITE_INCLUDE_DIR AND SQLITE_LIBRARIES) + + execute_process(COMMAND grep ".*#define.*SQLITE_VERSION " ${SQLITE_INCLUDE_DIR}/sqlite3.h + COMMAND sed "s/.*\"\\(.*\\)\".*/\\1/" + OUTPUT_VARIABLE SQLITE_VERSION + OUTPUT_STRIP_TRAILING_WHITESPACE) + + message(STATUS "Found SQLite version ${SQLITE_VERSION}: ${SQLITE_LIBRARIES}") + set(SQLITE_FOUND TRUE) +else() + message(STATUS "Could not find SQLite") +endif() diff --git a/server/modules/authenticator/CMakeLists.txt b/server/modules/authenticator/CMakeLists.txt index 8244eef4d..b8294d01a 100644 --- a/server/modules/authenticator/CMakeLists.txt +++ b/server/modules/authenticator/CMakeLists.txt @@ -5,18 +5,24 @@ target_link_libraries(MySQLBackendAuth maxscale-common MySQLCommon) set_target_properties(MySQLBackendAuth PROPERTIES VERSION "1.0.0") install_module(MySQLBackendAuth core) -if (GSSAPI_FOUND) - include_directories(${GSSAPI_INCS}) +if (GSSAPI_FOUND AND SQLITE_FOUND) + if (NOT SQLITE_VERSION VERSION_LESS "3.7.7") + include_directories(${GSSAPI_INCS}) + include_directories(${SQLITE_INCLUDE_DIR}) - add_library(GSSAPIAuth SHARED gssapi_auth.c gssapi_auth_common.c) - target_link_libraries(GSSAPIAuth maxscale-common ${GSSAPI_LIBS} sqlite3 MySQLCommon) - set_target_properties(GSSAPIAuth PROPERTIES VERSION "1.0.0") - install_module(GSSAPIAuth core) + add_library(GSSAPIAuth SHARED gssapi_auth.c gssapi_auth_common.c) + target_link_libraries(GSSAPIAuth maxscale-common ${GSSAPI_LIBS} ${SQLITE_LIBRARIES} MySQLCommon) + set_target_properties(GSSAPIAuth PROPERTIES VERSION "1.0.0") + install_module(GSSAPIAuth core) - add_library(GSSAPIBackendAuth SHARED gssapi_backend_auth.c gssapi_auth_common.c) - target_link_libraries(GSSAPIBackendAuth maxscale-common ${GSSAPI_LIBS} MySQLCommon) - set_target_properties(GSSAPIBackendAuth PROPERTIES VERSION "1.0.0") - install_module(GSSAPIBackendAuth core) + add_library(GSSAPIBackendAuth SHARED gssapi_backend_auth.c gssapi_auth_common.c) + target_link_libraries(GSSAPIBackendAuth maxscale-common ${GSSAPI_LIBS} MySQLCommon) + set_target_properties(GSSAPIBackendAuth PROPERTIES VERSION "1.0.0") + install_module(GSSAPIBackendAuth core) + + else() + message(STATUS "Minimum requires SQLite version for GSSAPIAuth is 3.7.7, current SQLite version is ${SQLITE_VERSION}") + endif() endif() add_library(NullAuthAllow SHARED null_auth_allow.c)