From 6d16cb3e2b48b4fb1f8d6efb3aea3ebd08b8bbfb Mon Sep 17 00:00:00 2001
From: Oliver Freyermuth <o.freyermuth@googlemail.com>
Date: Tue, 12 Apr 2016 23:51:16 +0200
Subject: [PATCH] FindPostgreSQL.cmake: Add PATH_SUFFIX for searching.

This slightly changes lookup order: Namely, the system-folder "/usr/include/postgresql"
is now preferred over "/usr/include/" even if both container libpq-fe.h.
This finds the correct path on a standard Gentoo installation, where "/usr/include/postgresql"
is a symlink to the folder with all include-files for the user-selected postgresql-version,
while "/usr/include/libpq-fe.h" is a single symlink provided for backwards-compatibility.

Since ROOT uses also e.g. "pg_config.h", selecting "/usr/include/" over "/usr/include/postgresql"
leads to failure on Gentoo.
---
 cmake/modules/FindPostgreSQL.cmake | 3 +++
 1 file changed, 3 insertions(+)

diff --git a/cmake/modules/FindPostgreSQL.cmake b/cmake/modules/FindPostgreSQL.cmake
index 9413a0377c9..ff339d4fa26 100644
--- a/cmake/modules/FindPostgreSQL.cmake
+++ b/cmake/modules/FindPostgreSQL.cmake
@@ -28,6 +28,9 @@ find_path(POSTGRESQL_INCLUDE_DIR libpq-fe.h
    "/usr/include/pgsql/server"
    "/usr/include/postgresql/server"
    "/usr/include/postgresql/*/server"
+  PATH_SUFFIXES
+    postgresql
+    include
 )
 
 find_library(POSTGRESQL_LIBRARY NAMES pq
-- 
GitLab