blob: 47caa360cc4b27cd6416bcd7f5f0fa642bfbb649 [file] [log] [blame]
eric@webkit.orgd99f85b2010-05-15 13:37:59 +00001# - Try to find Sqlite
2# Once done this will define
3#
4# SQLITE_FOUND - system has Sqlite
5# SQLITE_INCLUDE_DIR - the Sqlite include directory
6# SQLITE_LIBRARIES - Link these to use Sqlite
7# SQLITE_DEFINITIONS - Compiler switches required for using Sqlite
eric@webkit.orgd99f85b2010-05-15 13:37:59 +00008#
eric@webkit.orgd99f85b2010-05-15 13:37:59 +00009# Copyright (c) 2008, Gilles Caulier, <caulier.gilles@gmail.com>
10#
rakuco@webkit.orgf8462792012-04-30 21:02:51 +000011# Redistribution and use in source and binary forms, with or without
12# modification, are permitted provided that the following conditions
13# are met:
14#
15# 1. Redistributions of source code must retain the copyright
16# notice, this list of conditions and the following disclaimer.
17# 2. Redistributions in binary form must reproduce the copyright
18# notice, this list of conditions and the following disclaimer in the
19# documentation and/or other materials provided with the distribution.
20# 3. The name of the author may not be used to endorse or promote products
21# derived from this software without specific prior written permission.
22#
23# THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
24# IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
25# OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
26# IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
27# INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
28# NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
29# DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
30# THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
31# (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
32# THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
eric@webkit.orgd99f85b2010-05-15 13:37:59 +000033
commit-queue@webkit.orgd6fb2c52012-12-06 03:10:13 +000034if (SQLITE_INCLUDE_DIR AND SQLITE_LIBRARIES)
35 # in cache already
36 set(Sqlite_FIND_QUIETLY TRUE)
37endif (SQLITE_INCLUDE_DIR AND SQLITE_LIBRARIES)
eric@webkit.orgd99f85b2010-05-15 13:37:59 +000038
39# use pkg-config to get the directories and then use these values
commit-queue@webkit.orgd6fb2c52012-12-06 03:10:13 +000040# in the find_path() and find_library() calls
41if (NOT WIN32)
42 find_package(PkgConfig)
eric@webkit.orgd99f85b2010-05-15 13:37:59 +000043
commit-queue@webkit.orgd6fb2c52012-12-06 03:10:13 +000044 pkg_check_modules(PC_SQLITE sqlite3)
eric@webkit.orgd99f85b2010-05-15 13:37:59 +000045
commit-queue@webkit.orgd6fb2c52012-12-06 03:10:13 +000046 set(SQLITE_DEFINITIONS ${PC_SQLITE_CFLAGS_OTHER})
47endif (NOT WIN32)
eric@webkit.orgd99f85b2010-05-15 13:37:59 +000048
commit-queue@webkit.orgd6fb2c52012-12-06 03:10:13 +000049find_path(SQLITE_INCLUDE_DIR NAMES sqlite3.h
50 PATHS
51 ${PC_SQLITE_INCLUDEDIR}
52 ${PC_SQLITE_INCLUDE_DIRS}
eric@webkit.orgd99f85b2010-05-15 13:37:59 +000053)
54
commit-queue@webkit.orgd6fb2c52012-12-06 03:10:13 +000055find_library(SQLITE_LIBRARIES NAMES sqlite3
56 PATHS
57 ${PC_SQLITE_LIBDIR}
58 ${PC_SQLITE_LIBRARY_DIRS}
eric@webkit.orgd99f85b2010-05-15 13:37:59 +000059)
60
61include(FindPackageHandleStandardArgs)
commit-queue@webkit.orgd6fb2c52012-12-06 03:10:13 +000062FIND_PACKAGE_HANDLE_STANDARD_ARGS(Sqlite DEFAULT_MSG SQLITE_INCLUDE_DIR SQLITE_LIBRARIES)
eric@webkit.orgd99f85b2010-05-15 13:37:59 +000063
64# show the SQLITE_INCLUDE_DIR and SQLITE_LIBRARIES variables only in the advanced view
commit-queue@webkit.orgd6fb2c52012-12-06 03:10:13 +000065mark_as_advanced(SQLITE_INCLUDE_DIR SQLITE_LIBRARIES)