1 # CMake module to search for PostgreSQL library
3 # pg_config is searched for in POSTGRES_CONFIG dir,
6 # If it's found it sets POSTGRES_FOUND to TRUE
7 # and following variables are set:
12 IF (NOT POSTGRES_INCLUDE_DIR)
13 FIND_PATH(POSTGRES_INCLUDE_DIR libpq-fe.h /usr/local/include /usr/include c:/msys/local/include)
14 ENDIF (NOT POSTGRES_INCLUDE_DIR)
16 IF (NOT POSTGRES_LIBRARY)
17 FIND_LIBRARY(POSTGRES_LIBRARY NAMES pq PATH /usr/local/lib /usr/lib c:/msys/local/lib)
18 ENDIF (NOT POSTGRES_LIBRARY)
23 SET(POSTGRES_CONFIG_PREFER_PATH "$ENV{POSTGRES_HOME}/bin" CACHE FILEPATH "preferred path to PG (pg_config)")
24 FIND_PROGRAM(POSTGRES_CONFIG pg_config
25 ${POSTGRES_CONFIG_PREFER_PATH}
28 # MESSAGE("DBG POSTGRES_CONFIG ${POSTGRES_CONFIG}")
32 EXEC_PROGRAM(${POSTGRES_CONFIG}
34 OUTPUT_VARIABLE PG_TMP)
35 find_path(POSTGRES_INCLUDE_DIR libpq-fe.h
37 /usr/local/include/postgresql
38 /usr/local/postgresql/include
39 /usr/local/postgresql/include/postgresql
41 /usr/include/postgresql
46 EXEC_PROGRAM(${POSTGRES_CONFIG}
48 OUTPUT_VARIABLE PG_TMP)
49 find_library(POSTGRES_LIBRARY pq
54 /usr/local/lib/postgresql
55 /usr/local/postgresql/lib
57 ENDIF(POSTGRES_CONFIG)
62 IF (POSTGRES_INCLUDE_DIR AND POSTGRES_LIBRARY)
63 SET(POSTGRES_FOUND TRUE CACHE INTERNAL "PostgreSQL found")
64 ENDIF (POSTGRES_INCLUDE_DIR AND POSTGRES_LIBRARY)
69 IF (NOT POSTGRES_FIND_QUIETLY)
70 MESSAGE(STATUS "Found PostgreSQL: ${POSTGRES_INCLUDE_DIR}, ${POSTGRES_LIBRARY}")
71 ENDIF (NOT POSTGRES_FIND_QUIETLY)
73 check_library_exists("${POSTGRES_LIBRARY}" PQescapeStringConn "" HAVE_PQESCAPESTRINGCONN)
77 #SET (POSTGRES_INCLUDE_DIR "")
78 #SET (POSTGRES_LIBRARY "")
80 IF (POSTGRES_FIND_REQUIRED)
81 MESSAGE(FATAL_ERROR "Could not find PostgreSQL")
82 ELSE (POSTGRES_FIND_REQUIRED)
83 MESSAGE(STATUS "Could not find PostgreSQL")
84 ENDIF (POSTGRES_FIND_REQUIRED)
86 ENDIF (POSTGRES_FOUND)