Add and use FindSQLite.cmake

Added a find_package module for SQLite development libraries.
This commit is contained in:
Markus Makela
2016-10-28 12:23:47 +03:00
parent 1be3bb9b8d
commit 3c26ea16e2
4 changed files with 42 additions and 12 deletions

23
cmake/FindSQLite.cmake Normal file
View File

@ -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()