Merge branch 'backport-3.15-toc_on_ppc' into release-3.15

Merge-request: !4122
diff --git a/Modules/CMakeParseImplicitIncludeInfo.cmake b/Modules/CMakeParseImplicitIncludeInfo.cmake
index 91d03cd..ff4c325 100644
--- a/Modules/CMakeParseImplicitIncludeInfo.cmake
+++ b/Modules/CMakeParseImplicitIncludeInfo.cmake
@@ -167,7 +167,7 @@
   set(log "")
 
   # go through each line of output...
-  string(REGEX REPLACE "\r?\n" ";" output_lines "${text}")
+  string(REGEX REPLACE "\r*\n" ";" output_lines "${text}")
   foreach(line IN LISTS output_lines)
     if(state STREQUAL start)
       string(FIND "${line}" "#include \"...\" search starts here:" rv)
diff --git a/Modules/FindBoost.cmake b/Modules/FindBoost.cmake
index 078000f..af4947c 100644
--- a/Modules/FindBoost.cmake
+++ b/Modules/FindBoost.cmake
@@ -449,6 +449,9 @@
     # Convert component found variables to standard variables if required
     # Necessary for legacy boost-cmake and 1.70 builtin BoostConfig
     if(Boost_FIND_COMPONENTS)
+      # Ignore the meta-component "ALL", introduced by Boost 1.73
+      list(REMOVE_ITEM Boost_FIND_COMPONENTS "ALL")
+
       foreach(_comp IN LISTS Boost_FIND_COMPONENTS)
         if(DEFINED Boost_${_comp}_FOUND)
           continue()
diff --git a/Modules/FindGTK2.cmake b/Modules/FindGTK2.cmake
index e3af676..83091f3 100644
--- a/Modules/FindGTK2.cmake
+++ b/Modules/FindGTK2.cmake
@@ -259,6 +259,7 @@
         gtkmm-2.4
         libglade-2.0
         libglademm-2.4
+        harfbuzz
         pango-1.0
         pangomm-1.4
         sigc++-2.0
@@ -711,6 +712,8 @@
         _GTK2_FIND_LIBRARY    (PANGO pango false true)
         _GTK2_ADD_TARGET      (PANGO GTK2_DEPENDS gobject glib)
 
+        _GTK2_FIND_INCLUDE_DIR(HARFBUZZ hb.h)
+
         _GTK2_FIND_LIBRARY    (PANGOCAIRO pangocairo false true)
         _GTK2_ADD_TARGET      (PANGOCAIRO GTK2_DEPENDS pango cairo gobject glib)
 
diff --git a/Modules/FindPostgreSQL.cmake b/Modules/FindPostgreSQL.cmake
index dfece22..dfdd211 100644
--- a/Modules/FindPostgreSQL.cmake
+++ b/Modules/FindPostgreSQL.cmake
@@ -205,11 +205,22 @@
     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}")
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);