diff options
author | Brad King <brad.king@kitware.com> | 2019-11-05 16:23:39 (GMT) |
---|---|---|
committer | Kitware Robot <kwrobot@kitware.com> | 2019-11-05 16:23:59 (GMT) |
commit | 3521e3d524447f0f3ac20f8e2df2435dd6de7aa2 (patch) | |
tree | 506208f4c11b0a208ebb3c2d3a7db04d8b82c11d /Tests | |
parent | 153226a1471d38ecf54b807a0d6cfa30c436166a (diff) | |
parent | e992d62b7e15be28c8d560071bcf847f28d9fbb1 (diff) | |
download | CMake-3521e3d524447f0f3ac20f8e2df2435dd6de7aa2.zip CMake-3521e3d524447f0f3ac20f8e2df2435dd6de7aa2.tar.gz CMake-3521e3d524447f0f3ac20f8e2df2435dd6de7aa2.tar.bz2 |
Merge topic 'findpostgres-10-and-older'
e992d62b7e FindPostgreSQL: support version encoding used in pre-10 releases
Acked-by: Kitware Robot <kwrobot@kitware.com>
Merge-request: !3993
Diffstat (limited to 'Tests')
-rw-r--r-- | Tests/FindPostgreSQL/Test/main.c | 15 |
1 files changed, 12 insertions, 3 deletions
diff --git a/Tests/FindPostgreSQL/Test/main.c b/Tests/FindPostgreSQL/Test/main.c index 2cfeed0..a63377a 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); |