Added PostgreSQL storage support option for cmake for Unices (on Windows

we will need some registry readings or lookup directory within src 
path). Also fixed issues with mysql/sqlite finding scripts that were 
ignoring some attributes (like REQUIRED which makes it error if it 
cannot find it).
This commit is contained in:
dizzy 2007-08-27 20:02:18 +00:00
parent 229f057fd3
commit 8a538ca23c
7 changed files with 77 additions and 15 deletions

View file

@ -20,6 +20,7 @@ endif(WIN32)
#storage backends flags
option(WITH_MYSQL "include MySQL user accounts support" OFF)
option(WITH_SQLITE3 "include SQLite3 user accounts support" OFF)
option(WITH_PGSQL "include PostgreSQL user accounts support" OFF)
include(ConfigureChecks.cmake)

View file

@ -43,6 +43,9 @@ endif(WITH_MYSQL)
if(WITH_SQLITE3)
find_package(SQLite3 REQUIRED)
endif(WITH_SQLITE3)
if(WITH_PGSQL)
find_package(PostgreSQL REQUIRED)
endif(WITH_PGSQL)
# if any of nsl or socket exists we need to make sure the following tests
# use them otherwise some functions may not be found

View file

@ -7,7 +7,7 @@
IF (MYSQL_INCLUDE_DIR)
# Already in cache, be silent
SET(MYSQL_FIND_QUIETLY TRUE)
SET(MySQL_FIND_QUIETLY TRUE)
ENDIF (MYSQL_INCLUDE_DIR)
FIND_PATH(MYSQL_INCLUDE_DIR mysql.h
@ -43,17 +43,17 @@ ELSE (MYSQL_INCLUDE_DIR AND MYSQL_LIBRARY)
ENDIF (MYSQL_INCLUDE_DIR AND MYSQL_LIBRARY)
IF (MYSQL_FOUND)
IF (NOT MYSQL_FIND_QUIETLY)
IF (NOT MySQL_FIND_QUIETLY)
MESSAGE(STATUS "Found MySQL: ${MYSQL_LIBRARY}")
ENDIF (NOT MYSQL_FIND_QUIETLY)
ENDIF (NOT MySQL_FIND_QUIETLY)
ELSE (MYSQL_FOUND)
IF (MYSQL_FIND_REQUIRED)
IF (MySQL_FIND_REQUIRED)
MESSAGE(STATUS "Looked for MySQL libraries named ${MYSQL_NAMES}.")
MESSAGE(FATAL_ERROR "Could NOT find MySQL library")
ENDIF (MYSQL_FIND_REQUIRED)
ENDIF (MySQL_FIND_REQUIRED)
ENDIF (MYSQL_FOUND)
MARK_AS_ADVANCED(
MYSQL_LIBRARY
MYSQL_INCLUDE_DIR
)
)

View file

@ -0,0 +1,53 @@
# - Find libpq
# Find the native PostgreSQL includes and library
#
# PGSQL_INCLUDE_DIR - where to find libpq-fe.h, etc.
# PGSQL_LIBRARIES - List of libraries when using PGSQL.
# PGSQL_FOUND - True if PGSQL found.
IF (PGSQL_INCLUDE_DIR)
# Already in cache, be silent
SET(PostgreSQL_FIND_QUIETLY TRUE)
ENDIF (PGSQL_INCLUDE_DIR)
FIND_PATH(PGSQL_INCLUDE_DIR libpq-fe.h
/usr/local/pgsql/include
/usr/local/include/pgsql
/usr/local/include
/usr/include/pgsql
/usr/include
/usr/pgsql/include
)
SET(PGSQL_NAMES pq)
SET(PGSQL_SEARCH_LIB_PATHS
/usr/local/pgsql/lib /usr/local/lib /usr/lib
)
FIND_LIBRARY(PGSQL_LIBRARY
NAMES ${PGSQL_NAMES}
PATHS ${PGSQL_SEARCH_LIB_PATHS}
)
IF (PGSQL_INCLUDE_DIR AND PGSQL_LIBRARY)
SET(PGSQL_FOUND TRUE)
SET( PGSQL_LIBRARIES ${PGSQL_LIBRARY} )
ELSE (PGSQL_INCLUDE_DIR AND PGSQL_LIBRARY)
SET(PGSQL_FOUND FALSE)
SET( PGSQL_LIBRARIES )
ENDIF (PGSQL_INCLUDE_DIR AND PGSQL_LIBRARY)
IF (PGSQL_FOUND)
IF (NOT PostgreSQL_FIND_QUIETLY)
MESSAGE(STATUS "Found PostgreSQL: ${PGSQL_LIBRARY}")
ENDIF (NOT PostgreSQL_FIND_QUIETLY)
ELSE (PGSQL_FOUND)
IF (PostgreSQL_FIND_REQUIRED)
MESSAGE(STATUS "Looked for PostgreSQL libraries named ${PGSQL_NAMES}.")
MESSAGE(FATAL_ERROR "Could NOT find PostgreSQL library")
ENDIF (PostgreSQL_FIND_REQUIRED)
ENDIF (PGSQL_FOUND)
MARK_AS_ADVANCED(
PGSQL_LIBRARY
PGSQL_INCLUDE_DIR
)

View file

@ -7,7 +7,7 @@
IF (SQLITE3_INCLUDE_DIR)
# Already in cache, be silent
SET(SQLITE3_FIND_QUIETLY TRUE)
SET(SQLite3_FIND_QUIETLY TRUE)
ENDIF (SQLITE3_INCLUDE_DIR)
FIND_PATH(SQLITE3_INCLUDE_DIR sqlite3.h
@ -32,17 +32,17 @@ ELSE (SQLITE3_INCLUDE_DIR AND SQLITE3_LIBRARY)
ENDIF (SQLITE3_INCLUDE_DIR AND SQLITE3_LIBRARY)
IF (SQLITE3_FOUND)
IF (NOT SQLITE3_FIND_QUIETLY)
IF (NOT SQLite3_FIND_QUIETLY)
MESSAGE(STATUS "Found SQLite3: ${SQLITE3_LIBRARY}")
ENDIF (NOT SQLITE3_FIND_QUIETLY)
ENDIF (NOT SQLite3_FIND_QUIETLY)
ELSE (SQLITE3_FOUND)
IF (SQLITE3_FIND_REQUIRED)
IF (SQLite3_FIND_REQUIRED)
MESSAGE(STATUS "Looked for SQLite3 libraries named ${SQLITE3_NAMES}.")
MESSAGE(FATAL_ERROR "Could NOT find SQLite3 library")
ENDIF (SQLITE3_FIND_REQUIRED)
ENDIF (SQLite3_FIND_REQUIRED)
ENDIF (SQLITE3_FOUND)
MARK_AS_ADVANCED(
SQLITE3_LIBRARY
SQLITE3_INCLUDE_DIR
)
)

View file

@ -25,6 +25,9 @@ endif(MYSQL_FOUND)
if(SQLITE3_FOUND)
add_definitions("-DWITH_SQL_SQLITE3")
endif(SQLITE3_FOUND)
if(PGSQL_FOUND)
add_definitions("-DWITH_SQL_PGSQL")
endif(PGSQL_FOUND)
subdirs(compat common win32 tinycdb bntrackd client bniutils bnpass)

View file

@ -1,5 +1,7 @@
# add aditional includes corresponding to the additional libraries bellow
include_directories(${ZLIB_INCLUDE_DIR} ${MYSQL_INCLUDE_DIR} ${SQLITE3_INCLUDE_DIR})
include_directories(${ZLIB_INCLUDE_DIR} ${MYSQL_INCLUDE_DIR}
${SQLITE3_INCLUDE_DIR} ${PGSQL_INCLUDE_DIR}
)
set(BNETD_SOURCES
account.cpp account.h account_wrap.cpp account_wrap.h adbanner.cpp
@ -44,7 +46,7 @@ set(BNETD_GUI_SOURCES
add_executable(bnetd ${BNETD_SOURCES}
${BNETD_CONSOLE_RESOURCES})
target_link_libraries(bnetd common compat win32 tinycdb ${NETWORK_LIBRARIES}
${ZLIB_LIBRARIES} ${MYSQL_LIBRARIES} ${SQLITE3_LIBRARIES})
${ZLIB_LIBRARIES} ${MYSQL_LIBRARIES} ${SQLITE3_LIBRARIES} ${PGSQL_LIBRARIES})
install(TARGETS bnetd DESTINATION ${SBINDIR})
# build the GUI version too
@ -54,6 +56,6 @@ if(WITH_WIN32_GUI)
${BNETD_GUI_RESOURCES})
set_target_properties(bnetd_gui PROPERTIES COMPILE_FLAGS "-DWIN32_GUI")
target_link_libraries(bnetd_gui common_gui compat win32_gui tinycdb ${NETWORK_LIBRARIES}
${ZLIB_LIBRARIES} ${MYSQL_LIBRARIES} ${SQLITE3_LIBRARIES})
${ZLIB_LIBRARIES} ${MYSQL_LIBRARIES} ${SQLITE3_LIBRARIES} ${PGSQL_LIBRARIES})
install(TARGETS bnetd_gui DESTINATION ${SBINDIR})
endif(WITH_WIN32_GUI)