| 1 |
# cmake rules for eurephia - SQLite3 database driver |
| 2 |
# |
| 3 |
# GPLv2 only - Copyright (C) 2008 - 2012 |
| 4 |
# David Sommerseth <[email protected]> |
| 5 |
# |
| 6 |
# This program is free software; you can redistribute it and/or |
| 7 |
# modify it under the terms of the GNU General Public License |
| 8 |
# as published by the Free Software Foundation; version 2 |
| 9 |
# of the License. |
| 10 |
# |
| 11 |
# This program is distributed in the hope that it will be useful, |
| 12 |
# but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 13 |
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
| 14 |
# GNU General Public License for more details. |
| 15 |
# |
| 16 |
# You should have received a copy of the GNU General Public License |
| 17 |
# along with this program; if not, write to the Free Software |
| 18 |
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. |
| 19 |
# |
| 20 |
PROJECT(edb-sqlite C) |
| •21 |
cmake_minimum_required(VERSION 3.5) |
| 22 |
INCLUDE(CheckIncludeFile) |
| 23 |
INCLUDE(CheckLibraryExists) |
| 24 |
|
| 25 |
# Parameters the SQLite3 driver needs |
| 26 |
SET(SQLITE3PREFIX "/var/lib/eurephia" CACHE STRING "Install prefix for the eurephia SQLite3 database") |
| 27 |
|
| 28 |
# |
| 29 |
# Check for the SQLite3 library |
| 30 |
# |
| 31 |
find_package(PkgConfig) |
| 32 |
pkg_search_module(SQLITE3 REQUIRED sqlite3) |
| 33 |
INCLUDE_DIRECTORIES(BEFORE ${SQLITE3_INCLUDE_DIRS}) |
| 34 |
LINK_DIRECTORIES(${SQLITE3_LIBRARY_DIRS}) |
| 35 |
|
| 36 |
FIND_PROGRAM(SQLITE3BIN sqlite3 /usr) |
| 37 |
IF(NOT SQLITE3BIN) |
| 38 |
MESSAGE(STATUS "sqlite3 binary was not found. You will need to generate the database file on your own") |
| 39 |
ENDIF(NOT SQLITE3BIN) |
| 40 |
|
| 41 |
# |
| 42 |
# Source files |
| 43 |
# |
| 44 |
SET(edb_sqlite_SRC |
| 45 |
sqlite.c |
| 46 |
edb-sqlite.c |
| 47 |
../../common/eurephiadb_session_common.c |
| 48 |
) |
| 49 |
|
| 50 |
IF(ADMIN_ENABLED) |
| 51 |
SET(edb_sqlite_SRC ${edb_sqlite_SRC} |
| 52 |
administration/authentication.c |
| 53 |
administration/firewalladmin.c |
| 54 |
administration/attempts.c |
| 55 |
administration/blacklist.c |
| 56 |
administration/usercerts.c |
| 57 |
administration/configuration.c |
| 58 |
administration/useraccount.c |
| 59 |
administration/certificates.c |
| 60 |
administration/lastlog.c |
| 61 |
) |
| 62 |
ENDIF(ADMIN_ENABLED) |
| 63 |
|
| 64 |
# Compiler settings |
| 65 |
ADD_DEFINITIONS(-D_GNU_SOURCE) |
| 66 |
INCLUDE_DIRECTORIES(BEFORE ../../common/ ../../plugin/ ../../plugin/firewall ../) |
| 67 |
|
| 68 |
# |
| 69 |
# Build instructions |
| 70 |
# |
| 71 |
ADD_LIBRARY(edb-sqlite SHARED ${edb_sqlite_SRC}) |
| 72 |
TARGET_LINK_LIBRARIES(edb-sqlite common ${SQLITE3_LIBRARIES}) |
| 73 |
SET_TARGET_PROPERTIES( edb-sqlite PROPERTIES COMPILE_FLAGS -fPIC) |
| 74 |
|
| 75 |
IF(SQLITE3BIN) |
| 76 |
ADD_CUSTOM_COMMAND(TARGET edb-sqlite POST_BUILD |
| 77 |
COMMAND rm -f eurephiadb |
| 78 |
COMMAND ${SQLITE3BIN} eurephiadb < sql-schema.sql |
| 79 |
COMMENT "Creating template database: eurephiadb") |
| 80 |
ENDIF(SQLITE3BIN) |
| 81 |
|
| 82 |
IF(FIREWALL) |
| 83 |
ADD_DEFINITIONS(-DFIREWALL) |
| 84 |
ENDIF(FIREWALL) |
| 85 |
|
| 86 |
TARGET_LINK_LIBRARIES(edb-sqlite sqlite3 ${EXTRA_LIBS}) |
| 87 |
ADD_DEFINITIONS(-DDRIVER_MODE) |
| 88 |
ADD_DEFINITIONS(${LIBXML2_DEFINITIONS}) |
| 89 |
SET_TARGET_PROPERTIES(edb-sqlite PROPERTIES OUTPUT_NAME edb-sqlite PREFIX "") |
| 90 |
SET_SOURCE_FILES_PROPERTIES(${common_files_SRC} PROPERTIES GENERATED true) |
| 91 |
SET_DIRECTORY_PROPERTIES(PROPERTIES ADDITIONAL_MAKE_CLEAN_FILES eurephiadb) |
| 92 |
|
| 93 |
# |
| 94 |
# Install instructions |
| 95 |
# |
| 96 |
INSTALL(TARGETS edb-sqlite LIBRARY DESTINATION ${PLUGINDIR}) |
| 97 |
INSTALL(FILES edb-sqlite.7 DESTINATION ${MANDIR}/man7) |
| 98 |
IF(SQLITE3BIN) |
| 99 |
INSTALL(FILES eurephiadb DESTINATION ${SQLITE3PREFIX}/ RENAME eurephiadb-template) |
| 100 |
ENDIF(SQLITE3BIN) |