This is an automated email from the git hooks/post-receive script. It was generated because a ref change was pushed to the repository containing the project "CMake".
The branch, master has been updated via 9493c770d520d335aeceec81399207f4261f4392 (commit) via aeae4182cb90cbf65b1c27cc877f62d2c7690aaf (commit) from 8f3cbe3c65e1c723319d8c63ef7f3e3c8ef5b59d (commit) Those revisions listed above that are new to this repository have not appeared on any other notification email; so we list those revisions in full, below. - Log ----------------------------------------------------------------- https://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=9493c770d520d335aeceec81399207f4261f4392 commit 9493c770d520d335aeceec81399207f4261f4392 Merge: 8f3cbe3c65 aeae4182cb Author: Brad King <brad.k...@kitware.com> AuthorDate: Thu Nov 7 14:26:07 2019 +0000 Commit: Kitware Robot <kwro...@kitware.com> CommitDate: Thu Nov 7 09:26:17 2019 -0500 Merge topic 'findpostgres-10-and-older' aeae4182cb FindPostgreSQL: support version encoding used in pre-10 releases Acked-by: Kitware Robot <kwro...@kitware.com> Merge-request: !4007 https://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=aeae4182cb90cbf65b1c27cc877f62d2c7690aaf commit aeae4182cb90cbf65b1c27cc877f62d2c7690aaf Author: Ben Boeckel <ben.boec...@kitware.com> AuthorDate: Mon Nov 4 16:37:06 2019 -0500 Commit: Brad King <brad.k...@kitware.com> CommitDate: Thu Nov 7 09:24:12 2019 -0500 FindPostgreSQL: support version encoding used in pre-10 releases With the 10.x release, PostgreSQL upstream started encoding the version as `MMmmmm` where `M` is major and `m` is minor. Prior to that, `MMmmPP` was used where `P` was the patch number. Detect this difference and decode it based on the used encoding. Fixes: #19912 diff --git a/Modules/FindPostgreSQL.cmake b/Modules/FindPostgreSQL.cmake index 4b5e60e21a..1631c9c332 100644 --- a/Modules/FindPostgreSQL.cmake +++ b/Modules/FindPostgreSQL.cmake @@ -184,11 +184,22 @@ if (PostgreSQL_INCLUDE_DIR) endif() endforeach() if (_PostgreSQL_VERSION_NUM) - math(EXPR _PostgreSQL_major_version "${_PostgreSQL_VERSION_NUM} / 10000") - math(EXPR _PostgreSQL_minor_version "${_PostgreSQL_VERSION_NUM} % 10000") - set(PostgreSQL_VERSION_STRING "${_PostgreSQL_major_version}.${_PostgreSQL_minor_version}") - unset(_PostgreSQL_major_version) - unset(_PostgreSQL_minor_version) + # 9.x and older encoding + if (_PostgreSQL_VERSION_NUM LESS 100000) + math(EXPR _PostgreSQL_major_version "${_PostgreSQL_VERSION_NUM} / 10000") + math(EXPR _PostgreSQL_minor_version "${_PostgreSQL_VERSION_NUM} % 10000 / 100") + math(EXPR _PostgreSQL_patch_version "${_PostgreSQL_VERSION_NUM} % 100") + set(PostgreSQL_VERSION_STRING "${_PostgreSQL_major_version}.${_PostgreSQL_minor_version}.${_PostgreSQL_patch_version}") + unset(_PostgreSQL_major_version) + unset(_PostgreSQL_minor_version) + unset(_PostgreSQL_patch_version) + else () + math(EXPR _PostgreSQL_major_version "${_PostgreSQL_VERSION_NUM} / 10000") + math(EXPR _PostgreSQL_minor_version "${_PostgreSQL_VERSION_NUM} % 10000") + set(PostgreSQL_VERSION_STRING "${_PostgreSQL_major_version}.${_PostgreSQL_minor_version}") + unset(_PostgreSQL_major_version) + unset(_PostgreSQL_minor_version) + endif () else () foreach(_PG_CONFIG_HEADER ${_PG_CONFIG_HEADERS}) if(EXISTS "${_PG_CONFIG_HEADER}") diff --git a/Tests/FindPostgreSQL/Test/main.c b/Tests/FindPostgreSQL/Test/main.c index 2cfeed0da2..a63377a256 100644 --- a/Tests/FindPostgreSQL/Test/main.c +++ b/Tests/FindPostgreSQL/Test/main.c @@ -5,10 +5,19 @@ int main() { int version = PQlibVersion(); - int major = version / 10000; - int minor = version % 10000; char version_string[100]; - snprintf(version_string, sizeof(version_string), "%d.%d", major, minor); + // 9.x and older encoding. + if (version < 100000) { + int major = version / 10000; + int minor = version % 10000 / 100; + int patch = version % 100; + snprintf(version_string, sizeof(version_string), "%d.%d.%d", major, minor, + patch); + } else { + int major = version / 10000; + int minor = version % 10000; + snprintf(version_string, sizeof(version_string), "%d.%d", major, minor); + } printf("Found PostgreSQL version %s, expected version %s\n", version_string, CMAKE_EXPECTED_POSTGRESQL_VERSION); return strcmp(version_string, CMAKE_EXPECTED_POSTGRESQL_VERSION); ----------------------------------------------------------------------- Summary of changes: hooks/post-receive -- CMake _______________________________________________ Cmake-commits mailing list Cmake-commits@cmake.org https://cmake.org/mailman/listinfo/cmake-commits