mirror of
https://github.com/Kitware/CMake.git
synced 2026-05-05 22:00:10 -05:00
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
This commit is contained in:
@@ -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);
|
||||
|
||||
Reference in New Issue
Block a user