summaryrefslogtreecommitdiffstats
path: root/Tests
diff options
context:
space:
mode:
authorBrad King <brad.king@kitware.com>2019-11-05 16:31:24 (GMT)
committerBrad King <brad.king@kitware.com>2019-11-05 16:31:24 (GMT)
commit3c0a317a1d111fb1012de45c39b81048f5a700d9 (patch)
tree2632c1db66abea24ebbb51adae8a4f28fde97638 /Tests
parent0ec60a400234624b258307a7944184828c8b6abc (diff)
parente992d62b7e15be28c8d560071bcf847f28d9fbb1 (diff)
downloadCMake-3c0a317a1d111fb1012de45c39b81048f5a700d9.zip
CMake-3c0a317a1d111fb1012de45c39b81048f5a700d9.tar.gz
CMake-3c0a317a1d111fb1012de45c39b81048f5a700d9.tar.bz2
Merge branch 'findpostgres-10-and-older' into release-3.16
Merge-request: !3993
Diffstat (limited to 'Tests')
-rw-r--r--Tests/FindPostgreSQL/Test/main.c15
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);