ExternalProject_Add for Makefile project error during build
Asked Answered
L

2

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

Lousy answered 28/10, 2020 at 2:5 Comment(1)
Did you managed to solve this issue?Carnival
C
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
Carnival answered 24/1, 2022 at 10:23 Comment(0)
M
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)

Mauk answered 28/10, 2020 at 16:49 Comment(1)
How will this help during build (there is no install yet)?Lousy

© 2022 - 2024 — McMap. All rights reserved.