- Ubuntu 12.04
- CMake 2.8.9
- Postgresql 9.2.2
I'm trying to get the FindPostgreSQL
module to find /usr/include/postgresql/libpq-fe.h
.
Here's what I have in my CMakeLists.txt
:
find_package(PostgreSQL REQUIRED)
This is the error I get:
CMake Error at /usr/share/cmake-2.8/Modules/FindPackageHandleStandardArgs.cmake:97 (MESSAGE):
Could NOT find PostgreSQL (missing: PostgreSQL_TYPE_INCLUDE_DIR) (found
version "9.2.2")
Call Stack (most recent call first):
/usr/share/cmake-2.8/Modules/FindPackageHandleStandardArgs.cmake:288 (_FPHSA_FAILURE_MESSAGE)
/usr/share/cmake-2.8/Modules/FindPostgreSQL.cmake:155 (find_package_handle_standard_args)
CMakeLists.txt:7 (find_package)
I added the following lines before calling find_package
but it didn't seem to have any effect.
set(PostgreSQL_ADDITIONAL_VERSIONS "9.2.2")
set(PostgreSQL_ADDITIONAL_SEARCH_PATHS ${PostgreSQL_ADDITIONAL_SEARCH_PATHS} "/usr/include/postgresql")
I also tried googling for PostgreSQL_TYPE_INCLUDE_DIR
but didn't find anything. What else can I try?
On Ubuntu you can also work around that issue by calling
cmake
with havingPostgreSQL_TYPE_INCLUDE_DIR
defined like this:See the bug report [1] for this issue and a potential fix [2]. Álso see the discussion about the reasoning behind the move on the debian mailinglist at [3].
On Ubuntu/Debian, starting with PostgreSQL 9.3 the header file
pg_type.h
is moved to a separate package (fromlibpq-dev
topostgresql-server-dev
) and consequently the filepg_type.h
is moved to a new locationMake sure you've installed both
libpq-dev\
andpostgresql-server-dev-all
(or specific version e.g.postgresql-server-dev-9.4
)in case you're missing some package
should fix it.
After a bit more debugging I figured out that it's getting stuck trying to find
pg_type.h
This file is located in
/usr/include/postgresql/catalog/pg_types.h
but the module is expecting to find it in/usr/include/postgresql/server/catalog/pg_types.h
It works if I add
postgresql
to thePATH_SUFFIXES
From Linux Mint 17.3 ("Rosa") with PostgreSQL 9.3, I had to adjust ilia choly's solution (interestingly, the suggested
postgres
entry in the list was already present in the file, but wasn't enough to fix things).I had to edit
/usr/share/cmake-2.8/Modules/FindPostgreSQL.cmake
around line 114 and addpostgresql/9.3
so that thefind_path
call looks like