77b8eb4e821053f734846adc2ec6b409fc1b205a
[platform/upstream/doxygen.git] / cmake / FindSQLite3.cmake
1 # - Try to find Sqlite3
2 # Once done this will define
3 #
4 #  SQLITE3_FOUND - system has Sqlite3
5 #  SQLITE3_INCLUDE_DIRS - the Sqlite3 include directory
6 #  SQLITE3_LIBRARIES - Link these to use Sqlite3
7 #  SQLITE3_DEFINITIONS - Compiler switches required for using Sqlite3
8 #
9 #  Copyright (c) 2008 Andreas Schneider <mail@cynapses.org>
10 #
11 #  Redistribution and use is allowed according to the terms of the New
12 #  BSD license.
13 #  For details see the accompanying COPYING-CMAKE-SCRIPTS file.
14 #
15
16
17 if (SQLITE3_LIBRARIES AND SQLITE3_INCLUDE_DIRS)
18   # in cache already
19   set(SQLITE3_FOUND TRUE)
20 else (SQLITE3_LIBRARIES AND SQLITE3_INCLUDE_DIRS)
21   # use pkg-config to get the directories and then use these values
22   # in the FIND_PATH() and FIND_LIBRARY() calls
23   if (${CMAKE_MAJOR_VERSION} EQUAL 2 AND ${CMAKE_MINOR_VERSION} EQUAL 4)
24     include(UsePkgConfig)
25     pkgconfig(sqlite3 _SQLITE3_INCLUDEDIR _SQLITE3_LIBDIR _SQLITE3_LDFLAGS _SQLITE3_CFLAGS)
26   else (${CMAKE_MAJOR_VERSION} EQUAL 2 AND ${CMAKE_MINOR_VERSION} EQUAL 4)
27     find_package(PkgConfig)
28     if (PKG_CONFIG_FOUND)
29       pkg_check_modules(_SQLITE3 sqlite3)
30     endif (PKG_CONFIG_FOUND)
31   endif (${CMAKE_MAJOR_VERSION} EQUAL 2 AND ${CMAKE_MINOR_VERSION} EQUAL 4)
32   find_path(SQLITE3_INCLUDE_DIR
33     NAMES
34       sqlite3.h
35     PATHS
36       ${_SQLITE3_INCLUDEDIR}
37       /usr/include
38       /usr/local/include
39       /opt/local/include
40       /sw/include
41   )
42
43   find_library(SQLITE3_LIBRARY
44     NAMES
45       sqlite3
46     PATHS
47       ${_SQLITE3_LIBDIR}
48       /usr/lib
49       /usr/local/lib
50       /opt/local/lib
51       /sw/lib
52   )
53
54   if (SQLITE3_LIBRARY)
55     set(SQLITE3_FOUND TRUE)
56   endif (SQLITE3_LIBRARY)
57
58   set(SQLITE3_INCLUDE_DIRS
59     ${SQLITE3_INCLUDE_DIR}
60   )
61
62   if (SQLITE3_FOUND)
63     set(SQLITE3_LIBRARIES
64       ${SQLITE3_LIBRARIES}
65       ${SQLITE3_LIBRARY}
66     )
67   endif (SQLITE3_FOUND)
68
69   if (SQLITE3_INCLUDE_DIRS AND SQLITE3_LIBRARIES)
70      set(SQLITE3_FOUND TRUE)
71   endif (SQLITE3_INCLUDE_DIRS AND SQLITE3_LIBRARIES)
72
73   if (SQLITE3_FOUND)
74     if (NOT Sqlite3_FIND_QUIETLY)
75       message(STATUS "Found Sqlite3: ${SQLITE3_LIBRARIES}")
76     endif (NOT Sqlite3_FIND_QUIETLY)
77   else (SQLITE3_FOUND)
78     if (Sqlite3_FIND_REQUIRED)
79       message(FATAL_ERROR "Could not find Sqlite3")
80     endif (Sqlite3_FIND_REQUIRED)
81   endif (SQLITE3_FOUND)
82
83   # show the SQLITE3_INCLUDE_DIRS and SQLITE3_LIBRARIES variables only in the advanced view
84   mark_as_advanced(SQLITE3_INCLUDE_DIRS SQLITE3_LIBRARIES)
85
86 endif (SQLITE3_LIBRARIES AND SQLITE3_INCLUDE_DIRS)