1

I am trying to add Postgresql as a dependency for my project for which I am using ExternalProject module to download the source from github and build, but the build step fails when running from cmake (cmake --build .). Configure step seems to succeed and if I go to the Build directory under EP_BASE and do a make it runs successfully. I get the following error during build:

<...>/Source/postgresql_external/src/common/relpath.c:21:10: fatal error: catalog/pg_tablespace_d.h: No such file or directory
21 | #include "catalog/pg_tablespace_d.h"
  |          ^~~~~~~~~~~~~~~~~~~~~~~~~~~
compilation terminated.
make[5]: *** [<builtin>: relpath.o] Error 1
make[4]: *** [Makefile:42: all-common-recurse] Error 2
make[3]: *** [GNUmakefile:11: all-src-recurse] Error 2

My external project add looks like the following:

ExternalProject_Add(postgresql_external
  GIT_REPOSITORY    https://github.com/postgres/postgres.git
  GIT_TAG           REL_12_4
  CONFIGURE_COMMAND <SOURCE_DIR>/configure --prefix=<INSTALL_DIR>
  LOG_CONFIGURE 1
  LOG_BUILD 1
  LOG_INSTALL 1
)

This is running on Ubuntu 20.04 LTS, with cmake 3.16.3, gcc 9.3.0

Eqbal
  • 4,722
  • 12
  • 38
  • 47

2 Answers2

1

Try the following code, it works for me. PotgreSQL uses MAKELEVEL variable to generate header files via perl. When you call make directly it works as expected. But it seems that cmake adds more levels to PotgreSQL's root make, so headers are not generated.

CONFIGURE_COMMAND ./configure <your options>
BUILD_IN_SOURCE 1
BUILD_COMMAND $(MAKE) MAKELEVEL=0
w00drow
  • 468
  • 2
  • 11
0

try

ExternalProject_Get_Property(postgresql_external install_dir)
include_directories(${install_dir}/include)

I guess, you haven't propagate include directory to your target yet, but it is evtl. known to your system (thus successful call of manually called make)

dboy
  • 1,004
  • 2
  • 16
  • 24