summaryrefslogtreecommitdiffstats
path: root/Modules
diff options
context:
space:
mode:
authorBrad King <brad.king@kitware.com>2014-09-02 14:43:19 (GMT)
committerCMake Topic Stage <kwrobot@kitware.com>2014-09-02 14:43:19 (GMT)
commit85e39553fb5edda649e33896b0cf1aa70ec1ae4c (patch)
tree8cf31f0e3f21a2e81fa79dbe6b337a248779ae3e /Modules
parent3db5e31ec12b3fa410aaf18d8b460af969c05381 (diff)
parent741f29cc00beb52ebe45bde8245dae557a72cc10 (diff)
downloadCMake-85e39553fb5edda649e33896b0cf1aa70ec1ae4c.zip
CMake-85e39553fb5edda649e33896b0cf1aa70ec1ae4c.tar.gz
CMake-85e39553fb5edda649e33896b0cf1aa70ec1ae4c.tar.bz2
Merge topic 'fix-findpostgres-for-multilib'
741f29cc FindPostgreSQL: Fix for pg_config in multilib configurations.
Diffstat (limited to 'Modules')
-rw-r--r--Modules/FindPostgreSQL.cmake22
1 files changed, 16 insertions, 6 deletions
diff --git a/Modules/FindPostgreSQL.cmake b/Modules/FindPostgreSQL.cmake
index f13dea8..97666c8 100644
--- a/Modules/FindPostgreSQL.cmake
+++ b/Modules/FindPostgreSQL.cmake
@@ -145,12 +145,22 @@ find_library( PostgreSQL_LIBRARY
)
get_filename_component(PostgreSQL_LIBRARY_DIR ${PostgreSQL_LIBRARY} PATH)
-if (PostgreSQL_INCLUDE_DIR AND EXISTS "${PostgreSQL_INCLUDE_DIR}/pg_config.h")
- file(STRINGS "${PostgreSQL_INCLUDE_DIR}/pg_config.h" pgsql_version_str
- REGEX "^#define[\t ]+PG_VERSION[\t ]+\".*\"")
-
- string(REGEX REPLACE "^#define[\t ]+PG_VERSION[\t ]+\"([^\"]*)\".*" "\\1"
- PostgreSQL_VERSION_STRING "${pgsql_version_str}")
+if (PostgreSQL_INCLUDE_DIR)
+ # Some platforms include multiple pg_config.hs for multi-lib configurations
+ # This is a temporary workaround. A better solution would be to compile
+ # a dummy c file and extract the value of the symbol.
+ file(GLOB _PG_CONFIG_HEADERS "${PostgreSQL_INCLUDE_DIR}/pg_config*.h")
+ 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)
endif()