eric@webkit.org | d99f85b | 2010-05-15 13:37:59 +0000 | [diff] [blame] | 1 | # - 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.org | d99f85b | 2010-05-15 13:37:59 +0000 | [diff] [blame] | 8 | # |
eric@webkit.org | d99f85b | 2010-05-15 13:37:59 +0000 | [diff] [blame] | 9 | # Copyright (c) 2008, Gilles Caulier, <caulier.gilles@gmail.com> |
| 10 | # |
rakuco@webkit.org | f846279 | 2012-04-30 21:02:51 +0000 | [diff] [blame] | 11 | # 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.org | d99f85b | 2010-05-15 13:37:59 +0000 | [diff] [blame] | 33 | |
commit-queue@webkit.org | d6fb2c5 | 2012-12-06 03:10:13 +0000 | [diff] [blame] | 34 | if (SQLITE_INCLUDE_DIR AND SQLITE_LIBRARIES) |
| 35 | # in cache already |
| 36 | set(Sqlite_FIND_QUIETLY TRUE) |
| 37 | endif (SQLITE_INCLUDE_DIR AND SQLITE_LIBRARIES) |
eric@webkit.org | d99f85b | 2010-05-15 13:37:59 +0000 | [diff] [blame] | 38 | |
| 39 | # use pkg-config to get the directories and then use these values |
commit-queue@webkit.org | d6fb2c5 | 2012-12-06 03:10:13 +0000 | [diff] [blame] | 40 | # in the find_path() and find_library() calls |
| 41 | if (NOT WIN32) |
| 42 | find_package(PkgConfig) |
eric@webkit.org | d99f85b | 2010-05-15 13:37:59 +0000 | [diff] [blame] | 43 | |
commit-queue@webkit.org | d6fb2c5 | 2012-12-06 03:10:13 +0000 | [diff] [blame] | 44 | pkg_check_modules(PC_SQLITE sqlite3) |
eric@webkit.org | d99f85b | 2010-05-15 13:37:59 +0000 | [diff] [blame] | 45 | |
commit-queue@webkit.org | d6fb2c5 | 2012-12-06 03:10:13 +0000 | [diff] [blame] | 46 | set(SQLITE_DEFINITIONS ${PC_SQLITE_CFLAGS_OTHER}) |
| 47 | endif (NOT WIN32) |
eric@webkit.org | d99f85b | 2010-05-15 13:37:59 +0000 | [diff] [blame] | 48 | |
commit-queue@webkit.org | d6fb2c5 | 2012-12-06 03:10:13 +0000 | [diff] [blame] | 49 | find_path(SQLITE_INCLUDE_DIR NAMES sqlite3.h |
| 50 | PATHS |
| 51 | ${PC_SQLITE_INCLUDEDIR} |
| 52 | ${PC_SQLITE_INCLUDE_DIRS} |
eric@webkit.org | d99f85b | 2010-05-15 13:37:59 +0000 | [diff] [blame] | 53 | ) |
| 54 | |
commit-queue@webkit.org | d6fb2c5 | 2012-12-06 03:10:13 +0000 | [diff] [blame] | 55 | find_library(SQLITE_LIBRARIES NAMES sqlite3 |
| 56 | PATHS |
| 57 | ${PC_SQLITE_LIBDIR} |
| 58 | ${PC_SQLITE_LIBRARY_DIRS} |
eric@webkit.org | d99f85b | 2010-05-15 13:37:59 +0000 | [diff] [blame] | 59 | ) |
| 60 | |
| 61 | include(FindPackageHandleStandardArgs) |
commit-queue@webkit.org | d6fb2c5 | 2012-12-06 03:10:13 +0000 | [diff] [blame] | 62 | FIND_PACKAGE_HANDLE_STANDARD_ARGS(Sqlite DEFAULT_MSG SQLITE_INCLUDE_DIR SQLITE_LIBRARIES) |
eric@webkit.org | d99f85b | 2010-05-15 13:37:59 +0000 | [diff] [blame] | 63 | |
| 64 | # show the SQLITE_INCLUDE_DIR and SQLITE_LIBRARIES variables only in the advanced view |
commit-queue@webkit.org | d6fb2c5 | 2012-12-06 03:10:13 +0000 | [diff] [blame] | 65 | mark_as_advanced(SQLITE_INCLUDE_DIR SQLITE_LIBRARIES) |