summaryrefslogtreecommitdiffstats
path: root/database/sqlite/CMakeLists.txt
blob: a0a2dc8b8d79d5014b9c6905253ddc6657fdb4d7 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
#  cmake rules for eurephia - SQLite3 database driver
#
#  GPLv2 only - Copyright (C) 2008 - 2012
#               David Sommerseth <dazo@users.sourceforge.net>
#
#  This program is free software; you can redistribute it and/or
#  modify it under the terms of the GNU General Public License
#  as published by the Free Software Foundation; version 2
#  of the License.
#
#  This program is distributed in the hope that it will be useful,
#  but WITHOUT ANY WARRANTY; without even the implied warranty of
#  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
#  GNU General Public License for more details.
#
#  You should have received a copy of the GNU General Public License
#  along with this program; if not, write to the Free Software
#  Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
#
PROJECT(edb-sqlite C)
cmake_minimum_required(VERSION 2.6)
INCLUDE(CheckIncludeFile) 
INCLUDE(CheckLibraryExists) 

# Parameters the SQLite3 driver needs
SET(SQLITE3PREFIX "/var/lib/eurephia" CACHE STRING "Install prefix for the eurephia SQLite3 database")

#
#  Check for the SQLite3 library
#
find_package(PkgConfig)
pkg_search_module(SQLITE3 REQUIRED sqlite3)
INCLUDE_DIRECTORIES(BEFORE ${SQLITE3_INCLUDE_DIRS})
LINK_DIRECTORIES(${SQLITE3_LIBRARY_DIRS})

FIND_PROGRAM(SQLITE3BIN sqlite3 /usr)
IF(NOT SQLITE3BIN)
       MESSAGE(STATUS "sqlite3 binary was not found.  You will need to generate the database file on your own")
ENDIF(NOT SQLITE3BIN)

#
#  Source files
#
SET(edb_sqlite_SRC
	sqlite.c
	edb-sqlite.c
        ../../common/eurephiadb_session_common.c
)

IF(ADMIN_ENABLED)
       SET(edb_sqlite_SRC ${edb_sqlite_SRC}
               administration/authentication.c
               administration/firewalladmin.c
               administration/attempts.c
               administration/blacklist.c
               administration/usercerts.c
               administration/configuration.c
               administration/useraccount.c
               administration/certificates.c
               administration/lastlog.c
       )
ENDIF(ADMIN_ENABLED)

# Compiler settings
ADD_DEFINITIONS(-D_GNU_SOURCE)
INCLUDE_DIRECTORIES(BEFORE ../../common/ ../../plugin/ ../../plugin/firewall ../)

#
# Build instructions
#
ADD_LIBRARY(edb-sqlite SHARED ${edb_sqlite_SRC})
TARGET_LINK_LIBRARIES(edb-sqlite common ${SQLITE3_LIBRARIES})
SET_TARGET_PROPERTIES( edb-sqlite PROPERTIES COMPILE_FLAGS -fPIC)

IF(SQLITE3BIN)
         ADD_CUSTOM_COMMAND(TARGET edb-sqlite POST_BUILD
                            COMMAND rm -f eurephiadb
                            COMMAND ${SQLITE3BIN} eurephiadb < sql-schema.sql
                                    COMMENT "Creating template database: eurephiadb")
ENDIF(SQLITE3BIN)

IF(FIREWALL)
         ADD_DEFINITIONS(-DFIREWALL)
ENDIF(FIREWALL)

TARGET_LINK_LIBRARIES(edb-sqlite sqlite3 ${EXTRA_LIBS})
ADD_DEFINITIONS(-DDRIVER_MODE)
ADD_DEFINITIONS(${LIBXML2_DEFINITIONS})
SET_TARGET_PROPERTIES(edb-sqlite PROPERTIES OUTPUT_NAME edb-sqlite PREFIX "")
SET_SOURCE_FILES_PROPERTIES(${common_files_SRC} PROPERTIES GENERATED true)
SET_DIRECTORY_PROPERTIES(PROPERTIES ADDITIONAL_MAKE_CLEAN_FILES eurephiadb)

#
# Install instructions
#
INSTALL(TARGETS edb-sqlite LIBRARY DESTINATION ${PLUGINDIR})
INSTALL(FILES edb-sqlite.7 DESTINATION ${MANDIR}/man7)
IF(SQLITE3BIN)
  INSTALL(FILES eurephiadb DESTINATION ${SQLITE3PREFIX}/ RENAME eurephiadb-template)
ENDIF(SQLITE3BIN)