# cmake rules for eurephia - SQLite3 database driver # # GPLv2 only - Copyright (C) 2008 - 2010 # David Sommerseth # # 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 "/etc/openvpn" 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)