Skip to content

Commit 2be8dc0

Browse files
committed
cmake: add find modules for PCRE and SQLite3
Reviewed-by: Roger Meier <r.meier@siemens.com>
1 parent 74397cc commit 2be8dc0

2 files changed

Lines changed: 122 additions & 0 deletions

File tree

‎cmake/FindPCRE.cmake‎

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
#
2+
# $Id$
3+
#
4+
# - Find pcre
5+
# Find the native PCRE includes and library
6+
#
7+
# PCRE_INCLUDE_DIRS - where to find pcre.h, etc.
8+
# PCRE_LIBRARIES - List of libraries when using pcre.
9+
# PCRE_FOUND - True if pcre found.
10+
11+
12+
IF (PCRE_INCLUDE_DIRS)
13+
# Already in cache, be silent
14+
SET(PCRE_FIND_QUIETLY TRUE)
15+
ENDIF (PCRE_INCLUDE_DIRS)
16+
17+
FIND_PATH(PCRE_INCLUDE_DIR pcre.h)
18+
19+
SET(PCRE_NAMES pcre)
20+
FIND_LIBRARY(PCRE_LIBRARY NAMES ${PCRE_NAMES} )
21+
22+
# handle the QUIETLY and REQUIRED arguments and set PCRE_FOUND to TRUE if
23+
# all listed variables are TRUE
24+
INCLUDE(FindPackageHandleStandardArgs)
25+
FIND_PACKAGE_HANDLE_STANDARD_ARGS(PCRE DEFAULT_MSG PCRE_LIBRARY PCRE_INCLUDE_DIR)
26+
27+
IF(PCRE_FOUND)
28+
SET( PCRE_LIBRARIES ${PCRE_LIBRARY} )
29+
SET( PCRE_INCLUDE_DIRS ${PCRE_INCLUDE_DIR} )
30+
ELSE(PCRE_FOUND)
31+
SET( PCRE_LIBRARIES )
32+
SET( PCRE_INCLUDE_DIRS )
33+
ENDIF(PCRE_FOUND)
34+
35+
MARK_AS_ADVANCED( PCRE_LIBRARIES PCRE_INCLUDE_DIRS )

‎cmake/FindSQLite3.cmake‎

Lines changed: 87 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,87 @@
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)
87+

0 commit comments

Comments
 (0)