From 433aab306ed573cad7895678edf07843b2b2195d Mon Sep 17 00:00:00 2001 From: Sandeep Thakkar Date: Tue, 6 Sep 2022 14:19:21 +0530 Subject: [PATCH] The current logic to get the version from the version string depends on the position (11) which may not work with other postgres variants because of the different strings they may carry like EnterpriseDB for an example. So instead of of using string substring to parse the version, use string regex match. Also, move up the code to replace the strings alpha/beta/rc a bit to support the patch Tested on Linux --- CMakeLists.txt | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index c523b79d51f..bdc4256f22d 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -169,15 +169,16 @@ if(NOT POSTGRESQL_FOUND OR NOT POSTGRESQL_VERSION_STRING) message(FATAL_ERROR "PostgreSQL not found - Please check your PostgreSQL installation.") endif() +# for XbetaY XalphaY XrcY -> X.Y +string(REGEX REPLACE "([0-9]+)[beta|alpha|rc|devel].*" "\\1.0" POSTGRESQL_VERSION_STRING ${POSTGRESQL_VERSION_STRING}) message(STATUS "POSTGRESQL_VERSION_STRING=${POSTGRESQL_VERSION_STRING}") -string(SUBSTRING "${POSTGRESQL_VERSION_STRING}" 11 -1 POSTGRESQL_VERSION) -# for XbetaY XalphaY XrcY -> X.Y -string(REGEX REPLACE "^([0-9]+)[beta|alpha|rc|devel].*" "\\1.0" POSTGRESQL_VERSION ${POSTGRESQL_VERSION}) +STRING(REGEX MATCH "([0-9]+)\.([0-9]+)" POSTGRESQL_VERSION "${POSTGRESQL_VERSION_STRING}") +message(STATUS "POSTGRESQL_VERSION=${POSTGRESQL_VERSION}") #for X.Y.Z -> XY Y<10 string(REGEX REPLACE "^([0-9]+)\\.([0-9]+).*" "\\1\\2" PGSQL_VERSION ${POSTGRESQL_VERSION}) - +#message(STATUS "PGSQL_VERSION=${PGSQL_VERSION}") if("${POSTGRESQL_VERSION}" VERSION_LESS "${POSTGRESQL_MINIMUM_VERSION}") message(FATAL_ERROR " PostgreSQL ${POSTGRESQL_MINIMUM_VERSION} or greater is required.")