summaryrefslogtreecommitdiffstats
path: root/database/postgresql/CMakeLists.txt
blob: ec50b6ab457c71817ca8902926bd1256c052e14c (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
101
102
103
104
105
106
107
108
109
110
111
112
#  cmake rules for eurephia - PostgreSQL database driver
#
#  GPLv2 only - Copyright (C) 2011
#               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-pgsql C)
cmake_minimum_required(VERSION 2.6)

#
# Find PostgreSQL installation and validate the version
#
FIND_PROGRAM(PGCONFIG pg_config /usr)
IF(NOT PGCONFIG)
  MESSAGE(FATAL "Cannot find pg_config.  This driver requires at least PostgreSQL 8.0")
ENDIF(NOT PGCONFIG)

FIND_PATH(PGSQL_INCLUDE_DIR libpq-fe.h
  /usr/include
  /usr/local/include
  $ENV{LIB_DIR}/include/postgresql
)

FIND_LIBRARY(PGSQL_LIBRARIES NAMES pq libpq
  PATHS /usr/lib
  /usr/local/lib
  /usr/lib/postgresql
  /usr/lib64
  /usr/local/lib64
  /usr/lib64/postgresql
  $ENV{LIB_DIR}/lib
)

EXECUTE_PROCESS(COMMAND ${PGCONFIG} --pkglibdir
  OUTPUT_VARIABLE PGSQL_LIBRARIES_DIR
  OUTPUT_STRIP_TRAILING_WHITESPACE
)

EXECUTE_PROCESS(COMMAND ${PGCONFIG} --version
  OUTPUT_VARIABLE PGSQL_VERSION
  OUTPUT_STRIP_TRAILING_WHITESPACE
)
STRING(REGEX MATCH "[0-9].[0-9].[0-9]$" PGSQL_VERSION ${PGSQL_VERSION})

IF(PGSQL_INCLUDE_DIR AND PGSQL_LIBRARIES)
  MESSAGE(STATUS "Found PostgreSQL version ${PGSQL_VERSION}")
  MESSAGE(STATUS "  Include dir: ${PGSQL_INCLUDE_DIR}   Library dir: ${PGSQL_LIBRARIES_DIR}")
ELSE(PGSQL_INCLUDE_DIR AND PGSQL_LIBRARIES)
  MESSAGE(FATAL_ERROR "PostgreSQL not found.")
ENDIF(PGSQL_INCLUDE_DIR AND PGSQL_LIBRARIES)
MARK_AS_ADVANCED(PGSQL_INCLUDE_DIR PGSQL_LIBRARIES)

#
#  Source files
#

IF(ADMIN_ENABLED__disabled_for_now)
       SET(pgsql_admin_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__disabled_for_now)

# Compiler settings
INCLUDE_DIRECTORIES(BEFORE ../../common/ ../../plugin/ ../../plugin/firewall ../ ${PGSQL_INCLUDE_DIRS})
LINK_DIRECTORIES(${PGSQL_LIBRARIES_DIRS})

#
# Build instructions
#
ADD_LIBRARY(edb-pgsql SHARED edb-pgsql.c
                             pgsql-common.c
                             prepared-sql.c
                             ../../common/eurephiadb_session_common.c
                             ${pgsql_admin_SRC})
TARGET_LINK_LIBRARIES(edb-pgsql common pq ${EXTRA_LIBS})
SET_TARGET_PROPERTIES(edb-pgsql PROPERTIES COMPILE_FLAGS -fPIC)

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

ADD_DEFINITIONS(-DDRIVER_MODE)
ADD_DEFINITIONS(${LIBXML2_DEFINITIONS})
SET_TARGET_PROPERTIES(edb-pgsql PROPERTIES OUTPUT_NAME edb-pgsql PREFIX "")
SET_SOURCE_FILES_PROPERTIES(${common_files_SRC} PROPERTIES GENERATED true)

#
# Install instructions
#
INSTALL(TARGETS edb-pgsql LIBRARY DESTINATION ${PLUGINDIR})
# INSTALL(FILES edb-pgsql.7 DESTINATION ${MANDIR}/man7)