Merge topic 'fix-findpostgres-for-multilib'

741f29cc FindPostgreSQL: Fix for pg_config in multilib configurations.
This commit is contained in:
Brad King 2014-09-02 10:43:19 -04:00 committed by CMake Topic Stage
commit 85e39553fb
1 changed files with 16 additions and 6 deletions

View File

@ -145,12 +145,22 @@ find_library( PostgreSQL_LIBRARY
) )
get_filename_component(PostgreSQL_LIBRARY_DIR ${PostgreSQL_LIBRARY} PATH) get_filename_component(PostgreSQL_LIBRARY_DIR ${PostgreSQL_LIBRARY} PATH)
if (PostgreSQL_INCLUDE_DIR AND EXISTS "${PostgreSQL_INCLUDE_DIR}/pg_config.h") if (PostgreSQL_INCLUDE_DIR)
file(STRINGS "${PostgreSQL_INCLUDE_DIR}/pg_config.h" pgsql_version_str # Some platforms include multiple pg_config.hs for multi-lib configurations
REGEX "^#define[\t ]+PG_VERSION[\t ]+\".*\"") # This is a temporary workaround. A better solution would be to compile
# a dummy c file and extract the value of the symbol.
string(REGEX REPLACE "^#define[\t ]+PG_VERSION[\t ]+\"([^\"]*)\".*" "\\1" file(GLOB _PG_CONFIG_HEADERS "${PostgreSQL_INCLUDE_DIR}/pg_config*.h")
PostgreSQL_VERSION_STRING "${pgsql_version_str}") foreach(_PG_CONFIG_HEADER ${_PG_CONFIG_HEADERS})
if(EXISTS "${_PG_CONFIG_HEADER}")
file(STRINGS "${_PG_CONFIG_HEADER}" pgsql_version_str
REGEX "^#define[\t ]+PG_VERSION[\t ]+\".*\"")
if(pgsql_version_str)
string(REGEX REPLACE "^#define[\t ]+PG_VERSION[\t ]+\"([^\"]*)\".*"
"\\1" PostgreSQL_VERSION_STRING "${pgsql_version_str}")
break()
endif()
endif()
endforeach()
unset(pgsql_version_str) unset(pgsql_version_str)
endif() endif()