Find PostgreSQL correctly (#8435)
authoradrido <robots_only_adrido@gmx.com>
Sun, 7 Apr 2019 16:45:25 +0000 (18:45 +0200)
committerLoïc Blot <nerzhul@users.noreply.github.com>
Sun, 7 Apr 2019 16:45:25 +0000 (18:45 +0200)
README.md
src/CMakeLists.txt

index 8be6ecc68b604fa2143755c4fb6b80e21ae89ca6..2430f94f6c6ad884c67f8d018e19a17ab8d888e4 100644 (file)
--- a/README.md
+++ b/README.md
@@ -259,7 +259,7 @@ Library specific options:
     LEVELDB_LIBRARY                 - Only when building with LevelDB; path to libleveldb.a/libleveldb.so/libleveldb.dll.a
     LEVELDB_DLL                     - Only when building with LevelDB on Windows; path to libleveldb.dll
     PostgreSQL_INCLUDE_DIR          - Only when building with PostgreSQL; directory that contains libpq-fe.h
-    POSTGRESQL_LIBRARY              - Only when building with PostgreSQL; path to libpq.a/libpq.so
+    PostgreSQL_LIBRARY              - Only when building with PostgreSQL; path to libpq.a/libpq.so/libpq.lib
     REDIS_INCLUDE_DIR               - Only when building with Redis; directory that contains hiredis.h
     REDIS_LIBRARY                   - Only when building with Redis; path to libhiredis.a/libhiredis.so
     SPATIAL_INCLUDE_DIR             - Only when building with LibSpatial; directory that contains spatialindex/SpatialIndex.h
index 7647067765162dd4286a36f4a0e93065fa370d32..45008e337e6692bcd44e14ae4f8af2b2a7f2171e 100644 (file)
@@ -159,27 +159,14 @@ option(ENABLE_POSTGRESQL "Enable PostgreSQL backend" TRUE)
 set(USE_POSTGRESQL FALSE)
 
 if(ENABLE_POSTGRESQL)
-       find_program(POSTGRESQL_CONFIG_EXECUTABLE pg_config DOC "pg_config")
-       find_library(POSTGRESQL_LIBRARY pq)
-       if(POSTGRESQL_CONFIG_EXECUTABLE)
-               execute_process(COMMAND ${POSTGRESQL_CONFIG_EXECUTABLE} --includedir-server
-                       OUTPUT_VARIABLE POSTGRESQL_SERVER_INCLUDE_DIRS
-                       OUTPUT_STRIP_TRAILING_WHITESPACE)
-               execute_process(COMMAND ${POSTGRESQL_CONFIG_EXECUTABLE}
-                       OUTPUT_VARIABLE POSTGRESQL_CLIENT_INCLUDE_DIRS
-                       OUTPUT_STRIP_TRAILING_WHITESPACE)
-               # This variable is case sensitive for the cmake PostgreSQL module
-               set(PostgreSQL_ADDITIONAL_SEARCH_PATHS ${POSTGRESQL_SERVER_INCLUDE_DIRS} ${POSTGRESQL_CLIENT_INCLUDE_DIRS})
-       endif()
-
        find_package("PostgreSQL")
 
-       if(POSTGRESQL_FOUND)
+       if(PostgreSQL_FOUND)
                set(USE_POSTGRESQL TRUE)
                message(STATUS "PostgreSQL backend enabled")
                # This variable is case sensitive, don't try to change it to POSTGRESQL_INCLUDE_DIR
-               message(STATUS "PostgreSQL includes: ${PostgreSQL_INCLUDE_DIR}")
-               include_directories(${PostgreSQL_INCLUDE_DIR})
+               message(STATUS "PostgreSQL includes: ${PostgreSQL_INCLUDE_DIRS}")
+               include_directories(${PostgreSQL_INCLUDE_DIRS})
        else()
                message(STATUS "PostgreSQL not found!")
        endif()
@@ -593,7 +580,7 @@ if(BUILD_CLIENT)
                target_link_libraries(${PROJECT_NAME} ${CURSES_LIBRARIES})
        endif()
        if (USE_POSTGRESQL)
-               target_link_libraries(${PROJECT_NAME} ${POSTGRESQL_LIBRARY})
+               target_link_libraries(${PROJECT_NAME} ${PostgreSQL_LIBRARIES})
        endif()
        if (USE_LEVELDB)
                target_link_libraries(${PROJECT_NAME} ${LEVELDB_LIBRARY})
@@ -628,7 +615,7 @@ if(BUILD_SERVER)
                target_link_libraries(${PROJECT_NAME}server ${CURSES_LIBRARIES})
        endif()
        if (USE_POSTGRESQL)
-               target_link_libraries(${PROJECT_NAME}server ${POSTGRESQL_LIBRARY})
+               target_link_libraries(${PROJECT_NAME}server ${PostgreSQL_LIBRARIES})
        endif()
        if (USE_LEVELDB)
                target_link_libraries(${PROJECT_NAME}server ${LEVELDB_LIBRARY})