diff options
author | Ben Boeckel <ben.boeckel@kitware.com> | 2019-11-04 16:37:06 -0500 |
---|---|---|
committer | Ben Boeckel <ben.boeckel@kitware.com> | 2019-11-04 16:38:52 -0500 |
commit | e992d62b7e15be28c8d560071bcf847f28d9fbb1 (patch) | |
tree | f6594716e50c74cd501ba1566960e27aa0eb232a /Modules/FindPostgreSQL.cmake | |
parent | c1d5d5eb11e0260ffadda0851ac844ab46b6b179 (diff) | |
download | cmake-e992d62b7e15be28c8d560071bcf847f28d9fbb1.tar.gz |
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
Diffstat (limited to 'Modules/FindPostgreSQL.cmake')
-rw-r--r-- | Modules/FindPostgreSQL.cmake | 21 |
1 files changed, 16 insertions, 5 deletions
diff --git a/Modules/FindPostgreSQL.cmake b/Modules/FindPostgreSQL.cmake index cfa4ebce9f..4fcc79def8 100644 --- a/Modules/FindPostgreSQL.cmake +++ b/Modules/FindPostgreSQL.cmake @@ -208,11 +208,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}") |