FindPostgreSQL.cmake won't work on ubuntu

前端 未结 4 1380
抹茶落季
抹茶落季 2021-02-07 14:44
  • Ubuntu 12.04
  • CMake 2.8.9
  • Postgresql 9.2.2

I\'m trying to get the FindPostgreSQL module to find /usr/include/postgre

相关标签:
4条回答
  • 2021-02-07 15:20

    Make sure you've installed both libpq-dev\ and postgresql-server-dev-all (or specific version e.g. postgresql-server-dev-9.4)

    $ dpkg --get-selections | grep -e "libpq-dev\|postgresql-server-dev"
    

    in case you're missing some package

    apt-get install libpq-dev postgresql-server-dev-all
    

    should fix it.

    0 讨论(0)
  • 2021-02-07 15:28

    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

    find_path(PostgreSQL_TYPE_INCLUDE_DIR
      NAMES catalog/pg_type.h
      PATHS
       # Look in other places.
       ${PostgreSQL_ROOT_DIRECTORIES}
      PATH_SUFFIXES
        pgsql/server
        postgresql/server
        include/server
      # Help the user find it if we cannot.
      DOC "The ${PostgreSQL_INCLUDE_DIR_MESSAGE}"
    )
    

    It works if I add postgresql to the PATH_SUFFIXES

    find_path(PostgreSQL_TYPE_INCLUDE_DIR
      NAMES catalog/pg_type.h
      PATHS
       # Look in other places.
       ${PostgreSQL_ROOT_DIRECTORIES}
      PATH_SUFFIXES
        postgresql
        pgsql/server
        postgresql/server
        include/server
      # Help the user find it if we cannot.
      DOC "The ${PostgreSQL_INCLUDE_DIR_MESSAGE}"
    )
    
    0 讨论(0)
  • 2021-02-07 15:32

    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 add postgresql/9.3 so that the find_path call looks like

    find_path(PostgreSQL_TYPE_INCLUDE_DIR
      NAMES catalog/pg_type.h
      PATHS
       # Look in other places.
       ${PostgreSQL_ROOT_DIRECTORIES}
      PATH_SUFFIXES
        postgresql/9.3
        postgresql
        pgsql/server
        postgresql/server
        include/server
      # Help the user find it if we cannot.
      DOC "The ${PostgreSQL_INCLUDE_DIR_MESSAGE}"
    )
    
    0 讨论(0)
  • 2021-02-07 15:38

    On Ubuntu you can also work around that issue by calling cmake with having PostgreSQL_TYPE_INCLUDE_DIR defined like this:

    cmake -DPostgreSQL_TYPE_INCLUDE_DIR=/usr/include/postgresql/
    

    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 (from libpq-dev to postgresql-server-dev) and consequently the file pg_type.h is moved to a new location

    • [1] https://gitlab.kitware.com/cmake/cmake/issues/17223
    • [2] https://gitlab.kitware.com/cmake/cmake/commit/d4fd30d8d8f5b9c4b5a110b4676cad2a19d7c314
    • [3] https://bugs.debian.org/cgi-bin/bugreport.cgi?bug=314427
    0 讨论(0)
提交回复
热议问题