|
|
6289c6 |
diff -up cmake-2.8.10-rc3/Modules/FindPostgreSQL.cmake.findpostgresql cmake-2.8.10-rc3/Modules/FindPostgreSQL.cmake
|
|
|
6289c6 |
--- cmake-2.8.10-rc3/Modules/FindPostgreSQL.cmake.findpostgresql 2012-10-24 11:12:01.000000000 -0600
|
|
|
6289c6 |
+++ cmake-2.8.10-rc3/Modules/FindPostgreSQL.cmake 2012-10-24 19:49:54.189433358 -0600
|
|
|
6289c6 |
@@ -92,77 +92,99 @@ set( PostgreSQL_ROOT_DIRECTORIES
|
|
|
6289c6 |
#
|
|
|
6289c6 |
# Look for an installation.
|
|
|
6289c6 |
#
|
|
|
6289c6 |
-find_path(PostgreSQL_INCLUDE_DIR
|
|
|
6289c6 |
- NAMES libpq-fe.h
|
|
|
6289c6 |
+find_path(PostgreSQL_CONFIG_DIR
|
|
|
6289c6 |
+ NAMES pg_config
|
|
|
6289c6 |
PATHS
|
|
|
6289c6 |
# Look in other places.
|
|
|
6289c6 |
${PostgreSQL_ROOT_DIRECTORIES}
|
|
|
6289c6 |
PATH_SUFFIXES
|
|
|
6289c6 |
- pgsql
|
|
|
6289c6 |
- postgresql
|
|
|
6289c6 |
- include
|
|
|
6289c6 |
+ ""
|
|
|
6289c6 |
+ bin
|
|
|
6289c6 |
# Help the user find it if we cannot.
|
|
|
6289c6 |
- DOC "The ${PostgreSQL_INCLUDE_DIR_MESSAGE}"
|
|
|
6289c6 |
+ DOC "The ${PostgreSQL_ROOT_DIR_MESSAGE}"
|
|
|
6289c6 |
)
|
|
|
6289c6 |
|
|
|
6289c6 |
-find_path(PostgreSQL_TYPE_INCLUDE_DIR
|
|
|
6289c6 |
- NAMES catalog/pg_type.h
|
|
|
6289c6 |
- PATHS
|
|
|
6289c6 |
- # Look in other places.
|
|
|
6289c6 |
- ${PostgreSQL_ROOT_DIRECTORIES}
|
|
|
6289c6 |
- PATH_SUFFIXES
|
|
|
6289c6 |
- postgresql
|
|
|
6289c6 |
- pgsql/server
|
|
|
6289c6 |
- postgresql/server
|
|
|
6289c6 |
- include/server
|
|
|
6289c6 |
- # Help the user find it if we cannot.
|
|
|
6289c6 |
- DOC "The ${PostgreSQL_INCLUDE_DIR_MESSAGE}"
|
|
|
6289c6 |
-)
|
|
|
6289c6 |
-
|
|
|
6289c6 |
-# The PostgreSQL library.
|
|
|
6289c6 |
-set (PostgreSQL_LIBRARY_TO_FIND pq)
|
|
|
6289c6 |
-# Setting some more prefixes for the library
|
|
|
6289c6 |
-set (PostgreSQL_LIB_PREFIX "")
|
|
|
6289c6 |
-if ( WIN32 )
|
|
|
6289c6 |
- set (PostgreSQL_LIB_PREFIX ${PostgreSQL_LIB_PREFIX} "lib")
|
|
|
6289c6 |
- set ( PostgreSQL_LIBRARY_TO_FIND ${PostgreSQL_LIB_PREFIX}${PostgreSQL_LIBRARY_TO_FIND})
|
|
|
6289c6 |
-endif()
|
|
|
6289c6 |
+macro (fail_if)
|
|
|
6289c6 |
+ if (${ARGV})
|
|
|
6289c6 |
+ message (WARNING "Couldn't determine PostgreSQL configuration.")
|
|
|
6289c6 |
+ unset (PostgreSQL_CONFIG_DIR)
|
|
|
6289c6 |
+ break ()
|
|
|
6289c6 |
+ endif ()
|
|
|
6289c6 |
+endmacro ()
|
|
|
6289c6 |
+
|
|
|
6289c6 |
+macro (run_pg_config arg var)
|
|
|
6289c6 |
+ execute_process(COMMAND ${PostgreSQL_CONFIG_DIR}/pg_config ${arg}
|
|
|
6289c6 |
+ RESULT_VARIABLE pgsql_config_result
|
|
|
6289c6 |
+ OUTPUT_VARIABLE ${var}
|
|
|
6289c6 |
+ OUTPUT_STRIP_TRAILING_WHITESPACE)
|
|
|
6289c6 |
+
|
|
|
6289c6 |
+ fail_if (NOT ${pgsql_config_result} EQUAL 0 OR NOT ${var})
|
|
|
6289c6 |
+endmacro ()
|
|
|
6289c6 |
+
|
|
|
6289c6 |
+foreach (once only)
|
|
|
6289c6 |
+ fail_if (NOT PostgreSQL_CONFIG_DIR)
|
|
|
6289c6 |
+
|
|
|
6289c6 |
+ run_pg_config (--version PostgreSQL_VERSION_STRING)
|
|
|
6289c6 |
+ string (REGEX REPLACE "^PostgreSQL (.*)$" "\\1"
|
|
|
6289c6 |
+ PostgreSQL_VERSION_STRING "${PostgreSQL_VERSION_STRING}")
|
|
|
6289c6 |
+ fail_if (NOT PostgreSQL_VERSION_STRING)
|
|
|
6289c6 |
+
|
|
|
6289c6 |
+ run_pg_config (--includedir PostgreSQL_INCLUDE_DIR)
|
|
|
6289c6 |
+ fail_if (NOT EXISTS "${PostgreSQL_INCLUDE_DIR}/libpq-fe.h")
|
|
|
6289c6 |
+
|
|
|
6289c6 |
+ find_path(PostgreSQL_TYPE_INCLUDE_DIR
|
|
|
6289c6 |
+ NAMES catalog/pg_type.h
|
|
|
6289c6 |
+ PATHS ${PostgreSQL_INCLUDE_DIR}
|
|
|
6289c6 |
+ PATH_SUFFIXES
|
|
|
6289c6 |
+ pgsql/server
|
|
|
6289c6 |
+ postgresql/server
|
|
|
6289c6 |
+ include/server
|
|
|
6289c6 |
+ # Help the user find it if we cannot.
|
|
|
6289c6 |
+ DOC "The ${PostgreSQL_INCLUDE_DIR_MESSAGE}"
|
|
|
6289c6 |
+ )
|
|
|
6289c6 |
+ fail_if (NOT PostgreSQL_TYPE_INCLUDE_DIR)
|
|
|
6289c6 |
+
|
|
|
6289c6 |
+ set (PostgreSQL_INCLUDE_DIRS
|
|
|
6289c6 |
+ ${PostgreSQL_INCLUDE_DIR} ${PostgreSQL_TYPE_INCLUDE_DIR})
|
|
|
6289c6 |
+
|
|
|
6289c6 |
+ run_pg_config (--libdir PostgreSQL_LIBRARY_DIRS)
|
|
|
6289c6 |
+
|
|
|
6289c6 |
+ # The PostgreSQL library.
|
|
|
6289c6 |
+ set (PostgreSQL_LIBRARY_TO_FIND pq)
|
|
|
6289c6 |
+ # Setting some more prefixes for the library
|
|
|
6289c6 |
+ set (PostgreSQL_LIB_PREFIX "")
|
|
|
6289c6 |
+ if (WIN32)
|
|
|
6289c6 |
+ set (PostgreSQL_LIB_PREFIX ${PostgreSQL_LIB_PREFIX} "lib")
|
|
|
6289c6 |
+ set (PostgreSQL_LIBRARY_TO_FIND ${PostgreSQL_LIB_PREFIX}${PostgreSQL_LIBRARY_TO_FIND})
|
|
|
6289c6 |
+ endif()
|
|
|
6289c6 |
+
|
|
|
6289c6 |
+ find_library (PostgreSQL_LIBRARY
|
|
|
6289c6 |
+ NAMES ${PostgreSQL_LIBRARY_TO_FIND}
|
|
|
6289c6 |
+ PATHS ${PostgreSQL_LIBRARY_DIRS}
|
|
|
6289c6 |
+ PATH_SUFFIXES lib
|
|
|
6289c6 |
+ )
|
|
|
6289c6 |
+ fail_if (NOT PostgreSQL_LIBRARY)
|
|
|
6289c6 |
+ set (PostgreSQL_LIBRARIES ${PostgreSQL_LIBRARY_TO_FIND})
|
|
|
6289c6 |
|
|
|
6289c6 |
-find_library( PostgreSQL_LIBRARY
|
|
|
6289c6 |
- NAMES ${PostgreSQL_LIBRARY_TO_FIND}
|
|
|
6289c6 |
- PATHS
|
|
|
6289c6 |
- ${PostgreSQL_ROOT_DIRECTORIES}
|
|
|
6289c6 |
- PATH_SUFFIXES
|
|
|
6289c6 |
- lib
|
|
|
6289c6 |
-)
|
|
|
6289c6 |
-get_filename_component(PostgreSQL_LIBRARY_DIR ${PostgreSQL_LIBRARY} PATH)
|
|
|
6289c6 |
-
|
|
|
6289c6 |
-if (PostgreSQL_INCLUDE_DIR AND EXISTS "${PostgreSQL_INCLUDE_DIR}/pg_config.h")
|
|
|
6289c6 |
- file(STRINGS "${PostgreSQL_INCLUDE_DIR}/pg_config.h" pgsql_version_str
|
|
|
6289c6 |
- REGEX "^#define[\t ]+PG_VERSION[\t ]+\".*\"")
|
|
|
6289c6 |
-
|
|
|
6289c6 |
- string(REGEX REPLACE "^#define[\t ]+PG_VERSION[\t ]+\"([^\"]*)\".*" "\\1"
|
|
|
6289c6 |
- PostgreSQL_VERSION_STRING "${pgsql_version_str}")
|
|
|
6289c6 |
- unset(pgsql_version_str)
|
|
|
6289c6 |
-endif()
|
|
|
6289c6 |
+endforeach()
|
|
|
6289c6 |
|
|
|
6289c6 |
# Did we find anything?
|
|
|
6289c6 |
-include(${CMAKE_CURRENT_LIST_DIR}/FindPackageHandleStandardArgs.cmake)
|
|
|
6289c6 |
-find_package_handle_standard_args(PostgreSQL
|
|
|
6289c6 |
- REQUIRED_VARS PostgreSQL_LIBRARY PostgreSQL_INCLUDE_DIR PostgreSQL_TYPE_INCLUDE_DIR
|
|
|
6289c6 |
- VERSION_VAR PostgreSQL_VERSION_STRING)
|
|
|
6289c6 |
-set( PostgreSQL_FOUND ${POSTGRESQL_FOUND})
|
|
|
6289c6 |
+include (FindPackageHandleStandardArgs)
|
|
|
6289c6 |
+find_package_handle_standard_args (PostgreSQL
|
|
|
6289c6 |
+ REQUIRED_VARS
|
|
|
6289c6 |
+ PostgreSQL_LIBRARY_DIRS
|
|
|
6289c6 |
+ PostgreSQL_CONFIG_DIR
|
|
|
6289c6 |
+ PostgreSQL_INCLUDE_DIRS
|
|
|
6289c6 |
+ PostgreSQL_LIBRARIES
|
|
|
6289c6 |
+ VERSION_VAR
|
|
|
6289c6 |
+ PostgreSQL_VERSION_STRING
|
|
|
6289c6 |
+)
|
|
|
6289c6 |
+set (PostgreSQL_FOUND ${POSTGRESQL_FOUND})
|
|
|
6289c6 |
|
|
|
6289c6 |
# Now try to get the include and library path.
|
|
|
6289c6 |
-if(PostgreSQL_FOUND)
|
|
|
6289c6 |
-
|
|
|
6289c6 |
- set(PostgreSQL_INCLUDE_DIRS ${PostgreSQL_INCLUDE_DIR} ${PostgreSQL_TYPE_INCLUDE_DIR} )
|
|
|
6289c6 |
- set(PostgreSQL_LIBRARY_DIRS ${PostgreSQL_LIBRARY_DIR} )
|
|
|
6289c6 |
- set(PostgreSQL_LIBRARIES ${PostgreSQL_LIBRARY_TO_FIND})
|
|
|
6289c6 |
-
|
|
|
6289c6 |
- #message("Final PostgreSQL include dir: ${PostgreSQL_INCLUDE_DIRS}")
|
|
|
6289c6 |
- #message("Final PostgreSQL library dir: ${PostgreSQL_LIBRARY_DIRS}")
|
|
|
6289c6 |
- #message("Final PostgreSQL libraries: ${PostgreSQL_LIBRARIES}")
|
|
|
6289c6 |
+if (PostgreSQL_FOUND)
|
|
|
6289c6 |
+ message (STATUS "PostgreSQL include dirs: ${PostgreSQL_INCLUDE_DIRS}")
|
|
|
6289c6 |
+ message (STATUS "PostgreSQL library dirs: ${PostgreSQL_LIBRARY_DIRS}")
|
|
|
6289c6 |
+ message (STATUS "PostgreSQL libraries: ${PostgreSQL_LIBRARIES}")
|
|
|
6289c6 |
endif()
|
|
|
6289c6 |
|
|
|
6289c6 |
-mark_as_advanced(PostgreSQL_INCLUDE_DIR PostgreSQL_TYPE_INCLUDE_DIR PostgreSQL_LIBRARY )
|